Unix Flashcards

1
Q

What is an SH file?

A

Files with the .sh extension are UNIX shell script files. This allows you to execute a chain of UNIX commands as a single unit of work in a convenient and repeatable way.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What is SSH?

A

ssh (SSH client) is a program for logging into a remote machine and for executing commands on a remote machine. It is intended to replace rlogin and rsh, and provide secure encrypted communications between two untrusted hosts over an insecure network.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

How do you know what directory you are in?

A

Using the pwd command will print the working directory.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

How do you list all the files in a directory?

A

The ls command prints files and subdirectories in the current folder. Expose hidden files with the -a option.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

How do you edit a file in UNIX?

A

You can use the cat command or open the file with a text editor, such as vi or nano.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What is the cat command?

A

The cat command reads one or more files and prints them to standard output. The operator (one arrow pointing right) can be used to combine multiple files into one. The operator (two arrow pointing right) can be used to append to an existing file.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

How would you change directories?

A

Using the cd command and specifying the desired location.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

What is echo used for?

A

Echo prints a string value to the standard console output. You can pipe output from another command into echo, print a variable’s value, and more.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

What is telnet?

A

The telnet command allows you to communicate to another host using the TELNET protocol. telnet [host [port]]

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

What is the difference between find and grep?

A

“find” is a file locator while “grep” searches for patterns within a file.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

What does grep do?

A

The grep command is used to search text or searches the given file for lines containing a match to the given strings, words, or regular expression. By default, grep displays the matching lines.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

What does chmod command do?

A

In Unix operating systems, chmod is the command that can change the access permissions to files and directories. The syntax is: chmod (options) (permissions) (filename). The permissions list includes permissions for user, group, and other. You can use rwx (read, write, execute) notation or 0-7 digits to represent the permissions

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

If you have a variable called ‘name’, how would you reference that?

A

You can prepend the $ character to the beginning of the variable name, in this case $name will retrieve the environment variable’s value. You can change and set variable values using key=value syntax.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

What is the diff command?

A

“diff analyzes two files and prints the lines that are different. Essentially, it outputs a set of instructions for how to change one file in order to make it identical to the second file. It does not actually change the files; however, it can optionally generate a script (with the -e option) for the program ed (or ex which can be used to apply the changes. For example: diff file1.txt file2.txt”

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

How would you monitor a log file?

A

“SSH on to your server then type: tail -f /var/log/httpd/access_log The above command will show you the last few lines of the log file. The -f option will print to your console any new lines added to the log file in realtime. So you can get a live view of additions to the log file. “

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

What is sudo?

A

Sudo stands for either “substitute user do” or “super user do”. Sudo allows a user to run a program as another user (most often the root user) to achieve “best practice security” on Linux. Sudo access is temporary, and lasts only on a per-command basis.

17
Q

What is root?

A

root is the user name or account that by default has access to all commands and files on a Linux or other Unix-like operating system. It is also referred to as the root account, root user and the superuser.

18
Q

What is RPM, yum, and apt?

A

“Red Hat Package Manager (RPM) is the package management system used for packaging in the Linux Standard Base (LSB). RPM is used for querying and verifying packages, and installing, upgrading, and removing packages. Yellowdog Updater Modified (YUM) adds automatic updates and package management, including dependency management, to RPM systems. YUM works with repositories, which are collections of packages, typically accessible over a network connection. Advanced Package Tool (Apt) is the package management system used by Debian and distributions derived from Debian, such as Ubuntu.”

19
Q

Explain how to create a new user.

A

useradd [options] username. Options include user id (must be > 999), home directory, login shell, days until account or password expires, and comment (typically used to specify the user’s full name).

20
Q

What is the kill command?

A

Use the kill command to send a signal to each process specified by a pid (process identifier). The default signal is SIGTERM (terminate the process). For example: kill PID or kill -s signalName PID

21
Q

What is the CURL command?

A

Transfers data from or to a server, using one of the protocols: HTTP, HTTPS, FTP, FTPS, SCP, SFTP, TFTP, DICT, TELNET, LDAP or FILE.

22
Q

What is the rm command?

A

removes each specified file. By default, it does not remove directories.

23
Q

What is the tree command?

A

tree lists the contents of directories in a tree-like format. It’s a really neat and useful program you can use at the command line to view the structure of your file system.

24
Q

What is the nano command?

A

nano is a small, free and friendly editor which aims to replace Pico, the default editor included in the non-free Pine package. Rather than just copying Pico’s look and feel, nano also implements some missing (or disabled by default) features in Pico, such as “search and replace” and “go to line number”.

25
Q

What is chmod?

A

chmod changes the permissions of each given file according to mode, where mode describes the permissions to modify. Mode can be specified with octal numbers or with letters.

26
Q

What is chown?

A

chown changes the user and/or group ownership of each given file. If only an owner (a user name or numeric user ID) is given, that user is made the owner of each given file, and the files’ group is not changed. If the owner is followed by a colon and a group name (or numeric group ID), with no spaces between them, the group ownership of the files is changed as well. If a colon but no group name follows the user name, that user is made the owner of the files and the group of the files is changed to that user’s login group. If the colon and group are given, but the owner is omitted, only the group of the files is changed; in this case, chown performs the same function as chgrp. If only a colon is given, or if the entire operand is empty, neither the owner nor the group is changed.