Create
Learn
Share

Linux 103

rename
verickle's version from 2017-11-11 21:35

Shells

Question Answer
bashthe most common default shell for user accounts
Shshell upon which bash is based
tcshbased on the earlier C shell
cshoriginal C shell
kshdesigned to take the best features of the Bourne shell and the C shell and extend them
zshtakes shell evolution further than the Korn shell, incorporating features from earlier shells and adding still more
/bin/sha pointer to the system's default system shell
memorize

Common redirection operators

Question Answer
>Creates a new file containing standard output. If the specified file exists, it's overwritten. No file descriptor necessary.
>>Appends standard output to the existing file. If the specified file doesn't exist, it's created. No file descriptor necessary.
2>Creates a new file containing standard error. If the specified file exists, it's overwritten. File descriptor necessary.
2>>Appends standard error to the existing file. If the specified file doesn't exist, it's created. File descriptor necessary.
&>Creates a new file containing both standard output and standard error. If the specified file exists, it's overwritten. No file descriptors necessary.
<Sends the contents of the specified file to be used as standard input. No file descriptor necessary.
<<Accepts text on the following lines as standard input. No file descriptor necessary.
<>Causes the specified file to be used for both standard input and standard output. No file descriptor necessary.
|redirects the first program's standard output to the second program's standard input
memorize

Commands

Question Answer
unsetdelete an environment variable
envview the entire environment
mantext-based help system
infolike man, but uses a hypertext format so that you can move from section to section of the documentation for a program
helpspecifically for the built-in (internal) commands
pwddisplays the current working directory
exitterminates any shell
echodisplays its arguments
STDOUTstandard output device
logoutterminates only login shells.
catdisplay a file's contents to STDOUT
teesplits standard input so that it's displayed on standard output and in as many files as you specify
`text within backticks is treated as a separate command whose results are substituted on the command line
$()easier way to use ` (backtick)
memorize

File combining

Question Answer
catlinks together an arbitrary number of files end to end and sends the result to standard output
cat -E or cat --show-endsThe result is a dollar sign ($) at the end of each line.
cat -n or cat --numberadds line numbers to the beginning of every line
cat -s or cat --squeeze-blankcompresses groups of blank lines down to a single blank line
cat -T ot cat --show-tabsdisplays tab characters as ∧I
tacsimilar to cat, but it reverses the order of lines in the output
joincombines two files by matching the contents of specified fields within the files
pastemerges files line by line, separating the lines from each file with tabs
sed
expandconverts tabs to spaces
memorize

Manual sections

Question Answer
1Executable programs and shell commands
2System calls provided by the kernel
3Library calls provided by program libraries
4Device files (usually stored in /dev)
5File formats
6Games
7Miscellaneous (macro packages, conventions, and so on)
8System administration commands (programs run mostly or exclusively by root)
9Kernel routines
memorize

File Descriptors

Question Answer
0STDIN
1STDOUT
2STDERR
STDINStandard Input
STDOUTStandard Output
STDERRStandard Error
Standard Inputthe data that comes into the computer from a keyboard
Standard Outputnormally displayed on the screen, either in a full-screen text-mode session or in a GUI terminal emulator
Standard Errorintended to carry high-priority information such as error messages
memorize

Glossary

Question Answer
AccountStored information and a reserved directory that allows an individual (or sometimes a utility or server program) to use a computer. The term is often used and thought of as if it were a distinct virtual component of a computer that a person can use, as in "Sam logged into his account" or "Miranda's account isn't working."
American Standard Code for Information Interchange (ASCII)An encoding method for alphanumeric data, commonly used for text files. ASCII is a common code, but because it lacks characters used by many non-English languages, other encoding methods, such as UTF-8, are slowly supplanting it.
ASCIISee American Standard Code for Information Interchange (ASCII).
bashThe GNU Bourne Again Shell (bash) is based on the earlier Bourne shell for Unix but extends it in several ways. In Linux, bash is the most common default shell for user accounts.
bshThe Bourne shell upon which bash is based also goes by the name bsh. It's not often used in Linux, although the bsh command is sometimes a symbolic link to bash.
Command completionA feature of many Linux shells that simplifies typing long commands. Pressing the Tab key causes the shell to search for possible commands or filenames that would complete the command. If only one command or filename matches the characters typed so far, the shell completes the entry. If not, the shell enters the characters up to the point where the user must specify another character.
cshThe original C shell isn't much used on Linux, but if a user is familiar with csh, tcsh makes a good substitute.
Environment variablesEnvironment variables are like variables in programming languages—they hold data to be referred to by the variable name. Environment variables differ from programs' internal variables in that they're part of the environment of a program, and other programs, such as the shell, can modify this environment.
Graphical user interface (GUI)A method of human-computer interaction characterized by a graphical display, a mouse to move a pointer around the screen, and the ability to perform actions by pointing at objects on the screen and clicking a mouse button.
grepThe grep command searches for files that contain a specified string and returns the name of the file and (if it's a text file) a line of context for that string.
GUISee graphical user interface (GUI).
Here documentA form of redirection, denoted by <<, which takes the following lines of input to be passed to a program as standard input. Most often used to pass fixed input to a program as standard input in scripts, obviating the need for separate support files.
kshThe Korn Shell (ksh) was designed to take the best features of the Bourne shell and the C shell and extend them. It has a small but dedicated following among Linux users.
PipeA method of executing two programs so that one program's output serves as the second program's input. Piped programs are separated in a Linux shell by a vertical bar (|).
PipelineSee pipe.
RedirectionA procedure in which a program's standard output is sent to a file rather than to the screen or in which the program's standard input is obtained from a file rather than from the keyboard. See also standard input and standard output.
Regular expressionA method of matching textual information that may vary in important ways but that contains commonalities. The regular expression captures the commonalities and uses various types of wildcards to match variable information.
sedThe sed command directly modifies the contents of files, sending the changed file to standard output.
Shell historyA log of commands typed at a shell. The shell history enables easy repetition of a previously typed command.
SplitThe split command can split a file into two or more files. Unlike most of the text-manipulation commands described in this Lesson, this command requires you to enter an output filename-or more precisely, an output filename prefix, to which is added an alphabetic code.
Standard errorAn output stream that's reserved for high-priority messages, such as errors. See also standard output.
Standard inputThe default method of delivering input to a program. It normally corresponds to the keyboard at which you type.
Standard outputThe default method of delivering purely text-based information from a program to the user. It normally corresponds to a text-mode screen, xterm window, or the like. See also standard error.
StreamText or other input or output as processed by a program. Examples include files, keyboard input, and output to a screen.
tcshThis shell is based on the earlier C shell (csh). It's a fairly popular shell in some circles, but no major Linux distributions make it the default shell. Although it's similar to bash in many respects, some operational details differ. For instance, you don't assign environment variables in the same way in tcsh as in bash.
zshThe Z shell (zsh) takes shell evolution further than the Korn Shell, incorporating features from earlier shells and adding still more.
memorize