The shell: commands, paths and help
Commands, options, paths and getting help.
The previous lesson showed that the shell is the program that reads what you type. This one covers how to talk to it: how a command line is put together, how to move around the filesystem with absolute and relative paths, and how to get help from the server itself when you do not remember an option. With those three skills you can work out an unfamiliar command instead of memorising it, which is how experienced administrators actually work.
A command, its options and its arguments
When the prompt appears, you type a command line and press Enter. The first word is the command, the program to run. Words that start with a dash are options, which change how the command behaves. The remaining words are arguments, usually the files or directories to act on. Here the same command gets the same argument, once without and once with an option.
Without options, ls just confirms the name. The -l option asks for the long format: the file type and permissions, the number of links, the owner and group, the size in bytes, the time of the last change and the name. The lesson on permissions reads those columns one by one; for now it is enough to know where the size and the owner are.
Most options have two spellings: a short form, one dash and one letter, and a long form, two dashes and a word. Short options can be combined, so ls -la is the same as ls -l -a. Some options take a value, written after the short form or after an equals sign in the long form. Both of these print the first two lines of a file:
Scripts often use the long forms because they explain themselves; at the prompt the short forms save typing. A mistyped option makes the command stop before it does anything:
The message names the option it did not understand and suggests a real one. A long option may be shortened as long as the short form still fits only one option, so --almost-a works for --almost-all. --al fits both --all and --almost-all, and the tool refuses rather than guess. That wording comes from the Rust ls on Ubuntu 26.04; the GNU version (on RHEL, and as gnuls on Ubuntu) says the same thing differently:
Two rules catch newcomers. Everything is case-sensitive: ls is a command, LS is not, and /var/log and /Var/log are different paths. Spaces separate the words of a command line, so a file name that contains a space must be quoted, or the command receives two arguments; the lesson on quoting and wildcards covers the details.
Where you are: absolute and relative paths
Every file has a path: the directories you pass through to reach it, separated by /. The tree starts at / itself, the root directory. Your shell also has a current directory (the working directory) at every moment, and pwd prints it. Right after you log in, it is your home directory.
An absolute path starts with / and means the same thing wherever you are. cd (change directory) moves you. Each terminal below starts a fresh shell in the home directory, so commands that belong together are shown together, one per line, as you would type them.
A relative path does not start with /; the shell reads it from the current directory. Two names are special in every directory: . is the directory itself and .. is its parent, one level up. The tilde ~ stands for your home directory, and cd with no argument goes straight there. cd - returns to the directory you were in before and prints its name.
The most common path mistake is a missing leading slash. From the home directory, var/log means /home/deploy/var/log, which does not exist:
The error repeats the path exactly as you typed it, and that is the clue: it says var/log, not /var/log. With the slash the path works from anywhere. The -d option makes ls describe the directory itself instead of listing what is inside it.
Hidden files and your home directory
A name that starts with a dot is hidden: plain ls skips it and -a (all) shows it. Programs use this for their settings files, so they do not clutter a listing. Look at your own home directory with both options together.
The first line, total, is the disk space the listed files use, counted in blocks of 1 KiB. . is the home directory itself and .. is /home. .profile is read when you log in and .bashrc by interactive shells, and both were copied from /etc/skel when the account was created; the lesson on environment variables explains what goes in each. More dotfiles appear as you work, such as .bash_history for the commands you typed and .ssh once you use SSH keys.
The line for . shows the home directory as drwxr-x---: only you and your own group can look inside it, and other ordinary users cannot. RHEL 10 closes it to the group as well (drwx------). The permissions lesson explains how to read these letters, and the accounts lesson where the setting comes from.
Help that is already on the server
Nobody remembers every option. Three sources of help are installed on the server and work without internet access, and they describe the exact version you are running, which a web search may not. The quickest is --help, which almost every command accepts.
In the usage line, square brackets mark something optional and ... means it may be repeated, so ls [OPTION]... [FILE]... takes any number of options and any number of files, including none. For more detail, the manual page:
At a terminal, man shows the page in a pager: Space and the arrow keys move through it, / followed by a word searches forward, n jumps to the next match and q quits. LS(1) means section 1 of the manual, commands for users. The Rust ls has its own, shorter page; man gnuls opens the GNU one, which also documents details such as exit statuses.
The section matters when a name means two things. man -f lists every page with that name:
Section 1 has the passwd command that changes a password, section 5 describes file formats such as /etc/passwd, and section 8 holds administration commands. Plain man passwd opens the first match in the search order, the command, so ask for man 5 passwd when you want the file. When you do not know the name at all, apropos searches the one-line descriptions of every page:
One gap surprises everyone once. cd has no manual page, because it is not a program on disk: it is built into bash, and so are a few dozen other commands such as export, alias and help itself. For those, help prints bash's own text.
Let the shell do the typing
The last habits cannot be shown in a transcript because they happen as you type. Press Tab after the first few letters of a command, file or directory and bash completes it when there is only one match; press Tab twice to list the matches when there are several. When Tab does nothing, there is no match, which often means the path you are typing is wrong. On Ubuntu the bash-completion package also completes many commands' options and arguments.
The Up and Down arrows step through the commands you typed before, and Ctrl-R searches them; the lesson on quoting, wildcards and history goes further. Ctrl-C abandons the line you are typing or stops the program running in the foreground. Ctrl-D on an empty line ends the shell, which logs you out of an SSH session.
Try this
From your home directory, reach /var/log using only a relative path (cd ../../var/log), check with pwd, and come back with cd -. Then find the manual for the SSH server's configuration file: man -f sshd_config shows that it lives in section 5, so open it with man 5 sshd_config, press /, type PasswordAuthentication and press Enter to jump to that setting. Finally, use apropos to find the command that lists block devices, and read its --help.
Takeaway
Read any command line as command, options and arguments, and check paths for the leading slash first. When you are unsure of an option, ask the server (--help, man, help for builtins) before the internet: the local page describes the version you are running.