Linux Module 3 Working With Text

¡Supera tus tareas y exámenes ahora con Quizwiz!

End of line

$

If last character in the pattern, then pattern must be at the end of the line to match, otherwise just a literal $

$

When used with a process will immediately background the process or task in a terminal. This will allow the terminal to be freed up for additional tasks.

&

adding this symbol after the command allows the command to execute as a background process

&

: The notation "2>&1" means send stderr to where stdout is going and the notation ___ means redirect all output.

&>

To send the normal and error output of a command to a single file, you can use

&>

Used to create groups

( )

Zero or more of the previous character

*

One or more of the previous pattern

+

Highest priority

-20

Using the -p option along with the process identifier (PID)

-p

Any one single character

.

To search forward from the current position of the cursor, use the

/

Sometimes it isn't useful to have the error messages displayed in the terminal or stored in a file. To discard these error messages, use the __ the ___ is like a trash can where anything sent to it disappears from the system sometimes called a "bit bucket" or "black hole"

/dev/null

Default niceness

0

Lowest Priority

19

To return to the first line

1G

Go to line #1 by typing 1G. Search for "local" by typing /local. Type the letter n to move to the second occurrence of "local":

1G /local n

Type __ to return to the first line and then __ to delete five lines. In the vi editor

1G 5dd

The number __ is associated with the standard error file descriptor

2

To redirect the errors that are output by a command, you can use

2&>

To prevent clobbering an existing file when redirecting standard error, use the double > character after the number 2 to append instead

2>>

Copy three lines by typing 3yy. Then move to the end of the document by typing G. Paste the three lines by typing p

3yy G p

To delete 5 lines

5dd

To quit the vi editor

:q

To exit the vi editor, type in the following

:q!

The previous command :q failed because you have not saved the changes that you made in the file. To quit without saving type :q! and press the Enter key to quit the document and not save any changes:

:q! Enter

places between commands to execute multuple commands on a single command.

;

The__ Symbol is used for input redirection and used to pass the contents of a file as input to a command

<

Redirecting output using a single > (greater than symbol) will create a new file, or overwrite the contents of an existing file with the same name. Redirecting standard output with two greater than symbols >> will also create a new file if it does not exist.

>

Standard output is redirected using the__ symbol followed by the name of the file to which it will be written

>

The output of the command __ will be appended to the end of a file if it does already exist. For example, to append to the file that was created by the previous command, execute the following

>>

The preceding pattern is optional

?

To start searching backwards from the cursor position, start by typing

?

Enter insert mode at the end of the line

A

key combination that will force kill a process

CTRL+C

key combination that will stop a process

CTRL+Z

Press the Escape key to return to the command mode. Type dd to delete the current line:

ESC dd

To save the changes in vi type

Esc :w

Move to the end of the Document

G

Move to the end of the document by typing a G character

G

Hang up ends the process on logout

HUP

Enter insert mode at the beginning of the line

I

The process identifier, which is unique to the process. This information is useful to control the process by its ID number.

PID

The name of the terminal or pseudo-terminal where the process is running. This information is useful to distinguish between different processes that have the same name.

TTY

The square brackets [ ] work in regular expressions similar to how they work in glob expressions; they match a single character from the list or range of possible characters contained within the brackets.

[1]

Any one specified character

[]

On the other hand, to find all the lines which contain any non-numeric characters, insert a ^ as the first character inside the brackets. This character negates the characters listed "example 0 through 9"

[^0-9]

Not the one specified character

[^]

Beginning of line

^

If first character in the pattern, then pattern must be at beginning of the line to match, otherwise just a literal

^

Enter insert mode right after the cursor

a

Recall that an alias is a feature that allows a user to create nicknames for commands or command lines. Having an alias that runs multiple commands can be very useful and to accomplish this, the user would use the ; between each of the commands when creating the alias. For example, to create an alias called welcome which outputs the current user, the date, and the current directory listing, execute the following command:

alias welcome="whoami;date;ls"

Five or less characters

a{,5}

Zero or One a characters

a{0,1} a?

The regular expression a* is equivalent to

a{0,}

Zero or more characters

a{0,}

One or more Characters

a{1,}

From three to five a characters

a{3,5}

Five characters

a{5}

One word back

b

Regular expressions have two common forms

basic and extended.

A job control command that resumes the execution of a suspended process without bringing it to the foreground.

bg

Replace line of a document by typing

cc

Delete the next three words

d3w

Delete four characters to the left

d4h

To delete the current line

dd

Delete the current word by typing dw

dw

To delete the word

dw

The following table summarizes the extended regular expressions, which must be used with either the ___ command or the _ option with the ___ command

egrep grep -E

A job control command that resumes execution of a suspended process by bringing it to the foreground.

fg

Commands that read in text as input, alter that text in some way and then produce text as output are sometimes known as

filters

o redirect the standard error while executing the find command, execute the following commands "find a standard file in the etc directory with the standard error file descriptor"

find /etc . -name hostname 2> error.txt

Command used to display the amount of free and used memory in the system. This utility will display both the physical and swap memory on the system as well as the buffers used by the kernel.

free

The second anchor character $ can be used to ensure a pattern appears at the end of the line, thereby effectively reducing the search results. To find the lines that end with an r in the alpha-first.txt file, use the pattern r$

grep 'r$' alpha-first.txt

The simplest of all regular expressions is just to use literal characters. For example to locate all lines of the /etc/passwd file that contain the expression root, use the command

grep 'root' /etc/passwd

If you want to use grep without regard to the capitalization of text, you can use the option

grep -i

The first anchor character ^ is used to ensure that a pattern appears at the beginning of the line.

grep ^root

Left one character

h

Enter insert mode right before the cursor

i

Down one line

j

[3] Running the notations represent what?

job number

After using the top command to view the processes the __ key will allow a user to kill or send a signal to a process

k

Up one line

k

To kill a running process or job use the command

kill %1

To send the force kill to a process use the

kill -9 kill -KILL %1 kill -SIGKILL -p 96

To see a list of all of the signals available for your system, execute the

kill -l

To send the Terminate signal, to this process, you can use any of the following commands Process : 123 job number [1]

kill 123 kill %1 kill -p 123

Command similar to kill, but killall will allow a user to terminate a process by name as opposed to ID.

killall

Unlike the kill command, these other commands can be used to terminate all processes of a particular user with the -u option. For example, _____ would stop all of the process owned by the user "bob".

killall -u bob

Right one character

l

To view the output of the ls command one page at a time, execute the following command

ls -l /etc | more

Which of the following commands will take the standard error of the ls command and put it into the /tmp/output.txt file

ls 2> /tmp/output.txt

Which of the following commands will take the standard output of the ls and put it into the /tmp/output.txt file

ls > /tmp/output.txt

will list the files in a home directory

ls ~

Command used to change the priority of a process. The higher the nice value the lower the priority of a process. Nice values range from -20 to 20.

nice

Command used to run a command immune to hangups, with output to a non-tty. If standard input is a terminal, it can be redirected from /dev/null. If standard output is the terminal, append the ouptput to nohup.out. This should be located in the user's home directory.

nohup

No hang up lets the process continue

nohup

After executing the script, the user could proceed to logout. The next time the user logs in, the output of the script, if any, would be contained in the nohup.out file in that user's home directory.

nohup.out

To add a new line at the end of the document, type a o character and then type the end. Press the Escape key to return to the command mode

o the end ESC

Command that looks through the currently running processes and lists the process IDs that match the selection criteria.

pgrep

Two or more commands combined with the "|" between them form a

pipeline

Sends a specified signal (SIGTERM by default) to each process instead of listing them on stdout

pkill

Command used to report a snapshot of the current processes. Different options are available with ps to report more specific information.

ps

Execute the ps command to display the commands that are running in your current shell

ps

View all of the processes on the system by executing the following command

ps -fe

Command used to change the priority of a process while that process is running. The higher the value the lower the priority.

renice

Pressing the r key will allow a user to ___ a process by prompting for the PID and then the new niceness value.

renice

You can use the ____ command to change an existing process priority. A regular user can not change a process to a lower priority

renice

A full-screen software program that can be used to multiplex a physical console between several processes (typically interactive shells). It offers a user to open several separate terminal instances inside a one single terminal window manager. The screen application is very useful, if you are dealing with multiple programs from a command line interface and for separating programs from the terminal shell. It also allows you to share your sessions with others users and detach/attach terminal sessions.

screen

pressing k and selecting the process id and sending the proper signature will kill the process

sigkill

When a command encounters an error, it will produce output that is known as standard error also called

stderr

When a command executes without any errors, the output that is produced is known as standard out also called

stdout

Command used to read from standard input and write to standard output and files. splits the output of a command into two streams: one directed to the terminal, and the other into a file

tee

The | symbol separates alternative expressions that can match; it's also known as alternation. For example, to match the word tire or tyre, use the expression

tire|tyre

To display a real-time view of running processes, execute the following command

top

translate all the lower-case characters to upper-case in the /etc/hosts file, execute the following command

tr 'a-z' 'A-Z' < /etc/hosts

Both input as well as output redirection can be used together in the same command. To translate all the lower-case characters to upper-case in the /etc/hosts file and save the output in the ~/myhosts file, execute the following command

tr 'a-z' 'A-Z' < /etc/hosts > ~/myhosts

Undo the paste command by typing the letter

u

Undo the paste command by typing the letter u

u

Command that will display how long a system has been running. uptime gives a one line display showing the current time, how long ths system has been running, how many users are logged in, and the system load averages for the past 1, 5 and 15 minutes.

uptime

One word forward

w

Command used to build and execute command lines from standard input

xargs

Specify minimum, maximum or exact matches of the previous pattern

{}

If you want to overwrite a file by redirecting the output of a command, you can use

|

The command pipeline is used to send the output of one command as input to another

|


Conjuntos de estudio relacionados

Chapter 25 - Fluid, Electrolyte, Acid-Base Balance

View Set

CHAPTER 24- soft tissue injuries

View Set

Unit 2 - Chemistry of Life - Quiz 2: Properties of Compounds

View Set

Mexican Revolution Unit 1 Key Terms

View Set

Chapter 5 Accounting for merchandising operations

View Set