Linux command line

Sefism.

A to Z

Glossary

Every concept in this sheet, plus the smaller terms it uses. Select a concept to open its card.

A
Absolute and relative paths
An absolute path starts at /, such as /var/log/syslog.
awk
awk splits each line into fields ($1, $2, $NF for the last) and runs a small program per line, with patterns, variables and sums.
C
Creating, copying, moving and deleting
mkdir -p creates directories including parents, touch creates an empty file, cp -r copies, mv moves or renames, and rm deletes (-r for directories).
D
diff and comparing files
diff -u shows line differences between two files in unified format.
F
Filesystem layout
Everything hangs off /.
find
find walks a directory tree and matches files by name, type, size, age or owner, then prints them or runs an action on each.
G
Getting help
man cmd opens the manual page, cmd --help prints a short usage summary, and type cmd tells you whether a name is a program, a shell builtin or an alias.
Globs and hidden files
The shell expands globs before running a command: * matches any characters, ? one character, [abc] a set, and {a,b} expands to both words.
grep
grep prints lines matching a pattern.
H
Hard and symbolic links
A symbolic link is a small file pointing to a path.
M
Moving around and listing
pwd prints where you are, cd changes directory (cd - goes back, cd alone goes home), and ls lists contents with options for details, hidden files and sorting.
S
sed
sed edits text as it streams past, most often substituting with s/old/new/g.
sort, uniq, cut and wc
sort orders lines (-n numeric, -r reverse, -k by column), uniq collapses adjacent duplicates (-c counts them), cut extracts fields by delimiter, and wc -l counts lines.
V
Viewing files
cat prints a file, less pages through it (search with /, quit with q), head and tail show the first or last lines, and tail -f follows a file as it grows.
X
xargs
xargs reads items from standard input and passes them as arguments to a command, in batches.
10 · Glossary, A to Z10 / 10