You log in to a production server for the first time. A production server is a computer that runs an app for real users. You open it from far away over SSH. All you get is one line of text and a blinking cursor. There is no mouse and there are no windows. The only way in is the command line (also called the terminal): you type a command, and the server answers in text.
Every line you type has three parts. Compare it with an order at a coffee stall: "iced coffee with milk, no sugar, for table five".
- "Iced coffee with milk" (the menu item) is the command: the program that runs.
- "No sugar" (how to make it) is a flag: an option for how the program runs, starting with
-. - "Table five" (where it goes) is an argument: what the program works on, which is a file, a folder or the text to search for.
Through the whole DevOps track we manage one app: notes-api, the notes API from the Node.js track. It runs on one Ubuntu server (Ubuntu is a kind of Linux) named web-1, with the IP address 203.0.113.10. Its code is in the folder /srv/notes-api. The next lessons give the app the right file permissions, systemd, a deploy script, then Docker, CI/CD and monitoring. All of these are explained later.
One command, three parts
The shell is the program that reads what you type on the command line and runs it. The shell cuts the line you type at every space. The first word becomes the command, a word starting with - (or --) becomes a flag, and the rest become arguments (args):
| Command line | command | flags | args |
|---|---|---|---|
ls -la /srv/notes-api |
ls |
-la |
/srv/notes-api |
grep -r EACCES storage/logs/ |
grep |
-r |
EACCES, storage/logs/ |
mkdir -p storage/attachments/2026/10 |
mkdir |
-p |
storage/attachments/2026/10 |
cat config.js |
cat |
(empty) | config.js |
- In the
grepline, the command isgrep, the flag is-r, and there are two arguments: the text to look for (EACCES) and the folder to look in (storage/logs/). - One-letter flags can be combined:
-lais the same as-l -a. The long form of a flag takes two dashes:mkdir --parentsis the same asmkdir -p. - Some flags carry a value: in
tail -n 20 app.log, the20belongs to-n; it is not a file name.
Into web-1: who you are, where you are
This morning a report arrived: attachment uploads on notes-api keep failing. You log in to the server over SSH (the SSH & Remote lesson of the Terminal track shows how), then check who and where you are. In this example, the text up to the $ sign is the prompt (it shows the shell is waiting for a command). What you type comes after the $ sign, and the other lines are the server's answers:
$ ssh [email protected]
deploy@web-1:~$ whoami
deploy
deploy@web-1:~$ pwd
/home/deploy
deploy@web-1:~$ cd /srv/notes-api
deploy@web-1:/srv/notes-api$ ls -la
total 56
drwxr-xr-x 7 deploy deploy 4096 Oct 8 17:40 .
drwxr-xr-x 3 root root 4096 Sep 30 10:02 ..
-rw-r--r-- 1 deploy deploy 36 Sep 30 10:05 .env.example
drwxr-xr-x 8 deploy deploy 4096 Oct 8 17:35 .git
-rw-r--r-- 1 deploy deploy 28 Sep 30 10:05 .gitignore
-rw-r--r-- 1 deploy deploy 299 Oct 8 17:35 app.js
-rw-r--r-- 1 deploy deploy 402 Oct 8 17:35 config.js
-rw-r--r-- 1 deploy deploy 291 Oct 8 17:35 deploy.sh
-rw-r--r-- 1 deploy deploy 136 Oct 2 14:12 migrate.js
drwxr-xr-x 2 deploy deploy 4096 Oct 8 17:35 migrations
drwxr-xr-x 6 deploy deploy 4096 Oct 8 17:36 node_modules
-rw-r--r-- 1 deploy deploy 194 Oct 8 17:35 package.json
drwxr-xr-x 2 deploy deploy 4096 Oct 8 17:35 routes
drwxr-xr-x 4 deploy deploy 4096 Oct 8 17:40 storage
whoamiprints the name of the user (account) you are using.pwd(print working directory) prints the folder you are in now. On a server, run these two commands before any other.cd /srv/notes-apimoves you to the app's folder. The prompt changes with it:deploy@web-1:/srv/notes-api$means userdeploy, serverweb-1, folder/srv/notes-api. Before that, the folder was~, short for/home/deploy.ls -lalists what is in the folder.-ladds the permissions, owner, size and time of each item.-aalso shows names starting with a dot, such as.env.exampleand.git. The basics ofpwd,cdandlsare in the Navigating the File System lesson.
Health check: disk and logs
When an app has a problem, check two things first: whether the disk (the server's storage) is full, and what the log says (the file where the app records what happens).
deploy@web-1:/srv/notes-api$ df -h /
Filesystem Size Used Avail Use% Mounted on
/dev/vda1 25G 9.0G 15G 39% /
deploy@web-1:/srv/notes-api$ tail -n 3 storage/logs/app.log
2026-10-09 08:10:56 ERROR EACCES: permission denied, open '/srv/notes-api/storage/attachments/c90e7a51.jpg'
2026-10-09 08:10:56 INFO POST /notes/3/attachments 500 9ms
2026-10-09 08:12:30 INFO GET /notes 200 11ms
df -h /shows the use of the disk that/(the top folder) is on.-h(human-readable) writes sizes as25Gor9.0Ginstead of block counts. The disk is 39% used, so a full disk is not the problem.tail -n 3prints the last 3 lines of a file. New lines in a log are always added at the bottom, so the newest events are at the end of the file.tail -fkeeps printing new lines as they are added to the file.EACCES: permission deniedmeans the app has no permission, so it was refused when it tried to open a file instorage/attachments.
Search the log for a pattern: grep
Next, grep shows how often that error happened, and ls -l storage shows who owns the folders:
deploy@web-1:/srv/notes-api$ grep -c EACCES storage/logs/app.log
3
deploy@web-1:/srv/notes-api$ grep -r EACCES storage/logs/
storage/logs/app.log:2026-10-09 07:20:11 ERROR EACCES: permission denied, open '/srv/notes-api/storage/attachments/7f3a9c1e.jpg'
storage/logs/app.log:2026-10-09 07:45:03 ERROR EACCES: permission denied, open '/srv/notes-api/storage/attachments/b21d4e08.png'
storage/logs/app.log:2026-10-09 08:10:56 ERROR EACCES: permission denied, open '/srv/notes-api/storage/attachments/c90e7a51.jpg'
deploy@web-1:/srv/notes-api$ ls -l storage
total 8
drwxr-xr-x 2 deploy deploy 4096 Oct 8 17:40 attachments
drwxr-xr-x 2 www-data www-data 4096 Oct 9 00:00 logs
grep pattern fileprints every line of the file that contains the pattern (the text to look for). With-c(count),greponly prints how many lines match. The result is 3: there were 3 failed uploads.- With
-r(recursive),grepreads every file in a folder and its subfolders, and each result line starts with the file's name.app.log.1(yesterday's log) is read too, but it has no EACCES. ls -l storageshows the cause. Theattachmentsfolder belongs to the userdeploy, while thelogsfolder belongs towww-data, the user that runs the app. So the app may write its log, but it may not write attachments. The fix is in the next lesson, File System & Permissions.
Nested folders: mkdir -p
Budi made the attachments folder yesterday with mkdir -p. He was logged in as deploy at the time. A new folder always belongs to the user who made it, and that is where the problem comes from. mkdir makes a folder, and -p (parents) also makes any parent folders that are missing:
deploy@web-1:/srv/notes-api$ mkdir storage/attachments/2026/10
mkdir: cannot create directory 'storage/attachments/2026/10': No such file or directory
deploy@web-1:/srv/notes-api$ mkdir -p storage/attachments/2026/10
deploy@web-1:/srv/notes-api$
Without -p, mkdir only makes the last folder, so its parent folder (2026) must already exist. With -p, mkdir makes 2026 and then 10. If all the folders already exist, mkdir -p prints nothing and gives no error. Creating, copying and deleting files is covered in the Creating & Deleting Files lesson of the Terminal track.
A mini shell: splitting a command with JavaScript
In the exercise you write the function parseCommand(cmd). It copies the shell's first step:
- Split the command text at every space with
split(" "). - The word at index 0 becomes the
command. - The other words starting with
-go intoflags. Check them withstartsWith("-"). - The remaining words go into
args.
So "cat config.json" gives { command: "cat", flags: [], args: ["config.json"] }. That line has no flag, but flags is still there as an empty array; it is not left out.
⚠️ What confuses people on a server terminal
- Running a command without checking where you are.
rm -r logsdeletes thelogsfolder and everything in it. If you run it in the wrong folder, it deletes the wrong folder. Runwhoamiandpwdfirst, and read the prompt. - Forgetting
-rwhen grepping a folder.grep EACCES storage/logs/without-ronly printsgrep: storage/logs/: Is a directory(this is a folder, not a file). - Thinking
tailreads from the top.tailtakes the last lines,headthe first ones. For logs, you almost always needtail. - Reading an error only from the left. The format of an error message is
program: target: reason, for examplecat: storage/logs/app.lg: No such file or directory(catprints a file's contents). The reason is at the far right: there is no file with that name (app.lgis mistyped, the file isapp.log).
TL;DR: On the command line, you type a line and the shell (the program that reads what you type) runs it. A line you type is made of the command (the first word, the program's name), flags (options for how it runs, starting with -; they can be combined, like -la, and have long forms, like --parents) and arguments (the rest: the file, folder or text it works on). On a server (a computer that runs an app): whoami and pwd to know which user you are and which folder you are in, cd to move to another folder, ls -la to see everything in a folder with its owner, and df -h for disk use. tail -n 20 file prints the last 20 lines of a log (the file where an app records events), grep pattern file searches for text (-c counts matching lines, -r goes through a folder), and mkdir -p makes a folder with its parent folders. Read an error from the right: the reason comes last.
⚡ One command, three parts
Write:
grep -r EACCES storage/logs/
Guess first: the first word is the command, and a word starting with - is a flag. The rest are arguments. How many arguments does this line have?
Two: EACCES (the text to look for) and storage/logs/ (the folder to look in). grep is the command, -r the flag.
Meaning: The shell (the program that reads what you type) cuts the line at every space. The first word becomes the command (the program that runs), a word starting with - becomes a flag (an option for how it runs), and the rest become arguments (what it works on).
⚡ Who you are, where you are
Write:
deploy@web-1:~$ whoami
deploy
deploy@web-1:~$ pwd
/home/deploy
Meaning: The text up to the $ sign is the prompt: a sign that the server (the computer the app runs on) is waiting for a command. whoami prints the user (account) you are using, here deploy. pwd prints the folder you are in, here /home/deploy. On a server, run these two commands before any other.
⚡ Read the end of the log, then search it
Write:
deploy@web-1:/srv/notes-api$ tail -n 3 storage/logs/app.log
deploy@web-1:/srv/notes-api$ grep -c EACCES storage/logs/app.log
3
Meaning: A log is a file where an app records what happens, and new lines are always added at the bottom. That is why tail -n 3 (the 3 belongs to the flag -n) takes the last 3 lines: the newest events. grep -c looks for the text EACCES (the error code for permission denied) in that file, and only prints how many lines match: 3.
⚡ Nested folders in one step
Write:
deploy@web-1:/srv/notes-api$ mkdir -p storage/attachments/2026/10
Guess first: mkdir makes a folder. You run it without -p, and the 2026 folder doesn't exist yet. What does mkdir answer?
The error No such file or directory. Without -p, mkdir only makes the last folder, so its parent folder must already exist.
Meaning: With -p (parents), mkdir also makes any parent folders that are missing. If all the folders already exist, mkdir -p prints nothing and gives no error.