Chapter 3 (Using the Shell) Flashcards
A — is like a program or a macro
Script
A — is essentially a list of commands stored in a text file.
Script
The default shell for all Linux systems is —
Bash
Changing to a new default shell is very easy using the — command.
usermod
The – — records each command that you enter at the shell prompt.
Command History
The — command displays the entire history list, which normally includes at least — commands
History, 1000
A exclamation point is sometimes called a – in unix and Linux
bang
The — script contains configuration information that applies to every user on the system.
/etc/profile
Each users home directory can contain another start-up script called—
.profile
The — script is executed each time the user starts a bash shell.
.bashrc
(Bash Scripts)
— is executed each time a bash shell is started.
.bash_default
.bash_login
(Bash Scripts)
— is executed each time a user closes a bash shell
.bash_logout
A — is a string of characters that is substituted for another string of characters at the shell prompt.
Alias
The — command lets you define how the shell will substitute one string of text for another string of text that you enter at a shell prompt.
Alias
(Alias example)
alias muont=mount
The — command writes text to the screen.
Echo
As used in a Linux shell, is a name that can have a value assigned to it.
Shell variable
(Note)
Variables are typically created using all uppercase letters, though they don’t have to be. `
|
You can use the — command to start a program with an environment variable setting that is not part of your current environment.
env
An — — is a variable that has typically been defined (assigned a value) as part of the process of initializing either the operating system or the particular shell in which a user is working.
Environment Variable
The — command displays a list of all environment variables defined in your current environment.
set
Example $ set
Channels of communication in Linux can be redirected, however, using — operators
Redirection
When a program expects input such as a line of text, it reads that information from the standard — – – channel.
Standard Input channel (abbreviated STDIN)
When a program generates output, it normally sends it to the — — —
Standard output channel (abbreviated STDOUT)
A special tool for redirecting communication between programs is called a —
pipe
A — connects the output channel of one command to the input channel of another command.
pipe
$ ls /etc | sort
The result is that sort writes to the screen the lines from ls, sorted according to the first word in each line.
The — command is used to display the number of characters words and lines in a text file.
wc
> filename
Writes STDOUT output to the given file name.
(Example) ls -l > savelisting
> > filename
Appends to STDOUT output to the given file name (adding it to the end of any existing file contents)
(Example) can newfile»_space; existing_file
<filename
Sends data from the given file name as the STDIN, rather than reading from the keyboard.
(Example) my_script<input_codes
You can use the — command to write the contents of any file to the screen.
cat
(Note) Using the append operator, you can add the small file to the end of the larger file.
(Example)
$ cat small_file»_space; large_file
The — command lets you redirect output to a file and also to the screen.
tee
$ sort data_file | tee sorted_data
The following command displays the output of the sort command and also writes it to the file sorted_data
$ sort data_file | tee -a sorted_data
You can have the tee command append data to the end of the named file by adding an -a option.