Lab lesson · free
Learn Linux basics & practise right away
Anyone who wants to master Linux starts at the command line. Instead of memorising theory, you practise directly on a real cloud VM here: you type the commands, see the result immediately and get automatic feedback on whether it's right. This page explains the building blocks that recur in almost every task – and the error messages you will meet first.
Navigate the file system
pwd shows where you are, ls lists a directory's contents, and cd changes folders. These three commands are the foundation – almost every task starts with orienting yourself in the system. Linux has no drive letters: everything hangs off a single root directory /, and your personal area sits under /home/<name>, abbreviated as ~.
Absolute and relative paths
A path starting with / is absolute and means the same from anywhere – /etc/ssh/sshd_config is always the same file. Everything else is relative to the current directory. .. means one level up, . means „here“. The most common beginner mistake is a relative path inside a script that is later started from a different directory: it worked while testing and fails in operation.
Create files and directories
Use mkdir for folders, touch for empty files, cp and mv to copy and move, rm to delete. On a real VM you also learn the consequences – nothing is more dangerous and instructive than a real terminal. rm does not ask and has no recycle bin; rm -i asks before every file.
Look inside files
cat prints a whole file, less pages through it (quit with q), head and tail show the beginning and the end. tail -f attaches to a file and shows new lines as they are written – the standard move when watching log files, and you will need it in every operations task.
Install packages
You install software through the package manager – apt on Ubuntu. apt update fetches the package lists, apt install installs. Both need administrator rights, so sudo. Understanding how packages, updates and dependencies fit together is the basis for everything else – from web server to hardening.
Redirect and chain
> writes output into a file, >> appends, and | hands it to the next command. ls -l | grep .log | wc -l counts in one line how many log files sit in the directory. These three characters are why the command line goes so far with so few commands: each tool does one thing and you plug them together.
The shortcuts that make the difference
Tab completes paths and commands – pressed twice it lists all options. The up arrow recalls earlier commands, Ctrl + R searches them. Ctrl + C aborts, Ctrl + D ends input. Mastering these five does not double your speed; it sharply reduces typos in paths – and typos in paths are the most common source of errors early on.
What usually goes wrong at the start
Three patterns recur. First, spaces in filenames without quotes – cd My Folder looks for a directory called „My“. Second, sudo put in front of every command out of habit, so newly created files suddenly belong to root and you cannot edit them later. Third, reaching for chmod 777 when something does not work – that fixes the symptom and opens the file to everyone.
Commands to try
Where am I, and what is here?
$ pwd$ ls -la$ cd /etc && pwd$ cd ~ && pwdls -la also shows hidden entries (leading dot) and the permissions. The && runs the second command only if the first succeeded.
Create, copy, clean up
$ mkdir -p project/logs$ touch project/logs/app.log$ cp project/logs/app.log /tmp/$ rm -i /tmp/app.log-p creates missing intermediate directories and does not complain if the folder already exists – which is why it appears in almost every script.
Follow a log
$ tail -n 20 /var/log/syslog$ tail -f /var/log/syslogThe second line keeps running until you stop it with Ctrl + C. This is exactly how you watch a service while poking at it from a second window.
Search, filter, count
$ grep -rn "error" /var/log/ 2>/dev/null | head$ find /etc -name "*.conf" -type f | wc -l$ ls -lh /var/log | sort -k5 -h | tail -32>/dev/null discards the permission errors for directories you may not read – otherwise the actual hit drowns in noise.
Common error messages
- bash: cd: /etc/nginx: No such file or directory
- Cause: The directory does not exist – usually the package is not installed yet, or there is a typo in the path.
- Fix: Check with
ls /etc | grep -i nginwhether the folder exists at all, and install the package withsudo apt install nginxif needed. - mkdir: cannot create directory ‘/opt/app’: Permission denied
- Cause: A normal user may not write below
/opt. The permission belongs toroot. - Fix: Either use
sudo mkdir /opt/appor create it in your own area under~. Do not change the permissions of/opt– that fixes the symptom and opens a hole. - E: Could not get lock /var/lib/dpkg/lock-frontend. It is held by process 1234
- Cause: A second package operation is already running – often the automatic update shortly after the VM starts.
- Fix: Wait a minute or two and try again. Deleting the lock file is the wrong move: it exists to stop two operations from wrecking the same package database.
- bash: syntax error near unexpected token `newline'
- Cause: Usually an unpaired quote further up: the shell waits for the string to end and only trips at the line break.
- Fix: Abort with
Ctrl + Cand retype the line. A prompt that suddenly shows>is exactly that waiting.
In five steps
- 01Start the VM and check with
pwdwhere you land – that is your home directory. - 02Use
ls -la ~to see what is already there, hidden files included. - 03Create a structure with
mkdir -p practice/logsand enter it withcd practice. - 04Create a file with
touch logs/test.logand inspect its permissions withls -l logs. - 05Follow it with
tail -f logs/test.logand write into it from a second terminal usingecho hello >> logs/test.log.
What you practise
Get in Touch
Have a project?
Let's bring your idea to life together. We're happy to advise you with no obligation.
Get in Touch →