Glossary

Commands

9 of 15 commands

C top

chmod Linux
$ chmod 644 file
$ chmod g+r file

Change a file’s permission bits.

Two notations, and both are worth knowing. Symbolic (g+r) changes only what you name and leaves the rest alone. Numeric (644) sets all nine bits at once. Reach for symbolic when adjusting one thing, numeric when you want a known end state.

$ chmod 600 ~/.ssh/id_ed25519

Careful: Removing your own read or execute bit is easy and immediately confusing. Numeric notation overwrites every bit, not just the one you were thinking about.

F top

free Linux
$ free -h

Show physical memory and swap use.

Reads its numbers from /proc/meminfo. The available column is the one to look at — Linux deliberately uses spare memory for cache, so a small free figure is normal rather than a problem.

G top

grep Linux
$ grep -r pattern path

Find lines matching a pattern.

Most often the middle of a pipeline rather than a command on its own. -r recurses, -n gives line numbers, -i ignores case, and -v inverts the match.

$ ps -ef | grep sshd

L top

ln Linux
$ ln -s target linkname

Create a link to a file or directory.

With -s it makes a symbolic link. The argument order is the thing that catches people: the target that already exists comes first, the name being created second.

ls Linux
$ ls -l
$ ls -la

List directory contents.

-l is the form worth reading closely: ten characters of mode, then links, owner, group, size, time, and name. -a includes dot files, which is most of a home directory.

$ ls -ld /bin

M top

man Linux
$ man 5 passwd
$ man -k "disk space"

Read the manual page for a command, file format, or system call.

Sections matter — the same name can appear in several. Section 1 is user commands, 5 is file formats, 8 is administration. man -k searches the descriptions when you do not know the name. Press / to search within a page.

P top

ps Linux
$ ps -ef
$ ps -ef --forest

List running processes.

--forest draws the parent/child tree, which makes the result of fork() visible — every process descends from the first one. Usually piped into grep to find a particular service.

$ ps -ef --forest | head -20

T top

tar Linux
$ tar czf archive.tar.gz dir/
$ tar tvf archive.tar.gz

Bundle many files into one archive, optionally compressed.

The flags are positional and old-fashioned: c create, x extract, t list, v verbose, f naming the file, which must come last of the letters. Run tar tvf before extracting so you know whether the archive expands into a directory or scatters files where you stand.

$ zcat archive.tar.gz | tar xvf -

Careful: Ownership is restored by numeric ID and needs root to reproduce. ACLs, extended attributes, and SELinux contexts each need asking for explicitly.

U top

umask Linux
$ umask 022
$ umask 077

Set the permission bits removed from newly created files.

Subtractive, and from different bases: 666 for files and 777 for directories. 022 gives 644 and 755; 077 gives 600 and 700. It applies to the shell that runs it, so persistence means putting it in a startup file.