Most of the time you spend on a server is not spent changing things. It is spent finding things: which directory am I in, what is in it, which log changed last, which binary is actually running, what does this flag do. Engineers who look fast on a terminal are rarely typing fast; they are using completion, history and a dozen shortcuts so that they hardly type at all.
In this lesson you learn to read the prompt, move with cd, list with ls, let the shell finish your commands, recall old ones, and get answers from the system’s own documentation. Everything works in a container or WSL; the examples use the orbit-lab VM from lesson 1.
If you skipped ahead: create the Orbit directories from lesson 2 so the examples work: sudo mkdir -p /srv/orbit/{api,public,releases} /etc/orbit /var/lib/orbit /var/log/orbit
Reading the prompt
The prompt is the shell telling you it is ready, and on Ubuntu it is packed with information:
ubuntu@orbit-lab:~$ user ubuntu, host orbit-lab, home directory
ubuntu@orbit-lab:/var/log$ same user, now in /var/log
root@orbit-lab:/etc# the root user: the # is a warning sign
Before you press Enter on anything destructive, read the prompt: the host tells you which server you are on (production or lab?), and the path tells you where relative paths will land. The prompt is defined by the PS1 variable, which lesson 14 (environment variables) shows how to customise.
Where am I: pwd
pwd (print working directory) shows your current location as an absolute path:
$ pwd
/home/ubuntu
$ cd /bin
$ pwd
/bin
$ pwd -P
/usr/bin
Plain pwd shows the path you took. pwd -P resolves symbolic links and shows the physical directory, which matters when a path like /srv/orbit/current is a link to a release (lesson 4).
Moving around: cd
cd changes the current directory. It accepts two kinds of path:
- An absolute path starts with
/and works from anywhere:cd /var/log/orbit. - A relative path starts from where you are: from
/srv/orbit,cd publictakes you to/srv/orbit/public.
A few shortcuts cover nearly every move:
| Command | Goes to |
|---|---|
cd or cd ~ | Your home directory |
cd ~maya | Maya’s home directory (if that user exists) |
cd .. | The parent directory |
cd ../.. | Two levels up |
cd - | The previous directory (and prints it) |
cd - is the one people discover late and then use all day. It toggles between two places, such as a config directory and a log directory:
$ cd /etc/orbit
$ cd /var/log/orbit
$ cd -
/etc/orbit
$ cd -
/var/log/orbit
Listing files: ls
ls lists the current directory, or any path you give it. Its flags combine freely, so ls -lah is the same as ls -l -a -h.
| Flag | Effect |
|---|---|
-l | Long format: type, permissions, links, owner, group, size, date, name |
-a | Include hidden entries (names starting with .), including . and .. |
-A | Like -a without . and .. |
-h | Human-readable sizes (4.0K, 12M) together with -l |
-t | Sort by modification time, newest first |
-r | Reverse the sort order |
-S | Sort by size, largest first |
-d | Show a directory itself, not its contents |
-F | Add a marker: / for directories, @ for links, * for executables |
--color=auto | Colour by type when output goes to a terminal |
Some combinations worth keeping in your fingers:
$ ls -lhtr /var/log | tail -4
-rw-r----- 1 syslog adm 18K Nov 3 09:12 auth.log
-rw-r--r-- 1 root root 2.1K Nov 3 09:30 cloud-init-output.log
drwxr-sr-x+ 3 root systemd-journal 4.0K Nov 3 09:31 journal
-rw-r----- 1 syslog adm 96K Nov 3 09:44 syslog
$ ls -ld /etc/orbit
drwxr-xr-x 2 root root 4096 Nov 3 09:50 /etc/orbit
ls -lhtr sorts oldest first so the most recently changed file ends up right above your prompt: perfect when you want to know which log is being written now. ls -ld answers “who owns this directory?” without flooding the screen with its contents. (The | tail and | head parts keep only the last or first lines; lesson 5 explains pipes.)
On Ubuntu, ll is a ready-made alias for ls -alF, and plain ls is already an alias for ls --color=auto. The colours follow the file type: blue for directories, cyan for links, green for executables.
Seeing the shape with tree
ls -R gets noisy fast. tree draws a directory as a tree; install it with sudo apt install tree.
$ tree -L 2 /srv/orbit
/srv/orbit
├── api
├── public
└── releases
4 directories, 0 files
-L 2 limits the depth, -d shows directories only and -a includes hidden files.
Let the shell type for you
Tab completion
Press Tab while typing a command, path or option and bash completes it as far as it is unambiguous. Press Tab twice to list the candidates:
$ ls /etc/sys<Tab><Tab>
sysctl.conf sysctl.d/ systemd/
Completion is more than a speed trick. If Tab does not complete a path, the path does not exist (or you lack permission), and you find out before running the command. On Ubuntu, the bash-completion package also completes options and arguments, such as systemctl restart orb<Tab> or git checkout ma<Tab>.
Command history
bash remembers what you typed in ~/.bash_history. The Up and Down arrows walk through it, and there is more:
| Keys or command | What it does |
|---|---|
history | Lists past commands with numbers |
!! | Repeats the last command; sudo !! reruns it with sudo |
!$ | The last argument of the previous command |
!123 | Runs command number 123 from history |
| Ctrl+R | Searches backwards as you type; press Ctrl+R again for older matches |
$ cat /etc/orbit/orbit.env
cat: /etc/orbit/orbit.env: Permission denied
$ sudo !!
sudo cat /etc/orbit/orbit.env
Ctrl+R is the real time saver. Press it, type a fragment such as journal, and the shell shows the most recent matching command; Enter runs it, the Right arrow lets you edit it first, Ctrl+G cancels.
Warning: History is stored in plain text. If you ever type a password or token on the command line, it lands in ~/.bash_history. Ubuntu sets HISTCONTROL=ignoreboth, so a command that starts with a space is not saved, but the better habit is to never put secrets in commands.
Editing shortcuts
These work in bash and in most programs that read a line of input:
| Shortcut | Action |
|---|---|
| Ctrl+A | Jump to the start of the line |
| Ctrl+E | Jump to the end of the line |
| Ctrl+U | Delete from the cursor to the start of the line |
| Ctrl+K | Delete from the cursor to the end of the line |
| Ctrl+W | Delete the word before the cursor |
| Ctrl+L | Clear the screen (like clear) |
| Ctrl+C | Abandon the current line or stop the running command |
| Ctrl+D | Exit the shell (on an empty line) |
Getting help without a browser
man pages
man opens the manual page of a command. Pages are split into sections, and the same name can exist in several:
$ man 5 passwd
$ man -k "disk space"
df (1) - report file system space usage
man passwd documents the command that changes passwords (section 1); man 5 passwd documents the format of the /etc/passwd file. Section 8 holds admin commands. Inside a man page, /word searches, n jumps to the next match, g and G go to the top and bottom, and q quits. man -k (also called apropos) searches the one-line descriptions of all pages, which is how you find a command when you only know what it should do.
Minimal images, including the Ubuntu container image, strip out man pages to save space. Running unminimize (from the unminimize package on recent releases) puts them back.
Faster help
ls --helpprints a compact summary of options. Nearly every program supports--helpor-h.help cddocuments shell builtins: commands likecd,pwdandhistorythat are part of bash itself and have no separate man page.tldr tarshows a handful of practical examples. Install a client withsudo apt install tldr(or the fastertealdeer), runtldr --updateonce, and keep man pages for the details.
What exactly runs when I type this?
When a command behaves strangely, check what the name really is:
$ type cd
cd is a shell builtin
$ type ll
ll is aliased to `ls -alF'
$ type -a python3
python3 is /usr/bin/python3
python3 is /bin/python3
type knows about aliases, builtins, functions and files, so it is the authoritative answer. which python3 only searches the directories in $PATH for a file, and whereis python3 also lists related man pages and source locations. (Both /usr/bin and /bin appear above because of the merged /usr from lesson 2.) In scripts, use command -v python3 to test whether a command exists.
Inspecting a file: file and stat
Linux does not rely on file extensions. file looks at the content and tells you what something really is:
$ file /etc/hostname /bin /usr/bin/bash /srv/orbit/releases/upload-0311
/etc/hostname: ASCII text
/bin: symbolic link to usr/bin
/usr/bin/bash: ELF 64-bit LSB pie executable, x86-64, dynamically linked, ...
/srv/orbit/releases/upload-0311: gzip compressed data, from Unix
That last line is the kind of thing file is for: a build upload with no extension turns out to be a compressed archive. stat shows everything the filesystem knows about a file:
$ stat /etc/hostname
File: /etc/hostname
Size: 10 Blocks: 8 IO Block: 4096 regular file
Device: 8,1 Inode: 1310742 Links: 1
Access: (0644/-rw-r--r--) Uid: ( 0/ root) Gid: ( 0/ root)
Access: 2026-11-03 09:30:12.401837112 +0000
Modify: 2026-10-28 09:05:44.118203915 +0000
Change: 2026-10-28 09:05:44.118203915 +0000
Birth: 2026-10-28 09:05:44.114203904 +0000
Modify is when the content last changed, Change when the metadata (owner, permissions) last changed, and Access when it was last read (often updated lazily). The Inode number becomes important in lesson 4.
Globbing: listing many files at once
The shell expands wildcards before the command runs, so ls receives a list of real names:
| Pattern | Matches | Example |
|---|---|---|
* | Any number of characters, including none | ls /etc/*.conf |
? | Exactly one character | ls /var/log/syslog.? |
[abc] | One character from the set | ls -d /etc/[xyz]* |
$ echo /etc/host*
/etc/host.conf /etc/hostname /etc/hosts
$ ls /var/log/orbit/*.log
ls: cannot access '/var/log/orbit/*.log': No such file or directory
echo proves the shell does the work. When nothing matches, bash passes the pattern through unchanged, which is why the error shows a literal *.log. Two more rules: * does not match hidden files, and quotes switch expansion off (ls '*.log' looks for a file literally named *.log). Lesson 4 uses the same patterns to copy and delete.
Red Hat and Alpine
On Rocky Linux and RHEL everything here is the same, except that ll is defined as ls -l --color=auto and minimal installs may need sudo dnf install man-pages man-db tree. Alpine’s default shell is BusyBox ash: cd, ls and globbing work, but bash extras such as !! history tricks and rich completion arrive only after apk add bash bash-completion, and man pages need apk add mandoc plus each package’s -doc package.
Practice lab
Leo hands you the lab machine and asks you to get your bearings in Orbit’s layout without opening a file manager.
- Go to
/var/log/orbitwith an absolute path, then to/srv/orbit/publicwith a path relative to/srv/orbit, then jump back to the log directory with one short command. - List
/etcso the five most recently modified entries are visible right above your prompt, with human-readable sizes. - Find out whether
cd,lsandtreeare builtins, aliases or files, and where thetreebinary lives. - Find the manual page that describes the format of
/etc/hosts, look up what the-Sflag oflsdoes without opening a man page, then rerun the command from task 2 with Ctrl+R.
Show a solution
cd /var/log/orbit, then cd /srv/orbit followed by cd public (or cd ../../../srv/orbit/public in one go), and cd - jumps back to the log directory. ls -lhtr /etc | tail -5 puts the five newest entries at the bottom. type cd ls tree reports a builtin, an alias and a file; which tree prints /usr/bin/tree. man 5 hosts documents the file format (man -k hosts finds it if you do not know the section), ls --help shows that -S sorts by size, and Ctrl+R followed by lhtr and Enter reruns the listing.
Exercise
Maya runs ls -l in /srv/orbit/api and sees only two files, but git complains the directory is already a repository. What should she run to find out why?
Show answer
Answer: B. Names starting with a dot are not shown by ls unless you add -a (or -A). The hidden .git directory is what makes the folder a repository.
Exercise
On orbit-web-01, the command python3 –version prints an unexpected version, although /usr/bin/python3 is the right one. Which command reliably shows what the shell actually runs?
Show answer
Answer: C. type reports aliases, functions and builtins as well as files, in the order the shell uses them. which only searches $PATH and misses aliases and functions defined in the shell.
Exercise
Leo wants to know which file in /var/log is being written to right now and wants the answer next to his prompt. Which command fits best?
Show answer
Answer: C. -t sorts by modification time and -r reverses it, so the most recently written file appears last, right above the prompt. -S sorts by size, and -d shows the directory itself.
Key takeaways
- Read the prompt before every risky command: it tells you the user, the host and the current directory.
cd -,cd ..andcd ~cover most moves; scripts should always use absolute paths.ls -lah,ls -lhtrandls -ldanswer most “what is here?” questions.- Tab completion, Ctrl+R and the Ctrl+A/E/U/W shortcuts save more time than typing faster ever will.
- Get help locally with
--help,man,man -k,helpandtldr; check what a name really is withtype.
FAQ
What is the difference between an absolute and a relative path?
An absolute path starts with / and describes the location from the root of the tree, so it means the same thing wherever you are, for example /var/log/orbit. A relative path starts from the current directory, such as logs/api.log or ../public. Use relative paths to save typing at the prompt and absolute paths in scripts, cron jobs and systemd units.
What do the columns in ls -l mean?
From left to right: the file type and permissions (-rw-r--r--), the number of hard links, the owner, the group, the size in bytes (or human-readable with -h), the last modification time and the name. Symbolic links also show -> and their target. Lesson 6 explains the permission letters in detail.
Why do I get “command not found” for a program I just installed?
Either the program is not installed where you think, or its directory is not in your $PATH. Check with echo $PATH and look for the binary with ls in the install location (often /usr/local/bin or /opt/<name>/bin). If you just installed it in the current session, hash -r clears bash’s cache of command locations.
How do I search inside a man page?
Man pages open in the pager less, so type / followed by a word and press Enter, then n for the next match and N for the previous one. q quits. To search across all man pages by description, use man -k keyword or apropos keyword.
Can I go back to a directory from three moves ago?
cd - only remembers the last directory. For more, use pushd /path instead of cd: it keeps a stack you can see with dirs -v, and popd returns to the previous entry. Many people simply use Ctrl+R to find the old cd command in their history.