Linux for Cybersecurity Beginners: Filesystem, Commands, Permissions and Logs
Plain-English notes on the Linux skills security analysts use every day: finding your way around the filesystem, essential commands, getting help from inside Linux, chmod with worked examples, users and groups, and reading authentication logs with grep. Includes a guide to free online Linux practice environments, then ends with 19 hands-on practice tasks and solutions, plus a glossary of key terms.
Independent study aid. Not affiliated with or endorsed by Google or Coursera. All explanations, examples and practice tasks are original. Confirm current course content on the official Coursera page.
1. Why security work depends on Linux
Most servers, cloud workloads, network appliances and security tools run Linux. As an analyst you will read logs, check who has access to what, search for suspicious activity and run tools from a terminal. Knowing a small set of commands well beats knowing many commands badly.
Where to practise
Use a virtual machine, not your main computer. See the home lab setup guide, or jump to the free online practice environments if you would rather not install anything.
Core idea
Everything is a file, every file has an owner and permissions, and every action leaves a trail in the logs.
Study tip
Type every command yourself. Reading is not enough; muscle memory is the goal.
Safety: run the practice tasks in a lab VM. Commands that use sudo change the system. Always check a command before pressing Enter, especially anything containing rm.
2. Filesystem layout
Linux has one tree that starts at / (called “root”, not to be confused with the root user). Directories follow a common convention described in the Filesystem Hierarchy Standard (FHS), though distributions vary slightly. The FHS is the part of Linux that defines how directories and their contents are organised, and a file’s location is described by its file path, with each level of the hierarchy separated by a forward slash.
| Path | What lives there | Why a security analyst cares |
|---|---|---|
/ | Top of the tree | Everything is below this point |
/home | Personal folders for each user | User files, shell history, hidden config files |
/root | Home folder of the root user | Should be tightly protected |
/etc | System configuration files | Accounts, services, SSH settings, scheduled jobs. Attackers like to change these. |
/var/log | Log files | Main place to investigate activity |
/tmp | Temporary files, writable by everyone | Common place for malware to drop files |
/bin, /usr/bin | Programs and commands (“binaries”) | Altered binaries can signal compromise |
/sbin, /usr/sbin | Administration programs | Tools usually run with elevated rights |
/opt | Optional or third-party software | Where tools such as Splunk are often installed |
/dev | Device files | Disks, terminals and other hardware appear as files |
/proc | Live view of running processes and kernel data | Inspect processes without extra tools |
/boot | Files needed to start the system | Changes here deserve attention |
/mnt, /media | Mount points for extra drives (“mount”: USB and hard drives) | External drives and network shares |
Pro tip: run man hier in your lab VM to read a description of the filesystem hierarchy and its standard directories straight from the manual.
Absolute vs relative paths: an absolute path is the full path and starts at / (for example /etc/passwd). A relative path starts from the directory you are in now (for example notes/day1.txt). The shortcuts ~ (your home), . (here) and .. (one level up, the parent directory) save typing. For example, if your username is analyst, then /home/analyst/logs and ~/logs are the same place, and from inside ~/projects the relative path ../logs reaches it.
3. Essential commands
A command usually has three parts: the command name, optional options that change how it behaves (they normally begin with a hyphen, like -l), and arguments, which are the things it works on (like a file name).
Moving around and looking
| Command | Does | Example |
|---|---|---|
pwd | Prints your current (working) directory as an absolute path | pwd |
ls | Lists files. -l long, -a hidden, -h readable sizes. Add a path to list another directory without moving there. | ls -lahls /var/log |
cd | Changes directory. cd .. goes up one level; plain cd returns home. | cd /var/log |
cat | Prints a whole file | cat /etc/hostname |
less | Shows a file one page at a time (keys below) | less /var/log/syslog |
head / tail | First or last lines (10 by default). -n sets the number. tail -f follows new lines live. tail is ideal for the newest log entries. | tail -n 20 file.log |
file | Identifies what type a file really is | file download.bin |
whoami | Shows your current username | whoami |
Moving around inside less:
| Key | Action |
|---|---|
| Space bar | Forward one page |
b | Back one page |
| Down / Up arrow | Forward / back one line |
/word | Search for a word (n jumps to the next match) |
q | Quit and return to the terminal |
Creating, copying, moving and deleting
| Command | Does | Example |
|---|---|---|
mkdir | Makes a directory. -p makes parents too | mkdir -p lab/notes |
touch | Creates an empty file or updates its timestamp | touch a.txt |
cp | Copies and keeps the original. -r for directories | cp a.txt b.txt |
mv | Moves (the original disappears) or renames | mv b.txt c.txtmv c.txt ~/lab/notes/ |
rm | Deletes. There is no recycle bin | rm c.txt |
rmdir | Deletes an empty directory only. It refuses if anything is inside. | rmdir notes |
Be careful with rm -r. It deletes a directory and everything inside it with no confirmation. Double-check the path, and never combine it with sudo unless you are certain.
Editing files with nano and writing output with echo
nano is a beginner-friendly command-line text editor that comes with many Linux distributions and is widely used in security work. Vim and Emacs are other popular terminal editors, but nano is the easiest place to start.
nano notes.txt # opens the file, or creates it if it does not exist
| Keys | Action |
|---|---|
Ctrl+O | Save (“write out”). Press Enter to confirm the file name. |
Ctrl+X | Exit nano. It asks whether to save if you have unsaved changes. |
Ctrl+W | Search for text in the file |
nano has no autosave. Save with Ctrl+O before you exit, or your edits are lost.
You can also write to a file without opening an editor. echo prints text, and a redirect operator sends that text into a file instead of the screen:
echo "first note" > notes.txt # > overwrites the file
echo "second note" >> notes.txt # >> adds to the end
Use > carefully, because an overwritten file is very hard to recover. When in doubt, use >>.
Searching and filtering text
Filtering means selecting only the data that matches a condition, such as lines containing a word or files with a certain extension. It is one of the most useful analyst skills.
| Command | Does | Example |
|---|---|---|
grep | Finds lines matching a pattern (pattern first, then file) | grep "error" app.log |
find | Searches for files by name, type, owner, age | find /home -name "*.txt" |
wc -l | Counts lines | wc -l app.log |
sort | Sorts lines | sort names.txt |
uniq -c | Counts repeated adjacent lines (sort first) | sort names.txt | uniq -c |
cut | Extracts columns | cut -d: -f1 /etc/passwd |
awk | Pulls out fields from lines | awk '{print $1}' file |
Going deeper with find
The first argument after find is where to start looking. After that you add criteria. If you give no criteria, find returns everything below the starting point, which is rarely what you want. The asterisk * is a wildcard meaning “zero or more characters”.
| Goal | Command |
|---|---|
| Name contains “log” (case-sensitive) | find /home/analyst -name "*log*" |
| Same, ignoring upper/lower case | find /home/analyst -iname "*log*" |
| Changed in the last 3 days | find /home/analyst -mtime -3 |
| Changed more than 30 days ago | find /home/analyst -mtime +30 |
| Changed in the last 60 minutes | find /home/analyst -mmin -60 |
Regular files in /tmp changed in the last day | find /tmp -type f -mtime -1 |
-name is case-sensitive, so it would miss LOG or Log; -iname catches them. -mtime counts in whole days (-1 means less than one day ago, +1 means more than one day ago), and -mmin does the same in minutes. Searching for recently changed files is a classic way to spot what an intruder touched.
Standard input, standard output, pipes and redirects
- Standard output (stdout) is the information a command returns through the shell, normally printed on your screen.
- Standard input (stdin) is information a command receives, for example typed in or passed from another command.
- Pipe
|: sends the standard output of one command into the standard input of the next. It is on the backslash key on many keyboards. - Redirects:
>writes output to a file (overwriting it) and>>appends.
Chaining small commands is the secret of fast log analysis. For example, list a directory and keep only names containing “ssh”:
ls /etc | grep ssh
cut -d: -f1 /etc/passwd | sort | head -n 5
Processes, system information and privilege
| Command | Does |
|---|---|
whoami | Shows your current username |
id | Shows your user ID and group memberships |
ps aux | Lists running processes |
top | Live view of processes (q to quit) |
uname -a | Shows kernel and system details |
df -h / du -sh | Disk space overall / size of a folder |
ip a | Shows network interfaces and addresses |
sudo | Runs one command with administrator rights |
history | Shows previous commands |
Principle of least privilege: grant only the minimum access needed to do a task. In practice, work as a normal user and use sudo only for the single command that needs it. Staying logged in as root makes mistakes and attacks far more damaging.
4. Getting help inside Linux
You will never remember every command and option, and nobody does. Linux has built-in help, and a large online community, so learning to look things up is part of the job.
man, apropos and whatis
| Command | Use it when | Example |
|---|---|---|
man | You know the command and want full detail and all its options. The output is called a “man page”. Navigate it like less and press q to quit. | man chown |
whatis | You want a one-line reminder of what a command does | whatis nano |
apropos | You do not know the command name. It searches the man page descriptions for your keyword. Add -a to require all of several words. | apropos -a create group |
whatis cat # one-line description
man cat # full manual; look for the option that numbers lines
apropos -a graph editor # find commands whose description has both words
man useradd # look for the option that sets an account expiry date
- Most commands also print a short summary with
command --help(for examplegrep --help). - If
apropossays “nothing appropriate” on a fresh system, the manual index may not be built yet. On Debian-based systems,sudo mandbbuilds it. - There is no right or wrong keyword for
apropos. Treat it as a focused search and try different words if the first attempt does not help.
The Linux community
Most problems you hit have already been solved by someone else. A web search for your error message is often the fastest route. A trusted question-and-answer site is the UNIX & Linux Stack Exchange, where members vote on answers so the best ones rise to the top.
Before you paste anything into a public forum or an AI tool, remove real IP addresses, user names, host names and any other sensitive detail from your logs and commands. Also read any sudo or rm command from an online answer carefully before you run it, because copying one blindly can do real damage.
5. File permissions and chmod
How to read permissions
Permissions define what type of access a user or group has to a file or directory. Run ls -l and you will see lines like this (add -a, as in ls -la, to include hidden files that start with a dot):
-rwxr-xr-- 1 maya analysts 482 Oct 2 09:10 backup.sh
The permission string is 10 characters long: one for the type, then three sets of three.
| Part | Value | Meaning |
|---|---|---|
| First character | - | Type: - file, d directory, l link |
| Next three | rwx | Owner (user) permissions |
| Middle three | r-x | Group permissions |
| Last three | r-- | Everyone else (others) |
| Owner / group | maya analysts | The file’s owning user and group |
| Letter | On a file | On a directory | Number |
|---|---|---|---|
r read | View contents | List names inside | 4 |
w write | Change contents | Create, rename or delete items inside | 2 |
x execute | Run as a program | Enter the directory (cd) | 1 |
Numeric method: add the numbers for each group. rwx = 4+2+1 = 7, r-x = 4+0+1 = 5, r-- = 4, rw- = 6, --- = 0. Three digits give owner, group and others.
Nine worked examples
Example 1: Decode a mode
-rw-r--r-- → owner 6 (rw-), group 4 (r–), others 4 (r–) → 644. A typical setting for a normal document: owner edits, everyone else reads.
Example 2: Make a script runnable
chmod 755 backup.sh
ls -l backup.sh
Result: -rwxr-xr-x. Owner has full control; group and others can read and run it but not change it.
Example 3: Lock down a private file
chmod 600 secret.txt
Result: -rw-------. Only the owner can read or write. Use this pattern for private keys and notes with sensitive data.
Example 4: Symbolic mode, add one permission
chmod u+x run.sh
u = owner, g = group, o = others, a = all. + adds, - removes, = sets exactly. This adds execute for the owner and leaves everything else alone.
Example 5: Remove access for others
chmod go-rwx private.txt
Removes read, write and execute from group and others in one step.
Example 6: Directory permissions
chmod 700 ~/lab-private
Only the owner can list, enter or change the directory. If a directory lacks x for you, you cannot cd into it even if you can see its name.
Example 7: Why 777 is a red flag
chmod 777 gives everyone read, write and execute. Any user or compromised program could change or replace the file. In an audit, world-writable files and directories are worth investigating. Find them in your lab like this:
find ~ -type f -perm -002
The command lists regular files under your home that others can write to.
Example 8: Several changes in one command
chmod u=rwx,g=rx,o= deploy.sh
chmod u+rw,g-w,o-rwx report.txt
Separate the changes for each owner type with a comma and no spaces. A space would make chmod think the next piece is a file name. The first line sets the file to exactly rwxr-x--- (750). Using = overwrites whatever was there before, so any permission you do not list is removed.
Example 9: Least privilege in action
A file payroll-notes.txt belongs to a finance lead, hrlead. Only that person needs it, but a check shows the group can edit it too:
ls -l payroll-notes.txt
-rw-rw---- 1 hrlead finance 2210 Oct 2 11:05 payroll-notes.txt
chmod g-rw payroll-notes.txt
ls -l payroll-notes.txt
-rw------- 1 hrlead finance 2210 Oct 2 11:05 payroll-notes.txt
The group had more access than its job required, so g-rw removed it. Now only the one person who needs the file can open it. This is the habit to build: check with ls -l, remove anything not needed, then check again.
Changing ownership: chown changes who owns a file. Using sudo is normally required.
sudo chown maya file.txt # change the owning user only
sudo chown :analysts file.txt # change the owning group only (note the leading colon)
sudo chown maya:analysts file.txt # change both
sudo chgrp analysts file.txt # another way to change only the group
Add -R to apply a change to a directory tree, and use it with care.
6. Users and groups
Every account has a numeric user ID (UID), and every user belongs to at least one group (GID). Permissions are checked against these. UID 0 is root, the all-powerful account, also called the superuser.
Authentication
Proving who you are, for example with a password or key when you log in.
Authorization
Deciding what you are allowed to access once you are known, for example which files you may read or whether you may use sudo.
Linux user-management commands cover both: creating accounts and passwords is about authentication, while groups, permissions and sudo rights are about authorization.
Where account data lives
| File | Holds | Who can read it |
|---|---|---|
/etc/passwd | Account list: name, UID, GID, home, shell | Everyone (it holds no password hashes) |
/etc/shadow | Password hashes and ageing settings | Root only (and privileged system groups) |
/etc/group | Groups and their members | Everyone |
/etc/sudoers | Who may use sudo | Root. Edit only with visudo |
A line in /etc/passwd looks like this, with fields split by colons:
analyst1:x:1002:1002::/home/analyst1:/bin/bash
Fields: username, password placeholder (x means the hash is in shadow), UID, GID, optional comment, home directory, login shell.
Using sudo responsibly
sudo (“super user do”) temporarily gives a permitted user elevated rights for one command. Who may use it is set in the sudoers configuration file. It is safer than logging in as root because mistakes are limited to one command, and the system can record which user ran what. Logging in as root does neither.
Think of sudo rights as a set of keys that open every door in a building. A few people genuinely need them, but each person who holds them is also a bigger target: if an attacker steals that account, they inherit the keys. So:
- Give
sudoonly to people who need it, and review the membership regularly. - Put
sudoin front of the one command that needs it, not in front of everything. sudobypasses normal protections, so a typo or a copied command can do serious damage. Read commands from online sources before you run them.
Managing users and groups (lab VM only)
sudo useradd -m -s /bin/bash analyst1 # create user with a home folder
sudo passwd analyst1 # set a password
sudo groupadd soc-team # create a group
sudo usermod -aG soc-team analyst1 # add user to the group
id analyst1 # confirm membership
groups analyst1 # list the user's groups
sudo usermod -L analyst1 # lock the account
sudo userdel -r analyst1 # delete user and home folder
Primary and supplementary groups
Each user has one primary group (the default group for files they create) and can have any number of supplementary (secondary) groups. Lower case -g is for the primary group, upper case -G is for supplementary groups. The groups must already exist.
| Goal | Command |
|---|---|
| New user with a chosen primary group | sudo useradd -m -g soc-team analyst2 |
| New user with supplementary groups (comma-separated, no spaces) | sudo useradd -m -G soc-team,audit-team analyst3 |
| Change an existing user’s primary group | sudo usermod -g soc-team analyst2 |
| Add a supplementary group and keep the others | sudo usermod -a -G audit-team analyst2 |
Change a user’s home directory (add -m to move the files) | sudo usermod -d /home/a2 -m analyst2 |
| Change a login name | sudo usermod -l analyst2b analyst2 |
| Lock an account so the user cannot log in | sudo usermod -L analyst2 |
| Create a temporary account that expires on a date | sudo useradd -m -e 2026-12-31 contractor1 |
- Important: in
usermod -aG, the-ameans append. Without it,-Greplaces the user’s supplementary groups, removing them from every other one. - Offboarding tip: when someone leaves, consider locking the account with
usermod -Linstead of deleting it. You can then see which files they own and reassign ownership withchown.userdelalone leaves the home directory behind, whileuserdel -rremoves it, so make sure you have a backup before using-r. - On Ubuntu and Kali, members of the
sudogroup can usesudo. Other distributions may use a group calledwheel. - Group changes apply at the next login.
- Security habits: one account per person, strong passwords, remove or lock accounts when people leave, and review the members of the sudo group regularly.
7. Reading authentication logs with grep
Authentication logs record logins, failed attempts and use of sudo. On Debian-based systems such as Ubuntu and Kali they are usually in /var/log/auth.log. On Red Hat-style systems the file is /var/log/secure. Some systems store logs only in the journal, which you read with journalctl. Reading these logs normally needs sudo.
Sample log you can practise on
This is invented data using reserved example addresses. Each line holds a timestamp, host name, the program that wrote it, and a message.
Oct 2 09:14:01 labvm sshd[1201]: Failed password for invalid user admin from 203.0.113.45 port 52114 ssh2
Oct 2 09:14:05 labvm sshd[1203]: Failed password for invalid user admin from 203.0.113.45 port 52120 ssh2
Oct 2 09:14:09 labvm sshd[1205]: Failed password for root from 203.0.113.45 port 52131 ssh2
Oct 2 09:20:44 labvm sshd[1230]: Accepted password for maya from 198.51.100.7 port 40022 ssh2
Oct 2 09:31:12 labvm sudo: maya : TTY=pts/0 ; PWD=/home/maya ; USER=root ; COMMAND=/usr/bin/apt update
Oct 2 09:45:30 labvm sshd[1260]: Failed password for maya from 198.51.100.7 port 40100 ssh2
Oct 2 10:02:18 labvm sshd[1288]: Failed password for invalid user test from 192.0.2.99 port 33000 ssh2
Oct 2 10:02:22 labvm sshd[1290]: Failed password for invalid user test from 192.0.2.99 port 33004 ssh2
grep patterns that matter
| Goal | Command | Meaning |
|---|---|---|
| Find failed logins | grep "Failed password" sample.log | Lines containing that phrase |
| Count them | grep -c "Failed password" sample.log | Number of matching lines (6 here) |
| Ignore case | grep -i "failed" sample.log | Matches Failed, FAILED, failed |
| Exclude lines | grep -v "Failed" sample.log | Everything that does not match |
| Show line numbers | grep -n "Accepted" sample.log | Helps you locate the line again |
| Context | grep -A 2 -B 2 "Accepted" sample.log | Two lines after and before |
| Either word | grep -E "Accepted|sudo" sample.log | Extended pattern with OR |
| Only invalid users | grep "invalid user" sample.log | Attempts for accounts that do not exist |
Worked investigation: who is guessing passwords?
Step 1: Count failures.
grep -c "Failed password" sample.log
Answer: 6.
Step 2: Pull out the source addresses. The -o option prints only the matched part, and the pattern describes four groups of digits:
grep "Failed password" sample.log | grep -oE '([0-9]{1,3}\.){3}[0-9]{1,3}'
Step 3: Count per address. Sort first so identical lines sit together, then count them, then sort by count:
grep "Failed password" sample.log | grep -oE '([0-9]{1,3}\.){3}[0-9]{1,3}' | sort | uniq -c | sort -nr
Expected output:
3 203.0.113.45
2 192.0.2.99
1 198.51.100.7
Step 4: Interpret. Address 203.0.113.45 failed three times in eight seconds, including attempts for admin and root. That speed and the invalid user names point to automated guessing. Address 198.51.100.7 logged in successfully, then failed once, which looks like a normal typo. The signal is the pattern, not the single line.
Step 5: Report. Write what you saw, the time window, the counts and your recommended action (for example, block the address, disable password login for SSH, or enable rate limiting).
Spotting a successful login right after repeated failures from the same address is the pattern to look for. It may mean the guessing worked.
Useful extras for real systems
sudo grep "Failed password" /var/log/auth.log | tail -n 20
sudo tail -f /var/log/auth.log
sudo journalctl -u ssh --since "1 hour ago"
last -n 10
sudo lastb -n 10
tail -fshows new lines as they arrive. PressCtrl+Cto stop.- The SSH service unit is called
sshon Debian-based systems andsshdon many others. lastshows recent logins, andlastbshows failed ones if the system records them.- Rotated logs are renamed (for example
auth.log.1) and older ones may be compressed. Usezgrepto search compressed files. - To see which logs changed recently, try
sudo find /var/log -type f -mmin -60.
8. Free online Linux practice environments
You do not need to install anything to practise. The options below give you a real Linux shell in your browser or on a cloud server. A good path is to start with a browser-only option, then move to a cloud virtual machine (VM) when you want a “real server” with SSH and real logs.
Check before you sign up. Free offers change often. The limits below come from each provider’s own pages where available, but always confirm the current terms on the linked site before you create an account.
| Option | What is free | Account needed | Can you use sudo? | Best for |
|---|---|---|---|---|
| LabEx | Free Linux terminal playground and free guided Linux labs; Linux Journey tutorials | Free account for labs | Varies, so test it | Guided beginner labs |
| Coddy terminal | Free bash terminal in the browser | None | No | Quick tests of pipes, grep, find |
| KodeKloud Studio | Selected free labs and playgrounds with limited access | Free account, no card | Varies, so test it | Structured hands-on labs |
| GitHub Codespaces | Monthly allowance on personal accounts: 120 core-hours and 15 GB storage | Free GitHub account | Normally yes, so test it | A full terminal for most of the tasks on this page |
| Oracle Cloud | Always Free VMs, plus a 30-day trial credit | Account and card verification | Yes (your own VM) | A real always-on server with SSH and logs |
| Google Cloud | New-customer credit, an always-free e2-micro VM and a free Cloud Shell | Account and card | Yes | Cloud Shell for quick practice |
| AWS | New accounts: Free plan with credits (up to 6 months); free CloudShell | Account and card | Yes | CloudShell, or an EC2 VM |
| Azure | 30-day credit, 12 months of free Linux VM hours, Cloud Shell storage free for 12 months | Account and card | VM: yes. Cloud Shell: no | A Linux VM for the admin tasks |
| Vultr | No permanent free tier; promo credit for new accounts at times | Account and payment method | Yes (your own VM) | An inexpensive VM after credits end |
Test what you can do in 10 seconds. In any environment, run these. If the last line prints root, sudo works and you can do Tasks 9, 10 and 19.
whoami
pwd
cat /etc/os-release
sudo whoami
Browser-only options
LabEx: free Linux terminal and guided labs
LabEx offers free hands-on labs for Linux, DevOps and cybersecurity, with an online Linux terminal playground and an AI helper called Labby inside the labs. Its Linux Journey tutorials (formerly linuxjourney.com) are free and need no sign-up.
- Open the Online Linux Terminal for a quick shell, or choose Join For Free to create an account.
- Open the Linux skill tree and start with the beginner labs on navigation, files and permissions.
- Follow each lab step in the terminal that opens next to the instructions. Ask Labby if you get stuck.
- When a lab ends, try the matching section of this page in the same terminal. Run
sudo whoamifirst to see whether admin commands are allowed in that lab.
LabEx also lists free cybersecurity labs and Wireshark and Nmap playgrounds. Use these only inside the lab environment, never against systems you do not own.
Coddy terminal: instant bash with no sign-up
A free online Linux terminal that runs real bash and GNU tools in a sandboxed container. It is quick and needs no account, but it is limited: it is stateless (every Run starts fresh in /home), has no network and no sudo, and is read-only outside /tmp and /home.
- Open coddy.tech/playground/terminal.
- Type a command at the prompt and press Enter to run it.
- Press Shift+Enter to add a new line, so you can write several commands (or a loop) and run them together with Enter.
- Because nothing carries over between runs, paste your setup and your task together. For example:
mkdir -p practice && cd practice
printf 'Failed password for root from 203.0.113.45\nAccepted password for maya from 198.51.100.7\n' > sample.log
grep -c "Failed password" sample.log
ls -l
What works here: navigation, file commands, chmod and the grep/sort/uniq pipelines on a sample file you create (Tasks 1 to 8 and 11 to 15, if you include the setup in each run). What does not: anything with sudo (Tasks 9, 10, 19), the interactive nano part of Task 17, and real system logs.
KodeKloud Studio: free selected Linux labs
A free KodeKloud account gives access to selected labs and playgrounds with limited privileges, and no card is needed. The full lab library requires a paid plan, so look for labs marked as free.
- Open the KodeKloud Studio Linux labs page.
- Create a free account when asked to sign up or log in.
- Choose a Linux lab or playground that is available on the free plan and press start. A terminal opens in your browser.
- Follow the lab’s tasks. Sessions are usually time-limited and may not save your work, so copy any notes out before time runs out.
Use these labs for guided repetition of the navigation, file and permission skills from sections 3 and 5, then repeat the same commands yourself without the instructions.
GitHub Codespaces: a full Linux terminal in your browser
Codespaces gives you a cloud development container with VS Code and a terminal in the browser. Personal GitHub Free accounts include 120 core-hours and 15 GB of storage per month. A core-hour is not a clock hour: on a 2-core machine that is roughly 60 hours of use. This free allowance is for personal accounts only, not organisation accounts.
- Sign in to GitHub and create a new repository (for example
linux-practice) with a README. - On the repository page, choose Code, then the Codespaces tab, then Create codespace on main.
- When the editor loads, open a terminal from the Terminal menu (New Terminal).
- Paste the setup block from section 9 and work through the tasks. Run
sudo whoamito check whethersudoworks for the user and group tasks. - When you finish, stop the codespace from github.com/codespaces. Delete codespaces you no longer need, because stored codespaces use up your storage allowance.
A codespace is a container, not a full server, so files such as /var/log/auth.log may be missing. Practise the log skills on sample.log instead.
Cloud free tiers (real servers)
A cloud VM is a Linux machine you fully control. Because it has a public address, you will see real SSH login attempts in its logs within hours, which makes section 7 come alive. If /var/log/auth.log does not exist on your image, use sudo journalctl -u ssh instead.
- Expect to add a payment card for identity verification. Set a budget or billing alert on day one.
- Stop or delete every VM when you finish, and check the provider’s usage page. Free does not mean unlimited.
- Log in with an SSH key, not a password, and never store real data or credentials on a practice server.
- Only test on machines you own. Do not run scanning or attack tools against other people’s systems.
Connecting by SSH from your own computer ties directly to the permissions section. SSH refuses a private key that other users can read, so lock it down first (this is the chmod 600 pattern from section 5):
chmod 600 ~/Downloads/my-key.pem
ssh -i ~/Downloads/my-key.pem ubuntu@YOUR_PUBLIC_IP
The default user name depends on the image: ubuntu on Ubuntu images from Oracle and AWS, azureuser in Azure’s portal default, and root on a new Vultr server. Your provider shows the right one on the connect screen.
Oracle Cloud: Always Free VMs
Oracle’s Free Tier has a 30-day trial with credits plus Always Free resources that do not expire. Always Free includes up to two small AMD VMs (1/8 OCPU each) and an Arm Ampere A1 allowance of 3,000 OCPU-hours and 18,000 GB-hours per month, which works out to about 4 OCPUs and 24 GB of memory in total, plus 200 GB of block storage. Oracle’s own page notes that Arm instances created with trial credits beyond the Always Free limit are disabled and later deleted if you do not upgrade.
- Create an account at oracle.com/cloud/free and complete the card verification.
- In the console, go to Compute then Instances, and choose Create instance.
- Pick an Ubuntu image, then pick a shape marked Always Free-eligible.
- Let Oracle generate an SSH key pair and download the private key before you create the instance.
- When the instance is running, copy its public IP and connect with the
chmodandsshcommands above.
The free Arm shape is sometimes “out of capacity” in busy regions. If so, try again later or use the small AMD shape, which is plenty for these tasks.
Google Cloud: Cloud Shell and a free e2-micro VM
New customers get a $300 credit, and Google also lists always-free usage limits, including one e2-micro Compute Engine instance per month (in eligible regions) and a Cloud Shell with 5 GB of persistent home-directory storage. Cloud Shell is the easiest start because it needs no VM at all.
- Sign in at console.cloud.google.com and create or select a project (you will be asked to set up billing for a new account).
- Click the Activate Cloud Shell icon (
>_) at the top right. A terminal opens at the bottom of the page. - Run the quick test from earlier, then paste the setup block from section 9. Only your home directory is kept between sessions.
- For a real server with logs, go to Compute Engine then VM instances, create an
e2-microin an eligible region with an Ubuntu or Debian image, and use the SSH button to open a browser terminal.
AWS: CloudShell and an EC2 VM
Accounts created after 15 July 2025 choose a Free plan at sign-up: $100 in credits, up to $100 more for completing onboarding activities, and the plan ends after 6 months or when the credits run out, whichever comes first. Older accounts keep the previous 12-month free tier. AWS CloudShell itself has no additional charge and gives you a browser terminal with 1 GB of persistent home storage per Region.
- Create an account at aws.amazon.com/free and select the Free plan when asked.
- In the console, click the CloudShell icon in the top navigation bar. A terminal opens after a short wait.
- Run the quick test and the setup block. CloudShell runs Amazon Linux, so a few details differ from Ubuntu (for example the auth log is
/var/log/secureon Red Hat-style systems). - For a real server, open EC2, choose Launch instance, pick an Ubuntu image and a small instance type such as
t3.micro, and create a key pair. Then use Connect to open a browser terminal, or SSH from your computer. - Terminate the instance when done so it stops using your credits.
Azure: a free Linux VM (and Cloud Shell)
An Azure free account includes a $200 credit that lasts 30 days, plus monthly free amounts of popular services for 12 months for new customers, including 750 hours each of B1s, B2pts v2 and B2ats v2 burstable VMs on Linux or Windows. Cloud Shell includes 5 GB of free Azure Files storage for 12 months. Microsoft says you need to move to pay-as-you-go pricing after 30 days or once the credit is used, whichever comes first, to keep receiving the free services, so watch the dates and your spending.
- Sign up at azure.microsoft.com/free.
- For a quick shell, click the Cloud Shell icon (
>_) in the portal’s top bar and choose Bash. Cloud Shell does not give yousudo, so use it for the navigation,chmodandgreppractice. - For the user and group tasks, create a VM: Create a resource, Virtual machine, pick an Ubuntu image and a free-eligible size such as
B1s, choose SSH public key, and let Azure generate a key pair. - When it is running, connect with the
chmodandsshcommands above (default userazureuser), then runsudo whoami. - Delete the resource group when you finish so nothing keeps running.
Vultr: an inexpensive VM (not a permanent free tier)
Vultr does not have a permanent free tier. New accounts have at times received promotional credit, but the amount, duration and rules change, so check vultr.com for the current offer and treat it as a low-cost option rather than a free one. Servers are billed while they exist, so destroy them when you finish.
- Create an account and add a payment method or apply any current promo credit.
- Choose Deploy, then a cloud compute server, a nearby location, an Ubuntu image and the smallest plan.
- Add your SSH key if offered. Otherwise Vultr shows the root password on the server’s overview page.
- Connect with
ssh root@YOUR_PUBLIC_IP, or use the web console button on the server page. - Do not keep working as root. Create a normal user, give it
sudo, and log in as that user, as in section 6:
adduser analyst1
usermod -aG sudo analyst1
Then log in as analyst1 and use sudo only when needed. This is the least-privilege habit from sections 3 and 6.
9. 19 practice tasks with solutions
Do these in a lab VM or in one of the free online environments above (tasks that need sudo will not work in every one). Try each task before opening the solution. First, set up the practice area and sample data by pasting this whole block into your terminal:
mkdir -p ~/linux-practice && cd ~/linux-practice
cat > sample.log << 'EOF'
Oct 2 09:14:01 labvm sshd[1201]: Failed password for invalid user admin from 203.0.113.45 port 52114 ssh2
Oct 2 09:14:05 labvm sshd[1203]: Failed password for invalid user admin from 203.0.113.45 port 52120 ssh2
Oct 2 09:14:09 labvm sshd[1205]: Failed password for root from 203.0.113.45 port 52131 ssh2
Oct 2 09:20:44 labvm sshd[1230]: Accepted password for maya from 198.51.100.7 port 40022 ssh2
Oct 2 09:31:12 labvm sudo: maya : TTY=pts/0 ; PWD=/home/maya ; USER=root ; COMMAND=/usr/bin/apt update
Oct 2 09:45:30 labvm sshd[1260]: Failed password for maya from 198.51.100.7 port 40100 ssh2
Oct 2 10:02:18 labvm sshd[1288]: Failed password for invalid user test from 192.0.2.99 port 33000 ssh2
Oct 2 10:02:22 labvm sshd[1290]: Failed password for invalid user test from 192.0.2.99 port 33004 ssh2
EOF
Task 1. Show your current directory and list everything in it, including hidden files, with sizes people can read.
pwd
ls -lah
You should see sample.log. Hidden items start with a dot.
Task 2. Create the directories reports/2026/october in one command.
mkdir -p reports/2026/october
-p creates every missing parent. Check with ls -R reports.
Task 3. Copy sample.log to reports/2026/october/ as auth-copy.log, then confirm it exists.
cp sample.log reports/2026/october/auth-copy.log
ls -l reports/2026/october
Always work on a copy of evidence, never the original.
Task 4. Show only the first 3 lines and the last 2 lines of sample.log.
head -n 3 sample.log
tail -n 2 sample.logTask 5. Find every .log file under your practice folder.
find ~/linux-practice -name "*.log"
Two results: sample.log and the copy from Task 3.
Task 6. Create report.sh containing one line (echo "hello"), then set it to 755 and run it.
echo 'echo "hello"' > report.sh
chmod 755 report.sh
./report.sh
It prints hello. The ./ tells the shell to run the file in the current directory.
Task 7. Create private.txt and make it readable and writable only by you, using symbolic mode, starting from any permissions.
touch private.txt
chmod u=rw,go= private.txt
ls -l private.txt
Result: -rw-------. The comma separates the change for the owner from the change for group and others (no spaces allowed). The empty value after go= clears all group and others permissions.
Task 8. A file shows -rwxr-x---. Give the numeric mode and say who can do what.
750. Owner: read, write, execute. Group: read and execute. Others: nothing.
Task 9. Create a lab user analyst1 with a home directory and confirm the account exists.
sudo useradd -m -s /bin/bash analyst1
id analyst1
grep analyst1 /etc/passwd
Set a password with sudo passwd analyst1 if you want to log in as that user.
Task 10. Create a group soc-team, add analyst1 to it without removing other groups, and verify.
sudo groupadd soc-team
sudo usermod -aG soc-team analyst1
id analyst1
The output should list soc-team among the groups. Keep analyst1 and soc-team for Task 19, which includes the clean-up commands.
Task 11. Count how many failed password lines are in sample.log.
grep -c "Failed password" sample.log
Answer: 6.
Task 12. Show only the lines that are not failed logins, with line numbers.
grep -vn "Failed" sample.log
You should see line 4 (accepted login) and line 5 (sudo use).
Task 13. List the unique source IP addresses of failed logins, ranked by number of attempts.
grep "Failed password" sample.log | grep -oE '([0-9]{1,3}\.){3}[0-9]{1,3}' | sort | uniq -c | sort -nr
Expected: 203.0.113.45 (3), 192.0.2.99 (2), 198.51.100.7 (1).
Task 14. How many failed attempts were for accounts that do not exist? Which user names were tried?
grep -c "invalid user" sample.log
grep "invalid user" sample.log | awk '{print $10}' | sort | uniq -c
Four attempts: admin twice and test twice. In these lines the user name is the tenth field, so $10 works. Field positions can differ between log formats, so always check a line first.
Task 15. Save a short findings file called findings.txt with the top attacker address and the count of failed logins, then check the permissions are 600.
{ echo "Top failed-login source:"; grep "Failed password" sample.log | grep -oE '([0-9]{1,3}\.){3}[0-9]{1,3}' | sort | uniq -c | sort -nr | head -n 1; echo "Total failed logins:"; grep -c "Failed password" sample.log; } > findings.txt
chmod 600 findings.txt
cat findings.txt
ls -l findings.txt
The file should show 203.0.113.45 with 3 attempts and a total of 6, with mode -rw-------. Findings often include sensitive details, so restrict access.
Task 16. Use the built-in help tools: get a one-line description of grep, find the cat option that numbers output lines, and find the command that creates a new group using keywords only.
whatis grep
man cat
apropos -a create group
whatis prints a one-line summary. In man cat look for -n (--number), then press q to quit. The apropos search should list groupadd among its results. If it says nothing appropriate, run sudo mandb and try again. Results vary slightly between distributions.
Task 17. Use nano to create notes.txt with one line, save it, then add a second line with echo without overwriting the first.
nano notes.txt
echo "second line" >> notes.txt
cat notes.txt
In nano, type a line, press Ctrl+O and Enter to save, then Ctrl+X to exit. cat should show both lines. If you used a single > instead of >>, the first line would have been overwritten.
Task 18. Find (a) any file in your practice folder with “LOG” in its name regardless of case, and (b) every file there changed in the last 24 hours.
find ~/linux-practice -iname "*log*"
find ~/linux-practice -type f -mtime -1
The first command returns sample.log and auth-copy.log. Try the same search with -name "*LOG*" and notice that it finds nothing, because -name is case-sensitive. The second lists everything you created today.
Task 19. Create a user analyst2 whose primary group is soc-team and who is also in a new group audit-team, verify it, lock the account, then clean up everything from Tasks 9, 10 and this task.
sudo groupadd audit-team
sudo useradd -m -g soc-team -G audit-team analyst2
id analyst2
sudo usermod -L analyst2
# clean up
sudo userdel -r analyst1
sudo userdel -r analyst2
sudo groupdel audit-team
sudo groupdel soc-team
id analyst2 should show soc-team as the primary group and audit-team as a supplementary group. Delete the users before the groups, because Linux will not remove a group that is still some user’s primary group. Remember that userdel -r also deletes the home directory, which is fine in a throwaway lab but needs a backup on a real system.
10. Common mistakes
- Using
chmod 777to “fix” a problem. Find the real cause and grant only what is needed. - Forgetting
-ainusermod -aG. The user loses their other groups. - Running
uniqwithoutsort. It only collapses neighbouring duplicates. - Editing original logs. Copy evidence and work on the copy.
- Overwriting with
>by accident. Use>>when you mean to append. - Exiting nano without saving. nano does not autosave; press
Ctrl+Ofirst. - Putting a space after the comma in
chmod. Writeu=rwx,g=rx, notu=rwx, g=rx. - Staying logged in as root. Use a normal account and
sudoonly when needed. - Running
sudocommands copied from the internet without reading them. Understand every part first. - Deleting a leaver’s account straight away. Lock it first with
usermod -L, check what they own, then decide. - Leaving a cloud practice server running. Stop or delete it when you finish, and set a billing alert before you start.
- Assuming one log location. Check your distribution; use
/var/log/secureorjournalctlwhere appropriate. - Treating one failed login as an attack. Look at volume, speed, user names and what happens next.
- Mistyping paths in destructive commands. Run
lson the path first, thenrm.
11. YouTube search links
- Linux command line for beginners
- Linux filesystem hierarchy explained
- Linux find command examples
- man, apropos and whatis explained
- nano text editor tutorial
- chmod and file permissions explained
- Linux users and groups
- Analysing auth logs with grep
12. One-screen revision summary
- Filesystem: one tree from
/; configuration in/etc, logs in/var/log, user files in/home, temporary files in/tmp.man hierexplains the layout. - Core commands:
pwd ls cd cat less head tail find grep mkdir cp mv rm. Use pipes to chain them. - Editing and output:
nano(Ctrl+Osave,Ctrl+Xexit),echo "text" > fileoverwrites,>>appends. - find:
-name(case-sensitive),-iname(not),-mtime(days),-mmin(minutes). - Getting help:
manfor detail,whatisfor one line,aproposto search by keyword. - Permissions: r=4, w=2, x=1; three digits for owner, group, others. 644 for documents, 755 for scripts, 600 for private files, avoid 777.
- Symbolic chmod: who (
u g o a), action (+ - =), permission (r w x); separate changes with commas and no spaces. - Authentication vs authorization: who you are vs what you may do.
- Users:
/etc/passwdlists accounts,/etc/shadowholds hashes.-gsets the primary group,-Gsupplementary groups, andusermod -aGadds groups safely.chown :groupchanges only the group. - Least privilege: normal account first,
sudofor single commands, remove access that is not needed (chmod g-rw). - Auth logs:
grep "Failed password", then extract IPs,sort | uniq -c | sort -nr, then interpret the pattern. - Evidence habits: work on copies, record commands, report findings clearly.
13. Key terms
| Term | Meaning |
|---|---|
| Absolute file path | The full path to a file or directory, starting from the root / |
| Argument | Extra information a command needs, such as a file name or a search word |
| Authentication | Verifying who someone is |
| Authorization | Granting access to specific resources once identity is known |
| Bash | The default shell (command interpreter) on most Linux distributions |
| Command | An instruction that tells the computer to do something |
| File path | The location of a file or directory, with levels separated by / |
| Filesystem Hierarchy Standard (FHS) | The part of Linux that defines how directories and data are organised |
| Filtering | Selecting data that matches a condition |
| nano | A beginner-friendly command-line text editor |
| Option | Input that changes how a command behaves, usually starting with - |
| Permissions | The type of access (read, write, execute) granted on a file or directory |
| Pipe | The | operator that feeds one command’s output into another command |
| Principle of least privilege | Granting only the minimum access needed to complete a task |
| Redirection | Sending output to a file with > (overwrite) or >> (append) |
| Relative file path | A path that starts from your current directory |
| Root directory | The highest-level directory, written / |
| Root user (superuser) | An account with elevated privileges to modify the system |
| Standard input | Information a command receives |
| Standard output | Information a command returns, normally shown on screen |
| sudo | Runs a single command with elevated rights for a permitted user |
| SSH | Secure Shell: a way to log in to a remote Linux machine over the network, often with a key file instead of a password |
| Virtual machine (VM) | A software-based computer that runs inside another computer or in the cloud, safe for practice because you can delete it |
14. What you should be able to do
Related pages
Educational summary for learners; not affiliated with Google or Coursera. Commands and file locations vary by Linux distribution, so verify details in your system’s manual pages. Last reviewed: October 2026.
