Outcome 2 Revision Flashcards

(39 cards)

1
Q

What are the contents of the /bin directory?

A

The programs ‘pwd’, ‘rmdir’ and ‘ls’ and the following ‘uname’ program all live in the filesystem

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

What does Uname command do?

A

It shows system information and is useful for finding information such as the Linux kernel, CPU, and hardware platform.

uname –n - shows (print the network node (server) hostname)
uname -a - (print all information)

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

What does the pipe symbol do | ?

A

The pipe command takes the output of the first command and uses it as the input for the second command. Pipe is denoted by the pipe symbol ‘|’

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

What is happening in this command?:

Cy2a30@RIV-0M-MUOS-01ls /dev | grep sda

A

The command gets the listing of the current directory and then pipes it to (sends it to) the second command which is a grep command.

The grep command selects those lines from the directory listing (which it received from the ls command) having the regular expression ‘sda’ in them.

So basically as a result of this command you would get a list of files or directories that have the pattern ‘sda’ in their names.

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

What does ‘pwd’ command do?

A

It prints the full path of the current working directory

The pwd command should always be used should you get lost or confused in the file system. It lets you see the absolute path and lets you determine where you are in the context of the filesystem. If you have any problems as to your present location simply type cd as this will take you directly to your own home directory

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

The root / directory

A

The / (forward slash) is known as root and is denoted by a forward slash. This is known as the root directory. It is used to denote the starting point of the Linux filesystem and you cannot go any further back than this. Think of it as the equivalent of the ‘C’ drive in Windows.

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

What is the /var directory?

A

This directory contains ‘miscellaneous’ files used for the day to day running of the system.

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

What are the default permissions for a file and directory in Linux?

A
  • 644 for a file
  • 755 for a directory
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

How to recall previous commands?

A
  • The ‘up arrow’ key
  • ctrl+p
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

Introduction to the vi editor

A

Command Mode

This mode accepts commands, which are usually entered as single letters.
For instance, pressing the ‘i’ key or the ‘a’ key both get you into insert mode as does pressing the insert key itself, although in somewhat different ways, as described shortly, pressing the ‘o’ key opens a file in a line below the current one.

Ex Mode

To manipulate files (including saving your current file and running outside programs), you use ex mode. You enter ex mode from command mode by typing a colon (:), typically directly followed by the name of the ex-mode command you want to use. After you run the ex-mode command, Vi returns automatically to command mode.

Insert Mode

You enter text in insert mode. Most keystrokes result in text appearing on the screen. One important exception is the Esc key, which exits insert mode and returns to command mode.

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

What is the boot process in Linux?

A

cpu initiates bios
bios loads and runs boot loader
boot loader runs and runs secondary boot loaders and linux kernel
linux kernel loads and runs init
init start rest of services via Sys V and other startup scripts

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

What is the echo command?

A

The echo command when used on the command line or in a script will take a text string and write it to standard output – your screen.

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

What does this command do? :

echo Hello my name is caleb > names.odt

A

This command will create a new file with a .odt extension. Using this command simply sends (redirects) the text away from the screen by using a single > symbol typed after the text - to a new file called names.odt ‘. If the names.odt file previously did not exist; it will be created.

If names.odt does already exist – the redirection operator (>) will overwrite its existing contents.

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

What does Append symbol&raquo_space; do?

A

It adds data to a file without overwritting the exisiting contents.

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

What is the Tee command?

A

The tee command when used in conjunction with pipe, is used to store and view (both at the same time) the output of any other command. The tee command writes to the stdout (monitor) and to a file at the same time as shown in the examples below.

By default, the tee command overwrites the previous content of a file. You can instruct the tee command to append (add to the end) of the file using the –a option.

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

What does this command do? :

find –maxdepth 2 –name *.txt

A

This command will search the current level (1) and one level down and give me the name of these files with a .txt extension and the directory they are in.

The find command shown above when used with the correct options will search for all .txt files but will restrict the search to the current directory level (1) and the all subdirectories located one level down.

Find & grep are NOT the same program – grep matches a pattern

17
Q

What does the head command do?

A

It echoes (by default) the first 10 lines of one or more files to standard output.

Another definition: It prints the first lines of one or more files (or piped data) to standard output. By default, it shows the first 10 lines.

18
Q

What does the Tail command do?

A

The tail command works just like head, except that (by default) tail displays the last 10 lines of a file. (You can use the –n lines options to change the amount of data displayed, just as with head.) This command is useful for examining recent activity in log files or other files to which data may be appended.

Tail -f

The -f or –follow option tells tail to keep the file open and to display new lines of input as they’re added. This feature is helpful for tracking log files because it enables you to see changes as they’re made to the file and who or which device made those changes.

19
Q

What do these commands do? :

  • vmstat 2 20 > vmstat.log
  • tail –f vmstat.log
A

The first command will display the virtual memory statistics for the Linux server. The statistics will update every 2 seconds and display 20 lines of output. After the 20th line you’ll be returned to the prompt.

The second command - tail –f vmstat.log allows you to watch the vmstat.log file being continuously updated with the virtual memory statistics in real time.

When the vmstat command on your first screen terminates after the 20th entry, the vmstat.log file just stops. To exit the vmstat.log file just press ctrl+z

Remember! – tail –f vmstat.log however will keep the vmstat.log file open and display new lines as they are continuously updated.

Note: tail vmstat.log will only show the last 10 lines (by default).

20
Q

What is a process in Linux?

A

A process is identified on the system by a process ID. That process ID is unique for the current system. In other words, no other process can use that number as its process ID while that first process is still running. However, once a process is ended, another process can reuse that number.

Along with a process ID number, there are other attributes associated with a process. Each process, when it is run, is associated with a particular user account and group account. That account information helps determine what system resources the process can access (similar to access to our college system). For example, processes run as the root user have much more access to system files and resources than a process running as a regular user

21
Q

Which command shows the top 35 processes running on the system?

A

ps –e | head -36

The command to see all processes is - ps -e

Note: Use the ps –e command and pipe it with wc –l to see how many processes there are. (Possibly over 350 are running)

To see only the processes owned by you, use the ps u command.

22
Q

What does “ vi file2& “ command do?

A

It will place the process called file2 into the background as a running process. Note the process ID. Your process IDs will be different from the examples shown.

Alternatively you could use these 3 commands:
1. vi file2
2. ctrl+z
3. bg

23
Q

What does ‘fg’ command do?

A

If there is only one job then the fg (foreground) will bring this job to the foreground. If there are more than one job then the ‘%’ would be used symbol refers to the most recent command placed into the background.

24
Q

What are the Kill commands?

A

kill -9 and kill -15

25
Process priority in Linux
Changing Priority on Linux Processes When talking about the priority of a process, all we are talking about is how best to manage processor time. The CPU effectively appears to juggle multiple tasks at the same time. At times we can have enough resource to take on multiple processes and other times we can only focus on one process at a time. Occasionally, however something important will pop up and the CPU needs to devote all its energy into handling that task while putting less important tasks on the back burner. In Linux we can set guidelines for the CPU to follow when it is looking at all the tasks it has to do. These guidelines are called niceness or nice value. The Linux niceness scale goes from -20 to 19.
26
Priority/Nice Numbers
In Linux we can set guidelines for the CPU to follow when it is looking at all the tasks it has to do. These guidelines are called niceness or nice value. The Linux niceness scale goes from -20 to 19. Remember: The lower the number (the negative value), the higher the priority. A program set as -20 will have the highest priority! If the nice value is high positive number like 19, the task will be set to the lowest priority and the CPU will process it whenever it gets a chance. Note: The nice number (NI) has a default value of 0 Note: The default priority (PR) value is 20 Only root may launch a program with increased priority (that is: give a negative priority value). By using this scale, we can allocate our CPU resources more appropriately. Lower priority programs that are not important can be set to a higher nice value, while high priority programs like daemons and services can be set to receive more of the CPU’s focus. You can even give a specific user a lower nice value for all of his/her processes so you can limit their ability to slow down the computer’s core services.
27
Checking the Priority of Running Processes
The easiest way to get a quick picture of what the current niceness priority on a process is to open up the top processes with using the top command. On our system the top processes are displayed every 3 seconds by default but you can also reset this value so that top will display every 5 seconds by using the command. top –d5 (d= delay time) or every 7 seconds with…top –d7
28
What is the Tar program?
The tar program’s name stands for “tape archiver.” and is often used for transferring multiple files between computers in one step, such as distributing source code tar – cf create an archived file tar –tvf view the contents of the archived file verbosely (detailed) tar –tf view the contents of the archived file tar –xf extract the files from the archive
29
What is the Cpio archive utility?
The cpio archiving program is similar in principle to tar, but the details of its operation differ. As with tar, you can direct its output straight to a tape device or to a regular file. The cpio archive utility has three operating modes: . Copy-Out Mode This mode, activated by use of the -o or --create option, creates an archive and copies files into it. . Copy-In Mode You activate copy-in mode by using the -i or --extract option. This mode extracts data from an existing archive. If you provide a filename or a pattern to match, cpio extracts only the files whose names match the pattern you provide. . Copy-Pass Mode This mode is activated by the -p or --pass-through option. It combines the copy-out and copy-in modes, enabling you to copy a directory tree from one location to another.
30
As you can see lines 5, 8, 10, 12, 14 and 15 have usb0 in the string. Which command will show you only the lines mentioned above?
command cat usbfile.odt | grep usb0
31
How to create directory structure 'dir1/dir2/dir3/dir4'?
mkdir -p dir1/dir2/dir3/dir4
32
How to show numbered list using Cat command?
cat -n (file name) or nl (file name)
33
What is the command to see the first 5 entries in a file called cities?
head -5 cities
34
What is the command to see the last 3 entries in a file called cities?
tail -3 cities *by default tail displays the last 10 lines of a file.
35
What is the command to get number of how many processes there are running?
ps -e | wc -l
36
What does this command do 'vi file2&' ?
This will place the process called file2 into the background as a running process. *Alternatively you could use these 3 commands: 1. vi file2 2. ctrl+z 3. bg
37
What does 'top –d5 ' command do?
that top will display processes every 5 seconds
38
What does ' ls | cpio -ov > archive.cpio ' command do?
This command uses the cpio archive utility using the –o v switches to create a verbose file and list them redirect this to archive.cpio.
39