A beginner-friendly, practical Linux handbook for learning from scratch.
- Read one chapter at a time.
- Copy commands into a terminal only after reading the note or warning beside them.
- Practice each lab before moving on.
- Use the cheat sheet when you need a quick command reminder.
📝 Note Commands are written for common Linux distributions. Package manager commands may vary by distribution.
⚠️ Warning Be careful with commands that delete, overwrite, change permissions, format disks, or modify users. Always understand the command before running it.
- Linux Basics
- Installing Linux
- Linux File System
- Navigation Commands
- Working With Files
- Permissions
- File Searching
- Text Processing
- Redirection
- Processes
- Package Managers
- Networking
- Compression
- Disk Management
- Users
- Services
- Environment Variables
- Bash Basics
- Bash Scripting
- Cron Jobs
- Logs
- Security Basics
- Useful Linux Tools
- Keyboard Shortcuts
- Practice Exercises
- Linux Cheat Sheet
- Final Project
Estimated learning time: 45-60 minutes
Linux is a family of operating systems built around the Linux kernel. It is commonly used on servers, laptops, desktops, phones, routers, cloud platforms, embedded devices, and supercomputers.
Strictly speaking, Linux is the kernel. A complete Linux system also includes tools, libraries, shells, package managers, desktop environments, and applications.
uname -aExpected output example:
Linux ubuntu 6.8.0-35-generic #35-Ubuntu SMP x86_64 GNU/Linux
| Year | Event |
|---|---|
| 1969 | Unix development begins at Bell Labs. |
| 1983 | GNU project begins, aiming to create a free Unix-like operating system. |
| 1991 | Linus Torvalds announces the first Linux kernel. |
| 1990s | Linux distributions such as Debian, Slackware, Red Hat, and SUSE grow. |
| 2000s | Linux becomes dominant in servers, networking, and embedded systems. |
| Today | Linux powers cloud infrastructure, Android, containers, DevOps tooling, AI platforms, and more. |
- It is open source.
- It is stable and reliable.
- It is highly customizable.
- It runs well on servers.
- It has powerful command-line tools.
- It is widely used in cloud computing and cybersecurity.
- It supports strong automation through shell scripting.
A distribution, or distro, packages the Linux kernel with system tools, package managers, installers, documentation, and software repositories.
| Distribution | Best For | Package Manager |
|---|---|---|
| Ubuntu | Beginners, desktops, servers | APT |
| Linux Mint | New desktop users | APT |
| Debian | Stability, servers | APT |
| Fedora | Modern Linux features | DNF |
| RHEL / Rocky / AlmaLinux | Enterprise servers | DNF / YUM |
| Arch Linux | Advanced learning, customization | Pacman |
| openSUSE | Desktops and admin tools | Zypper |
| Kali Linux | Security labs | APT |
💡 Tip Beginners usually have the smoothest start with Ubuntu, Linux Mint, or Fedora.
Open source software makes its source code available so people can inspect, modify, share, and improve it.
This matters because:
- Bugs can be found by many people.
- Users are not locked into one vendor.
- Communities can improve tools together.
- Learning is easier because internals are visible.
| Term | Meaning |
|---|---|
| Kernel | The core layer that talks to hardware and manages processes, memory, filesystems, and devices. |
| Operating system | The full usable environment: kernel, tools, shell, libraries, package manager, services, and applications. |
Example:
uname -rExpected output:
6.8.0-35-generic
- Web servers
- Cloud platforms
- Containers and Kubernetes
- Android devices
- Network routers and firewalls
- Supercomputers
- Cybersecurity labs
- Developer workstations
- IoT and embedded systems
- Thinking Linux is only one operating system.
- Installing an advanced distro too early.
- Copying commands with
sudowithout understanding them. - Ignoring documentation and manual pages.
- Start with a beginner-friendly distro.
- Learn the terminal gradually.
- Practice in a virtual machine before changing your main computer.
- Keep notes of useful commands.
Linux is a powerful open source ecosystem built around the Linux kernel. Distributions package Linux into usable systems for different needs, from beginner desktops to enterprise servers.
- Run
uname -a. - Find your distribution name:
cat /etc/os-release- Find your current shell:
echo "$SHELL"Estimated learning time: 60-90 minutes
| Method | Best For | Risk Level |
|---|---|---|
| Virtual machine | Safe learning | Low |
| WSL | Windows users learning command line | Low |
| Live USB | Testing hardware compatibility | Low-medium |
| Dual boot | Daily desktop Linux use | Medium-high |
| Full install | Dedicated Linux machine | High if replacing existing OS |
Dual boot means installing Linux alongside another operating system, usually Windows.
Basic flow:
- Back up your files.
- Create free disk space.
- Create a bootable USB.
- Boot from USB.
- Choose "Install alongside" or manually partition.
- Install bootloader.
- Reboot and select OS.
⚠️ Warning Partitioning mistakes can erase data. Back up important files before dual booting.
A virtual machine runs Linux inside your existing operating system.
Common tools:
- VirtualBox
- VMware Workstation Player
- Hyper-V
- UTM
- GNOME Boxes
Recommended beginner VM settings:
| Resource | Recommendation |
|---|---|
| RAM | 4 GB minimum |
| CPU | 2 cores |
| Disk | 30 GB or more |
| Network | NAT |
WSL, or Windows Subsystem for Linux, lets Windows users run Linux command-line tools.
Install Ubuntu on WSL:
wsl --install -d UbuntuList installed WSL distributions:
wsl --list --verbose📝 Note WSL is excellent for learning shell commands, scripting, Git, Python, Node.js, and server tooling. It is not exactly the same as a full Linux desktop install.
A live USB lets you boot Linux without installing it.
Use it to:
- Test Wi-Fi, graphics, keyboard, and touchpad support.
- Try Linux before installing.
- Recover files from a broken system.
| Goal | Recommended Distro |
|---|---|
| Beginner desktop | Linux Mint or Ubuntu |
| Developer laptop | Ubuntu or Fedora |
| Stable server | Debian or Ubuntu Server |
| Enterprise practice | Rocky Linux or AlmaLinux |
| Learn internals | Arch Linux after basics |
| Security learning | Kali in a VM only |
- Verify ISO checksums when possible.
- Use official download pages.
- Disable fast startup in Windows before dual booting.
- Keep a recovery USB nearby.
- Record your disk layout before changing partitions.
- Start with a VM if unsure.
The safest way to learn Linux is through a VM or WSL. Dual boot and full installs are useful later, but they require careful backups and partitioning.
- Install Linux in a VM or WSL.
- Run:
whoami
pwd
ls
cat /etc/os-release- Take a screenshot or note your distro version.
Estimated learning time: 60-75 minutes
Linux uses a single directory tree that starts at /, called the root directory.
/
├── bin
├── boot
├── dev
├── etc
├── home
├── lib
├── media
├── mnt
├── opt
├── proc
├── root
├── run
├── sbin
├── srv
├── sys
├── tmp
├── usr
└── var
| Directory | Purpose | Example |
|---|---|---|
/ |
Root of the filesystem. Everything starts here. | cd / |
/bin |
Essential user commands. | /bin/ls |
/boot |
Bootloader files and kernels. | /boot/vmlinuz-* |
/dev |
Device files representing hardware and virtual devices. | /dev/sda, /dev/null |
/etc |
System-wide configuration files. | /etc/ssh/sshd_config |
/home |
Regular users' home directories. | /home/alex |
/lib |
Essential shared libraries. | /lib/x86_64-linux-gnu |
/media |
Auto-mounted removable media. | /media/alex/USB |
/mnt |
Temporary manual mount point. | /mnt/backup |
/opt |
Optional third-party software. | /opt/google |
/proc |
Virtual filesystem exposing process and kernel information. | /proc/cpuinfo |
/root |
Home directory of the root user. | /root |
/run |
Runtime state files since boot. | /run/sshd.pid |
/sbin |
System administration binaries. | /sbin/reboot |
/srv |
Data served by services. | /srv/www |
/sys |
Virtual filesystem for devices and kernel objects. | /sys/class/net |
/tmp |
Temporary files. Often cleared automatically. | /tmp/test.txt |
/usr |
User programs, libraries, docs, and shared data. | /usr/bin/python3 |
/var |
Variable data like logs, cache, mail, and databases. | /var/log/syslog |
An absolute path starts at /:
cd /var/logA relative path starts from your current directory:
cd DocumentsShow your current directory:
pwd- Confusing
/with/root. - Editing files in
/etcwithout a backup. - Storing personal files outside
/home. - Deleting files in
/varor/usrwithout knowing why.
- Keep personal files in your home directory.
- Use
/tmponly for temporary work. - Back up configuration before editing:
sudo cp /etc/ssh/sshd_config /etc/ssh/sshd_config.bakLinux organizes all files under /. System files, user files, device files, logs, applications, and temporary data each have common locations.
cd /
ls
cd /etc
pwd
cd ~
mkdir -p linux-practice/filesystem
cd linux-practice/filesystem
pwdTry reading system information:
cat /proc/cpuinfo | head
cat /proc/meminfo | headEstimated learning time: 75-90 minutes
Most commands follow this shape:
command [options] [arguments]Example:
ls -la /etc| Part | Meaning |
|---|---|
ls |
Command |
-la |
Options |
/etc |
Argument |
Purpose: print working directory.
Syntax:
pwdExample:
pwdExpected output:
/home/alex
Related commands: cd, realpath
Purpose: list directory contents.
Syntax:
ls [options] [path]Examples:
ls
ls -l
ls -la
ls -lh /var/logCommon options:
| Option | Meaning |
|---|---|
-l |
Long listing |
-a |
Show hidden files |
-h |
Human-readable sizes |
-R |
Recursive listing |
-t |
Sort by modification time |
Common mistake:
ls -lh /missing/pathExpected error:
ls: cannot access '/missing/path': No such file or directory
Purpose: change directory.
Syntax:
cd [path]Examples:
cd /etc
cd ~
cd ..
cd -| Path | Meaning |
|---|---|
~ |
Your home directory |
. |
Current directory |
.. |
Parent directory |
- |
Previous directory |
Purpose: show directories as a tree.
Install if missing:
sudo apt install treeExamples:
tree
tree -L 2
tree -aPurpose: search files and directories.
Syntax:
find [path] [expression]Examples:
find . -name "*.txt"
find /etc -type f -name "*.conf"
find ~ -type d -name "Downloads"Purpose: quickly find files using a database.
Install:
sudo apt install plocateUpdate database:
sudo updatedbSearch:
locate sshd_config📝 Note
locatemay not find newly created files until its database is updated.
Purpose: show the path of a command that your shell would run.
which python3Expected output:
/usr/bin/python3
Purpose: locate binary, source, and manual page files.
whereis bashExpected output:
bash: /usr/bin/bash /usr/share/man/man1/bash.1.gz
Purpose: print the absolute resolved path.
realpath ../Documents- Use
pwdoften when learning. - Use quotes around paths with spaces:
cd "My Folder"- Use tab completion to avoid typos.
Navigation commands help you understand where you are, move around the filesystem, locate commands, and resolve paths.
mkdir -p ~/linux-practice/navigation/alpha/beta
cd ~/linux-practice/navigation
pwd
tree
cd alpha/beta
pwd
cd ..
realpath .
find ~/linux-practice -type d -name betaEstimated learning time: 90-120 minutes
Purpose: create an empty file or update a timestamp.
touch notes.txt
ls -l notes.txtPurpose: print or concatenate files.
cat notes.txt
cat file1.txt file2.txtCreate a small file:
cat > hello.txt
Hello Linux
Press Ctrl+D when donePurpose: view files page by page.
less /var/log/syslogUseful keys:
| Key | Action |
|---|---|
Space |
Next page |
b |
Previous page |
/text |
Search |
q |
Quit |
Purpose: simple pager.
more /etc/services💡 Tip Prefer
lessfor most reading because it has better navigation.
Purpose: show beginning of a file.
head /etc/passwd
head -n 5 /etc/passwdPurpose: show end of a file.
tail /etc/passwd
tail -n 20 /var/log/syslog
tail -f /var/log/syslogPurpose: beginner-friendly terminal text editor.
nano notes.txtUseful keys:
| Key | Action |
|---|---|
Ctrl+O |
Save |
Enter |
Confirm filename |
Ctrl+X |
Exit |
Ctrl+W |
Search |
Purpose: powerful modal terminal editor.
Open file:
vim notes.txtBasic workflow:
| Key | Action |
|---|---|
i |
Insert mode |
Esc |
Normal mode |
:w |
Save |
:q |
Quit |
:wq |
Save and quit |
:q! |
Quit without saving |
⚠️ Warning New users often get stuck in Vim. PressEsc, type:q, then pressEnterto quit.
Purpose: copy files and directories.
cp notes.txt notes-backup.txt
cp -r project project-backup
cp -i notes.txt notes-backup.txtOptions:
| Option | Meaning |
|---|---|
-r |
Recursive copy |
-i |
Ask before overwrite |
-v |
Verbose |
-p |
Preserve mode, ownership, timestamps |
Purpose: move or rename files.
mv old.txt new.txt
mv new.txt ~/Documents/
mv -i file.txt existing.txtPurpose: remove files or directories.
rm old.txt
rm -i old.txt
rm -r old-folder
⚠️ Warningrmdoes not move files to a recycle bin. Be extra careful withrm -rand never run destructive commands from unknown sources.
Purpose: create directories.
mkdir projects
mkdir -p projects/linux/scriptsPurpose: remove empty directories.
rmdir empty-folderPurpose: create links.
Hard link:
ln original.txt hard-link.txtSymbolic link:
ln -s /var/log/syslog syslog-link| Link Type | Description |
|---|---|
| Hard link | Another directory entry for the same file data. |
| Symbolic link | A pointer to another path. |
- Running
rm -rin the wrong directory. - Forgetting
-rwhen copying directories. - Overwriting files with
cpormv. - Using
caton huge files instead ofless.
- Use
-iwhile learning:
cp -i source.txt destination.txt
mv -i old.txt new.txt
rm -i file.txt- Make backups before editing config files.
- Use
lessfor large files.
File commands let you create, inspect, edit, copy, move, delete, organize, and link files. The most dangerous beginner command in this chapter is rm, so use it carefully.
mkdir -p ~/linux-practice/files
cd ~/linux-practice/files
touch alpha.txt beta.txt
echo "hello" > alpha.txt
cat alpha.txt
cp alpha.txt alpha-copy.txt
mv beta.txt gamma.txt
mkdir archive
mv gamma.txt archive/
ln -s alpha.txt alpha-link.txt
ls -laEstimated learning time: 90-120 minutes
Linux permissions control who can read, write, or execute files.
| Symbol | Meaning For Files | Meaning For Directories |
|---|---|---|
r |
Read file contents | List directory contents |
w |
Modify file contents | Create, delete, or rename entries |
x |
Execute file | Enter/traverse directory |
Linux permission sets apply to:
| Class | Meaning |
|---|---|
| User | File owner |
| Group | Users in the file's group |
| Others | Everyone else |
Example:
ls -l script.shExpected output:
-rwxr-xr-- 1 alex developers 42 Aug 6 10:00 script.sh
Breakdown:
| Part | Meaning |
|---|---|
- |
Regular file |
rwx |
Owner can read, write, execute |
r-x |
Group can read and execute |
r-- |
Others can read |
Purpose: change permissions.
Symbolic examples:
chmod u+x script.sh
chmod g-w report.txt
chmod o-r private.txt
chmod a+r README.mdNumeric examples:
chmod 644 README.md
chmod 755 script.sh
chmod 700 private-folder| Number | Permission |
|---|---|
4 |
Read |
2 |
Write |
1 |
Execute |
0 |
None |
Add numbers together:
| Value | Meaning |
|---|---|
7 |
rwx |
6 |
rw- |
5 |
r-x |
4 |
r-- |
0 |
--- |
Common modes:
| Mode | Meaning | Typical Use |
|---|---|---|
400 |
Owner read only | Private key |
444 |
Everyone read only | Public read-only file |
600 |
Owner read/write | Private config |
644 |
Owner write, everyone read | Normal text file |
700 |
Owner full access | Private directory or script |
755 |
Owner write, everyone read/execute | Public directory or executable |
777 |
Everyone full access | Rare temporary troubleshooting only |
⚠️ Warning Avoidchmod 777. It allows every user to read, write, and execute. On shared systems, this can expose data, allow accidental deletion, or enable malicious modification.
Purpose: change owner and optionally group.
sudo chown alex file.txt
sudo chown alex:developers project/
sudo chown -R alex:developers project/Purpose: change group ownership.
sudo chgrp developers report.txtPurpose: set default permission mask for new files and directories.
Show current umask:
umaskCommon default:
0022
This usually creates:
- Files as
644 - Directories as
755
Purpose: run a command with elevated privileges.
sudo apt update
sudo systemctl restart ssh
⚠️ Warningsudomeans "do this with administrator-level power." Read the command carefully first.
- Using
sudofor everything. - Running
chmod -R 777. - Making private SSH keys too permissive.
- Forgetting that directory
xpermission controls traversal.
- Use least privilege.
- Use
644for ordinary files and755for ordinary directories. - Use
600or400for private secrets. - Avoid recursive permission changes unless necessary.
Permissions protect files and directories through read, write, and execute bits for owner, group, and others. Numeric modes are compact, but dangerous when used carelessly.
mkdir -p ~/linux-practice/permissions
cd ~/linux-practice/permissions
echo "secret" > secret.txt
ls -l secret.txt
chmod 600 secret.txt
ls -l secret.txt
echo 'echo hello' > run-me.sh
chmod 755 run-me.sh
./run-me.shEstimated learning time: 75-90 minutes
Search by name:
find ~ -name "notes.txt"Search by extension:
find . -type f -name "*.log"Search by size:
find . -type f -size +10M
find . -type f -size -100kSearch by date:
find . -type f -mtime -7
find . -type f -mtime +30Search by permissions:
find . -type f -perm 777
find . -type f -perm /u=xRun a command on matches:
find . -type f -name "*.tmp" -printlocate nginx.conf
locate "*.service"Purpose: search text content.
grep "error" app.log
grep -i "error" app.log
grep -R "TODO" .
grep -n "main" script.shOptions:
| Option | Meaning |
|---|---|
-i |
Ignore case |
-n |
Show line numbers |
-R |
Recursive |
-v |
Invert match |
-E |
Extended regular expressions |
Command: rg
Purpose: fast recursive text search.
Install:
sudo apt install ripgrepExamples:
rg "error"
rg -n "TODO" .
rg -i "failed" /var/log
rg --files
rg --files -g "*.md"- Searching the whole filesystem when home directory is enough.
- Forgetting quotes around patterns with spaces.
- Confusing filename search with content search.
- Use
findfor file metadata. - Use
greporrgfor file contents. - Prefer
rgin code projects when available.
Use find and locate to discover files by path or metadata. Use grep and rg to search inside files.
mkdir -p ~/linux-practice/search/logs
cd ~/linux-practice/search
printf "INFO started\nERROR failed\n" > logs/app.log
touch report.txt data.csv
find . -type f -name "*.txt"
find . -type f -name "*.log"
grep -n "ERROR" logs/app.log
rg "started" .Estimated learning time: 90-120 minutes
Text processing is one of Linux's strongest areas.
Create sample data:
cat > people.csv <<'EOF'
name,team,score
Alex,blue,91
Sam,red,84
Taylor,blue,88
Jordan,red,91
EOFgrep "blue" people.csv
grep -v "red" people.csvPurpose: process columns and records.
Print first column:
awk -F, '{print $1}' people.csvPrint names and scores:
awk -F, 'NR > 1 {print $1, $3}' people.csvPurpose: stream editing.
Replace text:
sed 's/blue/green/g' people.csvPrint lines 2-3:
sed -n '2,3p' people.csvPurpose: extract fields.
cut -d, -f1 people.csv
cut -d, -f1,3 people.csvsort people.csv
sort -t, -k3 -n people.csvcut -d, -f2 people.csv | sort | uniq
cut -d, -f2 people.csv | sort | uniq -cwc people.csv
wc -l people.csv
wc -w people.csv
wc -c people.csvecho "hello" | tr 'a-z' 'A-Z'
echo "a,b,c" | tr ',' '\n'Purpose: build command arguments from input.
printf "one\ntwo\nthree\n" | xargs echoFind and count matching files:
find . -name "*.csv" | xargs wc -l
⚠️ Warning Filenames can contain spaces. Safer pattern:
find . -name "*.csv" -print0 | xargs -0 wc -l- Parsing complex formats with simple tools when a structured parser is better.
- Forgetting
sortbeforeuniq. - Using
xargsunsafely with filenames containing spaces.
- Build pipelines step by step.
- Test on sample data first.
- Use
awk -F,for simple CSV only; real CSV can contain quoted commas.
Linux text tools can filter, transform, count, sort, and summarize data. Pipelines let small tools work together.
cd ~/linux-practice
mkdir -p text
cd text
cat > access.log <<'EOF'
200 /index.html
404 /missing.html
200 /about.html
500 /api
404 /old.html
EOF
grep "404" access.log
awk '{print $1}' access.log | sort | uniq -c
wc -l access.logEstimated learning time: 60-75 minutes
Redirection controls where input and output go.
| Operator | Purpose |
|---|---|
> |
Redirect output, overwrite file |
>> |
Redirect output, append to file |
< |
Read input from file |
<< |
Here document |
| ` | ` |
tee |
Send output to screen and file |
echo "hello" > message.txt
cat message.txt
⚠️ Warning>overwrites the target file.
echo "line one" >> notes.txt
echo "line two" >> notes.txt
cat notes.txtwc -l < notes.txtcat > todo.txt <<'EOF'
Learn pwd
Learn ls
Learn cd
EOFcat /etc/passwd | head
ps aux | grep sshecho "hello" | tee output.txt
echo "another line" | tee -a output.txtUse with sudo:
echo "example" | sudo tee /etc/example.conf- Accidentally overwriting a file with
>. - Forgetting
-awithteewhen appending. - Building very long pipelines without testing each step.
- Use
>>when preserving existing content matters. - Use
teewhen you want to see and save output. - Break pipelines into pieces while learning.
Redirection and pipes make Linux commands powerful. They let you save output, append data, read from files, and combine commands.
mkdir -p ~/linux-practice/redirection
cd ~/linux-practice/redirection
echo "alpha" > words.txt
echo "beta" >> words.txt
cat words.txt | sort | tee sorted.txt
wc -l < sorted.txtEstimated learning time: 75-90 minutes
A process is a running program.
ps
ps aux
ps aux | grep sshtopKeys:
| Key | Action |
|---|---|
q |
Quit |
P |
Sort by CPU |
M |
Sort by memory |
Install:
sudo apt install htopRun:
htopPurpose: send a signal to a process by PID.
kill 1234
kill -9 1234
⚠️ Warningkill -9forcefully terminates a process. Try normalkillfirst.
killall firefoxpkill -f "python app.py"Start a long command:
sleep 300Press Ctrl+Z, then:
jobs
bg %1
fg %1Start with lower priority:
nice -n 10 long-commandChange priority:
sudo renice -n 5 -p 1234- Killing the wrong PID.
- Using
kill -9too quickly. - Forgetting background jobs are still running.
- Inspect with
ps,top, orhtopbefore killing. - Try graceful termination first.
- Use service management for system services instead of killing random processes.
Processes are running programs. Linux provides tools to inspect, pause, resume, prioritize, and terminate them.
sleep 120 &
jobs
ps
kill %1
jobsEstimated learning time: 75-90 minutes
Package managers install, update, remove, and search software from trusted repositories.
| Distribution Family | Package Manager |
|---|---|
| Debian, Ubuntu, Mint | APT |
| Fedora, RHEL, Rocky, AlmaLinux | DNF |
| Older RHEL/CentOS | YUM |
| Arch, Manjaro | Pacman |
| openSUSE | Zypper |
| Universal | Snap |
| Universal desktop apps | Flatpak |
sudo apt update
sudo apt upgrade
sudo apt install tree
sudo apt remove tree
apt search nginx
apt show nginxsudo dnf check-update
sudo dnf upgrade
sudo dnf install tree
sudo dnf remove tree
dnf search nginx
dnf info nginxsudo yum update
sudo yum install tree
sudo yum remove tree
yum search nginxsudo pacman -Syu
sudo pacman -S tree
sudo pacman -R tree
pacman -Ss nginx
pacman -Qi bashsudo zypper refresh
sudo zypper update
sudo zypper install tree
sudo zypper remove tree
zypper search nginxsudo snap install hello-world
snap list
sudo snap remove hello-world
snap find codeflatpak search vlc
flatpak install flathub org.videolan.VLC
flatpak run org.videolan.VLC
flatpak uninstall org.videolan.VLC- Mixing package sources without understanding them.
- Skipping updates for months.
- Running random install scripts from the internet.
- Confusing package names with command names.
- Prefer official repositories.
- Update package indexes before installing with APT.
- Read package details before installing unfamiliar tools.
- Remove software you no longer use.
Package managers are the safest normal way to install software on Linux. Use the one designed for your distribution.
Install tree using your distro's package manager, then run:
tree --versionSearch for nginx with your package manager without installing it.
Estimated learning time: 90-120 minutes
Show addresses:
ip addrShow routes:
ip routeOlder networking command, often not installed by default.
ifconfigInstall on Debian/Ubuntu:
sudo apt install net-toolsping example.com
ping -c 4 example.comtraceroute example.comInstall if missing:
sudo apt install tracerouteShow listening ports:
ss -tulnShow TCP connections:
ss -tanOlder alternative:
netstat -tulncurl https://example.com
curl -I https://example.com
curl -o page.html https://example.comwget https://example.com
wget -O page.html https://example.comdig example.com
dig example.com A
dig example.com MXnslookup example.comssh user@server.example.com
ssh -p 2222 user@server.example.comscp file.txt user@server:/home/user/
scp user@server:/var/log/app.log .rsync -av project/ backup/
rsync -avz project/ user@server:/home/user/project/- Using
ifconfigon systems whereipis preferred. - Leaving SSH open with weak passwords.
- Confusing local and remote paths in
scp. - Downloading files without checking the URL.
- Prefer
ipandsson modern Linux. - Use SSH keys instead of passwords.
- Use
rsyncfor repeat transfers. - Check listening ports regularly on servers.
Linux networking tools help inspect interfaces, test connectivity, resolve DNS, download files, connect remotely, and transfer data.
ip addr
ip route
ping -c 4 example.com
curl -I https://example.com
ss -tulnEstimated learning time: 60-75 minutes
zip archive.zip file1.txt file2.txt
zip -r project.zip project/
unzip archive.zip
unzip archive.zip -d extracted/gzip app.log
gunzip app.log.gzCreate archive:
tar -cf files.tar file1.txt file2.txtExtract archive:
tar -xf files.tarCreate gzip-compressed tarball:
tar -czf project.tar.gz project/Extract gzip-compressed tarball:
tar -xzf project.tar.gzList archive contents:
tar -tf project.tar.gzxz largefile
unxz largefile.xz
tar -cJf project.tar.xz project/
tar -xJf project.tar.xzbzip2 file.txt
bunzip2 file.txt.bz2
tar -cjf project.tar.bz2 project/
tar -xjf project.tar.bz2- Confusing archiving with compression.
- Extracting archives in the wrong directory.
- Forgetting
-z,-J, or-jwith compressed tar files.
- List archive contents before extracting unknown archives:
tar -tf archive.tar.gz- Extract into a new folder when unsure:
mkdir extracted
tar -xzf archive.tar.gz -C extractedArchives group files together. Compression reduces size. tar.gz is one of the most common Linux archive formats.
mkdir -p ~/linux-practice/compression/project
cd ~/linux-practice/compression
echo "alpha" > project/a.txt
echo "beta" > project/b.txt
tar -czf project.tar.gz project/
tar -tf project.tar.gz
mkdir extracted
tar -xzf project.tar.gz -C extractedEstimated learning time: 75-90 minutes
Purpose: show filesystem disk usage.
df -h
df -h /Purpose: show file and directory sizes.
du -sh .
du -h --max-depth=1lsblk
lsblk -fsudo blkidmount
sudo mount /dev/sdb1 /mntsudo umount /mntInspect disks:
sudo fdisk -lEdit a disk:
sudo fdisk /dev/sdb
⚠️ Warning Partitioning tools can destroy data. Do not write changes unless you know exactly which disk you are modifying.
- Confusing
/dev/sdaand/dev/sdb. - Unmounting the wrong filesystem.
- Running partition commands on the system disk accidentally.
- Use
lsblk -fbefore mounting or formatting. - Back up data before partitioning.
- Prefer graphical disk tools while learning if available.
Disk tools show storage usage, block devices, partitions, filesystems, and mount points. Treat partitioning commands with caution.
df -h
du -sh ~
lsblk
lsblk -fEstimated learning time: 75-90 minutes
whoamiid
id usernameChange your password:
passwdChange another user's password:
sudo passwd usernameCreate user:
sudo useradd -m studentCreate user with shell:
sudo useradd -m -s /bin/bash studentAdd user to group:
sudo usermod -aG sudo studentChange shell:
sudo usermod -s /bin/bash studentDelete user:
sudo userdel studentDelete user and home directory:
sudo userdel -r studentgroups
groups student- Forgetting
-mwhen creating a user. - Forgetting
-awithusermod -aG, which can replace group membership. - Deleting a user before backing up their home directory.
- Use named users instead of sharing one account.
- Grant admin privileges only when needed.
- Lock or remove unused accounts.
Linux is a multi-user system. User and group commands manage identity, access, shells, passwords, and administrative privileges.
⚠️ Warning This lab changes users. Run it only in a VM, WSL test environment, or disposable lab system.
sudo useradd -m -s /bin/bash student
id student
groups student
sudo passwd student
sudo userdel -r studentEstimated learning time: 60-75 minutes
Most modern Linux systems use systemd. The main command is systemctl.
systemctl status ssh
systemctl status nginxsudo systemctl start nginx
sudo systemctl stop nginx
sudo systemctl restart nginxEnable at boot:
sudo systemctl enable nginxDisable at boot:
sudo systemctl disable nginxEnable and start now:
sudo systemctl enable --now nginxsystemctl list-units --type=service
systemctl list-unit-files --type=service- Starting a service without enabling it for boot.
- Enabling a service without starting it now.
- Managing services by killing processes instead of using
systemctl.
- Check status after changes.
- Read logs if a service fails:
journalctl -u nginx --no-pagersystemctl manages services: start, stop, restart, enable, disable, and inspect status.
If cron is available:
systemctl status cron
sudo systemctl restart cron
systemctl status cronOn some distributions, use:
systemctl status crondEstimated learning time: 45-60 minutes
Environment variables store configuration values available to the shell and processes.
| Variable | Meaning | Example Command |
|---|---|---|
PATH |
Directories searched for commands | echo "$PATH" |
HOME |
Current user's home directory | echo "$HOME" |
USER |
Current username | echo "$USER" |
HOSTNAME |
System hostname | echo "$HOSTNAME" |
SHELL |
Current user's login shell | echo "$SHELL" |
Create shell variable:
EDITOR=nanoExport environment variable:
export EDITOR=nanoUse it:
echo "$EDITOR"env
env | sortprintenv
printenv PATHmkdir -p ~/bin
export PATH="$HOME/bin:$PATH"To make it persistent, add it to ~/.bashrc:
echo 'export PATH="$HOME/bin:$PATH"' >> ~/.bashrc
source ~/.bashrc- Forgetting
$when reading a variable. - Adding broken entries to
PATH. - Editing shell config files without opening a new shell or using
source.
- Quote variable expansions:
echo "$HOME"- Put personal scripts in
~/binor~/.local/bin. - Avoid storing secrets in shell history.
Environment variables configure shells and programs. PATH is especially important because it controls where Linux looks for commands.
echo "$HOME"
echo "$USER"
printenv SHELL
export FAVORITE_OS=Linux
echo "$FAVORITE_OS"Estimated learning time: 75-90 minutes
Bash is a common Linux shell. It reads commands, expands variables, runs programs, and supports scripting.
name="Alex"
echo "Hello, $name"No spaces around =:
city="Prague"greet() {
echo "Hello, $1"
}
greet "Linux learner"alias ll='ls -lah'
llMake persistent:
echo "alias ll='ls -lah'" >> ~/.bashrc
source ~/.bashrchistory
history | grep sshRun previous command:
!!Type part of a command or path, then press Tab.
Example:
cd ~/Doc<Tab>- Writing
name = Alexinstead ofname="Alex". - Forgetting quotes around variables.
- Making aliases that hide important command behavior.
- Use meaningful variable names.
- Keep aliases simple.
- Learn shell history search with
Ctrl+R.
Bash lets you run commands interactively and build reusable shortcuts with variables, aliases, functions, history, and completion.
mkdir -p ~/linux-practice/bash
cd ~/linux-practice/bash
name="Student"
echo "Welcome, $name"
alias today='date'
today
history | tailEstimated learning time: 2-3 hours
A Bash script is a file containing shell commands.
#!/bin/bashThis is called a shebang. It tells Linux which interpreter to use.
Create hello.sh:
nano hello.shContent:
#!/bin/bash
echo "Hello from Bash"Run:
chmod +x hello.sh
./hello.shExpected output:
Hello from Bash
#!/bin/bash
name="Alex"
echo "Hello, $name"#!/bin/bash
echo "Script name: $0"
echo "First argument: $1"
echo "All arguments: $@"Run:
./args.sh one two three#!/bin/bash
if [ -f "$1" ]; then
echo "File exists: $1"
else
echo "File not found: $1"
fi#!/bin/bash
case "$1" in
start)
echo "Starting"
;;
stop)
echo "Stopping"
;;
*)
echo "Usage: $0 {start|stop}"
exit 1
;;
esac#!/bin/bash
for file in *.txt; do
echo "Found text file: $file"
done#!/bin/bash
count=1
while [ "$count" -le 5 ]; do
echo "Count: $count"
count=$((count + 1))
done#!/bin/bash
log() {
echo "[$(date +%F_%T)] $1"
}
log "Script started"Linux commands return exit codes:
| Code | Meaning |
|---|---|
0 |
Success |
| Non-zero | Error or special condition |
Check previous command:
echo "$?"Exit manually:
exit 1backup-folder.sh:
#!/bin/bash
set -e
source_dir="$1"
backup_dir="$2"
if [ -z "$source_dir" ] || [ -z "$backup_dir" ]; then
echo "Usage: $0 SOURCE_DIR BACKUP_DIR"
exit 1
fi
if [ ! -d "$source_dir" ]; then
echo "Source directory does not exist: $source_dir"
exit 1
fi
mkdir -p "$backup_dir"
timestamp="$(date +%Y%m%d-%H%M%S)"
archive="$backup_dir/backup-$timestamp.tar.gz"
tar -czf "$archive" "$source_dir"
echo "Backup created: $archive"Run:
chmod +x backup-folder.sh
./backup-folder.sh ~/Documents ~/backupsdisk-report.sh:
#!/bin/bash
echo "Disk usage report"
echo "Generated: $(date)"
echo
df -h
echo
echo "Largest items in current directory:"
du -h --max-depth=1 . | sort -h | tailcheck-site.sh:
#!/bin/bash
url="$1"
if [ -z "$url" ]; then
echo "Usage: $0 URL"
exit 1
fi
status="$(curl -o /dev/null -s -w "%{http_code}" "$url")"
echo "$url returned HTTP status $status"
if [ "$status" -ge 200 ] && [ "$status" -lt 400 ]; then
exit 0
else
exit 1
fi- Forgetting
chmod +x. - Running a script from the wrong directory.
- Not quoting variables.
- Ignoring exit codes.
- Using Bash-specific features with
/bin/sh.
- Start scripts with
#!/bin/bash. - Use
set -efor simple scripts where stopping on error is desired. - Quote variables:
"$file". - Validate arguments.
- Print helpful usage messages.
Bash scripts automate repeated tasks. Start small, validate inputs, quote variables, and check errors.
Create a script called hello-user.sh:
#!/bin/bash
name="$1"
if [ -z "$name" ]; then
echo "Usage: $0 NAME"
exit 1
fi
echo "Hello, $name"Run:
chmod +x hello-user.sh
./hello-user.sh SamEstimated learning time: 45-60 minutes
Cron runs scheduled commands.
Edit current user's cron jobs:
crontab -eList jobs:
crontab -lRemove all current user's jobs:
crontab -r
⚠️ Warningcrontab -rremoves your crontab without editing. Use carefully.
* * * * * command
| | | | |
| | | | day of week
| | | month
| | day of month
| hour
minute
Run every minute:
* * * * * echo "hello" >> /tmp/hello.logRun every day at 2:30 AM:
30 2 * * * /home/alex/scripts/backup.shRun every Monday at 9:00 AM:
0 9 * * 1 /home/alex/scripts/report.shRun every 15 minutes:
*/15 * * * * /home/alex/scripts/check-site.sh https://example.com- Using relative paths in cron jobs.
- Forgetting cron has a limited environment.
- Not redirecting output.
- Assuming cron ran without checking logs.
- Use absolute paths.
- Log output:
0 2 * * * /home/alex/scripts/backup.sh >> /home/alex/backup.log 2>&1- Test scripts manually before scheduling.
Cron schedules recurring jobs. Use absolute paths, explicit logging, and tested scripts.
Create a script:
mkdir -p ~/linux-practice/cron
cat > ~/linux-practice/cron/timestamp.sh <<'EOF'
#!/bin/bash
date >> "$HOME/linux-practice/cron/timestamps.log"
EOF
chmod +x ~/linux-practice/cron/timestamp.shAdd to crontab:
* * * * * /home/YOUR_USER/linux-practice/cron/timestamp.shReplace YOUR_USER with your actual username.
Estimated learning time: 60-75 minutes
Logs help you understand what happened on a system.
ls -lah /var/logCommon files:
| File | Purpose |
|---|---|
/var/log/syslog |
General system messages on Debian/Ubuntu |
/var/log/auth.log |
Authentication logs on Debian/Ubuntu |
/var/log/messages |
General logs on some RHEL-like systems |
/var/log/secure |
Auth logs on some RHEL-like systems |
/var/log/kern.log |
Kernel logs on some systems |
Show logs:
journalctlCurrent boot:
journalctl -bService logs:
journalctl -u ssh
journalctl -u nginx --since "1 hour ago"Follow logs:
journalctl -fKernel ring buffer:
dmesg
dmesg | tail
dmesg | grep -i usbsudo less /var/log/auth.log
sudo grep "sudo" /var/log/auth.logsudo less /var/log/syslog
sudo tail -f /var/log/syslog- Not checking logs when a service fails.
- Using
caton huge logs. - Forgetting logs differ between distributions.
- Use
less,tail, andjournalctl. - Filter by time and service.
- Check logs before restarting repeatedly.
Logs are essential for troubleshooting. journalctl, /var/log, and dmesg are the most important starting points.
ls -lah /var/log
journalctl -b --no-pager | tail
dmesg | tailIf available:
sudo grep "sudo" /var/log/auth.log | tailEstimated learning time: 90-120 minutes
Generate a key:
ssh-keygen -t ed25519 -C "your_email@example.com"Show public key:
cat ~/.ssh/id_ed25519.pubCopy key to server:
ssh-copy-id user@serverPrivate key permissions:
chmod 700 ~/.ssh
chmod 600 ~/.ssh/id_ed25519A firewall controls network access.
Install:
sudo apt install ufwAllow SSH:
sudo ufw allow sshEnable:
sudo ufw enableStatus:
sudo ufw status verbose
⚠️ Warning On a remote server, allow SSH before enabling the firewall or you may lock yourself out.
Fail2Ban blocks repeated suspicious login attempts.
sudo apt install fail2ban
sudo systemctl enable --now fail2ban
sudo systemctl status fail2bansudo apt update
sudo apt upgradeGive users and services only the access they need.
Examples:
chmod 600 private.conf
sudo usermod -aG developers alexUse:
- Long passwords
- Unique passwords
- Password managers
- Multi-factor authentication where available
Simple archive backup:
tar -czf backup-$(date +%Y%m%d).tar.gz ~/DocumentsRsync backup:
rsync -av --delete ~/Documents/ /mnt/backup/Documents/- Password SSH login exposed to the internet.
- Reusing passwords.
- No backups.
- Overusing root privileges.
- Ignoring security updates.
- Use SSH keys.
- Disable unused services.
- Keep software updated.
- Back up before major changes.
- Avoid
chmod 777.
Linux security starts with updates, least privilege, strong authentication, firewall rules, careful permissions, and backups.
ssh-keygen -t ed25519 -C "practice@example.com"
ls -la ~/.ssh
chmod 700 ~/.ssh
chmod 600 ~/.ssh/id_ed25519If using Ubuntu in a VM:
sudo ufw statusEstimated learning time: 60-90 minutes
| Tool | Purpose | Example |
|---|---|---|
htop |
Interactive process viewer | htop |
btop |
Modern resource monitor | btop |
ncdu |
Disk usage explorer | ncdu ~ |
tmux |
Terminal multiplexer | tmux |
screen |
Terminal session manager | screen |
fzf |
Fuzzy finder | `history |
bat |
Improved cat with highlighting |
bat file.txt |
exa / eza |
Improved ls |
eza -lah |
ripgrep |
Fast recursive search | rg "TODO" |
jq |
JSON processor | `cat data.json |
Install examples:
sudo apt install htop ncdu tmux fzf ripgrep jqFedora:
sudo dnf install htop ncdu tmux fzf ripgrep jq- Installing many tools before learning built-ins.
- Depending on aliases that are not available on servers.
- Forgetting scripts should use common portable commands when possible.
- Learn core commands first.
- Add helpful tools gradually.
- Keep your dotfiles documented.
Modern Linux tools can make the terminal more comfortable, but they work best after you understand the standard commands.
Install two tools from this section and try them:
htop
ncdu ~
rg "Linux" ~/linux-practiceEstimated learning time: 30-45 minutes
| Shortcut | Meaning | Example Use |
|---|---|---|
Ctrl+C |
Stop current command | Stop ping |
Ctrl+Z |
Suspend current command | Pause sleep 300 |
Ctrl+D |
End input or logout | Finish cat > file |
Ctrl+R |
Search command history | Find old ssh command |
Ctrl+L |
Clear screen | Clean terminal view |
Ctrl+A |
Move to start of line | Edit long command |
Ctrl+E |
Move to end of line | Edit long command |
More useful shortcuts:
| Shortcut | Meaning |
|---|---|
Alt+B |
Move backward one word |
Alt+F |
Move forward one word |
Ctrl+U |
Delete from cursor to start |
Ctrl+K |
Delete from cursor to end |
Ctrl+W |
Delete previous word |
Shortcuts make terminal use faster and less frustrating. Learn Ctrl+C, Ctrl+R, Ctrl+A, and Ctrl+E early.
- Run
ping example.com, then stop it withCtrl+C. - Type a long command and move with
Ctrl+AandCtrl+E. - Search history with
Ctrl+R.
Estimated learning time: 2-4 hours
Use these labs to combine chapters.
mkdir -p ~/linux-labs/lab1/{docs,logs,scripts}
touch ~/linux-labs/lab1/docs/readme.txt
echo "Lab started" > ~/linux-labs/lab1/logs/app.log
tree ~/linux-labs/lab1Checklist:
- Create nested folders.
- Create a file.
- Write text to a file.
- Display the folder tree.
cd ~/linux-labs/lab1
cp docs/readme.txt docs/readme-copy.txt
mv docs/readme-copy.txt docs/notes.txt
ls -lah docsChecklist:
- Copy a file.
- Rename a file.
- List the result.
printf "INFO boot\nERROR failed login\nINFO done\n" > ~/linux-labs/lab1/logs/app.log
grep -n "ERROR" ~/linux-labs/lab1/logs/app.log
find ~/linux-labs -type f -name "*.log"Checklist:
- Search by filename.
- Search by content.
- Show line numbers.
cd ~/linux-labs/lab1
echo 'echo "hello lab"' > scripts/hello.sh
chmod 755 scripts/hello.sh
scripts/hello.sh
chmod 600 logs/app.log
ls -l scripts/hello.sh logs/app.logChecklist:
- Make a script executable.
- Restrict a log file.
- Read permission output.
⚠️ Run only in a VM or lab environment.
sudo useradd -m -s /bin/bash labuser
id labuser
sudo passwd labuser
sudo userdel -r labuserChecklist:
- Create a user.
- Inspect user ID.
- Set password.
- Remove the user.
Debian/Ubuntu:
sudo apt update
sudo apt install tree htop
tree --version
htopFedora:
sudo dnf install tree htopChecklist:
- Update package metadata.
- Install software.
- Confirm command works.
mkdir -p ~/linux-labs/scripts
nano ~/linux-labs/scripts/report.shScript:
#!/bin/bash
echo "System report"
date
whoami
df -h /Run:
chmod +x ~/linux-labs/scripts/report.sh
~/linux-labs/scripts/report.shChecklist:
- Create a script.
- Make it executable.
- Run it.
cd ~/linux-labs
tar -czf lab-backup.tar.gz lab1 scripts
tar -tf lab-backup.tar.gz
mkdir restore-test
tar -xzf lab-backup.tar.gz -C restore-testChecklist:
- Create a tarball.
- List its contents.
- Extract safely.
mkdir -p ~/linux-labs/downloads
cd ~/linux-labs/downloads
curl -o example.html https://example.com
wget -O example-wget.html https://example.com
ls -lhChecklist:
- Download with
curl. - Download with
wget. - Compare file sizes.
ssh-keygen -t ed25519 -C "lab@example.com"
ssh user@server
scp file.txt user@server:/tmp/
rsync -av folder/ user@server:/tmp/folder/Checklist:
- Generate SSH key.
- Connect to a server.
- Copy a file.
- Sync a folder.
Estimated learning time: Keep for reference
| Command | Purpose | Example |
|---|---|---|
pwd |
Print current directory | pwd |
ls |
List files | ls -lah |
cd |
Change directory | cd /etc |
tree |
Show directory tree | tree -L 2 |
find |
Find files | find . -name "*.txt" |
locate |
Fast filename search | locate sshd_config |
updatedb |
Update locate database | sudo updatedb |
which |
Show command path | which bash |
whereis |
Locate binary/manual/source | whereis ls |
realpath |
Resolve absolute path | realpath file.txt |
touch |
Create/update file | touch notes.txt |
cat |
Print file | cat notes.txt |
less |
Page through file | less /var/log/syslog |
more |
Simple file pager | more file.txt |
head |
Show first lines | head -n 5 file.txt |
tail |
Show last lines | tail -f app.log |
nano |
Edit text | nano notes.txt |
vim |
Edit text | vim notes.txt |
cp |
Copy files | cp a.txt b.txt |
mv |
Move/rename files | mv old.txt new.txt |
rm |
Remove files | rm -i old.txt |
mkdir |
Create directory | mkdir -p a/b/c |
rmdir |
Remove empty directory | rmdir empty |
ln |
Create links | ln -s target link |
chmod |
Change permissions | chmod 755 script.sh |
chown |
Change owner | sudo chown alex file.txt |
chgrp |
Change group | sudo chgrp dev file.txt |
umask |
Show/set default mask | umask |
sudo |
Run as admin | sudo apt update |
su |
Switch user | su - root |
whoami |
Show current user | whoami |
id |
Show user/group IDs | id |
passwd |
Change password | passwd |
useradd |
Add user | sudo useradd -m sam |
usermod |
Modify user | sudo usermod -aG sudo sam |
userdel |
Delete user | sudo userdel -r sam |
groups |
Show groups | groups sam |
groupadd |
Add group | sudo groupadd developers |
groupdel |
Delete group | sudo groupdel developers |
grep |
Search text | grep -n "error" app.log |
rg |
Fast search text | rg "TODO" |
awk |
Process columns | awk '{print $1}' file |
sed |
Edit streams | sed 's/a/b/g' file |
cut |
Extract fields | cut -d, -f1 data.csv |
sort |
Sort lines | sort names.txt |
uniq |
Remove duplicate adjacent lines | `sort names.txt |
wc |
Count lines/words/bytes | wc -l file.txt |
tr |
Translate characters | `echo hi |
xargs |
Build args from input | `find . -name "*.log" |
tee |
Write and display output | `echo hi |
ps |
Show processes | ps aux |
top |
Process monitor | top |
htop |
Interactive process monitor | htop |
btop |
Modern resource monitor | btop |
kill |
Send signal by PID | kill 1234 |
killall |
Kill by process name | killall firefox |
pkill |
Kill by pattern | pkill -f app.py |
jobs |
List shell jobs | jobs |
bg |
Resume job in background | bg %1 |
fg |
Bring job foreground | fg %1 |
nice |
Start with priority | nice -n 10 command |
renice |
Change process priority | sudo renice -n 5 -p 1234 |
systemctl |
Manage services | systemctl status ssh |
journalctl |
View systemd logs | journalctl -u ssh |
dmesg |
Kernel messages | `dmesg |
apt |
Debian package manager | sudo apt install tree |
dnf |
Fedora/RHEL package manager | sudo dnf install tree |
yum |
Older RHEL package manager | sudo yum install tree |
pacman |
Arch package manager | sudo pacman -S tree |
zypper |
openSUSE package manager | sudo zypper install tree |
snap |
Snap packages | sudo snap install code |
flatpak |
Flatpak apps | flatpak search vlc |
ip |
Network configuration | ip addr |
ifconfig |
Older network info | ifconfig |
ping |
Test connectivity | ping -c 4 example.com |
traceroute |
Trace network route | traceroute example.com |
ss |
Socket statistics | ss -tuln |
netstat |
Older network sockets | netstat -tuln |
curl |
Transfer URLs | curl -I https://example.com |
wget |
Download files | wget https://example.com |
dig |
DNS lookup | dig example.com |
nslookup |
DNS lookup | nslookup example.com |
ssh |
Remote login | ssh user@server |
scp |
Secure copy | scp file user@server:/tmp/ |
rsync |
Sync files | rsync -av src/ dest/ |
zip |
Create zip archive | zip -r files.zip folder/ |
unzip |
Extract zip archive | unzip files.zip |
gzip |
Compress file | gzip file.log |
gunzip |
Decompress gzip | gunzip file.log.gz |
tar |
Archive files | tar -czf backup.tar.gz folder/ |
xz |
Compress with xz | xz file.img |
unxz |
Decompress xz | unxz file.img.xz |
bzip2 |
Compress with bzip2 | bzip2 file.txt |
bunzip2 |
Decompress bzip2 | bunzip2 file.txt.bz2 |
df |
Filesystem usage | df -h |
du |
Directory/file usage | du -sh . |
lsblk |
List block devices | lsblk -f |
blkid |
Show block IDs | sudo blkid |
mount |
Mount filesystem | sudo mount /dev/sdb1 /mnt |
umount |
Unmount filesystem | sudo umount /mnt |
fdisk |
Partition disks | sudo fdisk -l |
env |
Show environment | env |
printenv |
Print env variables | printenv PATH |
export |
Export variable | export EDITOR=nano |
alias |
Create shell shortcut | alias ll='ls -lah' |
history |
Show command history | history |
date |
Show date/time | date |
cal |
Show calendar | cal |
hostname |
Show/set hostname | hostname |
uname |
System/kernel info | uname -a |
uptime |
Show uptime/load | uptime |
free |
Memory usage | free -h |
lscpu |
CPU information | lscpu |
lsusb |
USB devices | lsusb |
lspci |
PCI devices | lspci |
crontab |
Manage cron jobs | crontab -l |
at |
Schedule one-time job | `echo "date" |
sleep |
Wait | sleep 5 |
watch |
Repeat command | watch df -h |
man |
Manual pages | man ls |
info |
Info documentation | info coreutils |
help |
Bash builtin help | help cd |
type |
Show command type | type cd |
file |
Identify file type | file image.png |
stat |
File metadata | stat file.txt |
basename |
Strip directory path | basename /tmp/a.txt |
dirname |
Strip filename | dirname /tmp/a.txt |
readlink |
Show symlink target | readlink link.txt |
shred |
Overwrite file data | shred -u secret.txt |
sync |
Flush filesystem buffers | sync |
clear |
Clear terminal | clear |
reset |
Reset terminal | reset |
echo |
Print text | echo "hello" |
printf |
Formatted print | printf "%s\n" hello |
read |
Read user input | read name |
test |
Evaluate expression | test -f file.txt |
[ |
Test alias | [ -f file.txt ] |
true |
Successful command | true |
false |
Failing command | false |
exit |
Exit shell/script | exit 0 |
Estimated learning time: 3-6 hours
Goal: create a small project that uses filesystem navigation, users, permissions, packages, Bash scripting, archives, downloads, logs, and services.
⚠️ Warning Do this in a VM or safe lab environment. Some steps usesudo.
You are setting up a small training server for a fictional team. You need to create project folders, add a user, configure permissions, install tools, write a report script, download sample data, archive the project, inspect logs, and manage a service.
mkdir -p ~/admin-lab/{data,logs,scripts,archives,downloads}
tree ~/admin-labChecklist:
- Created
data - Created
logs - Created
scripts - Created
archives - Created
downloads
Debian/Ubuntu:
sudo apt update
sudo apt install tree curl jq htopFedora:
sudo dnf install tree curl jq htopChecklist:
- Installed
tree - Installed
curl - Installed
jq - Installed
htop
cd ~/admin-lab/downloads
curl -o sample.json https://api.github.com/repos/torvalds/linux
jq '.name, .description, .stargazers_count' sample.jsonExpected output example:
"linux"
"Linux kernel source tree"
123456
⚠️ Use a VM or lab system.
sudo useradd -m -s /bin/bash trainee
id traineeecho "training notes" > ~/admin-lab/data/notes.txt
chmod 644 ~/admin-lab/data/notes.txt
chmod 700 ~/admin-lab/scripts
ls -ld ~/admin-lab/scripts
ls -l ~/admin-lab/data/notes.txtCreate ~/admin-lab/scripts/system-report.sh:
#!/bin/bash
set -e
report_dir="$HOME/admin-lab/logs"
report_file="$report_dir/system-report-$(date +%Y%m%d-%H%M%S).txt"
mkdir -p "$report_dir"
{
echo "System Report"
echo "Generated: $(date)"
echo "User: $(whoami)"
echo "Host: $(hostname)"
echo
echo "Disk:"
df -h /
echo
echo "Memory:"
free -h
echo
echo "Uptime:"
uptime
} > "$report_file"
echo "Report written to $report_file"Run:
chmod +x ~/admin-lab/scripts/system-report.sh
~/admin-lab/scripts/system-report.sh
ls -lh ~/admin-lab/logsjournalctl -b --no-pager | tail -n 20
dmesg | tail -n 20If available:
sudo tail -n 20 /var/log/syslogCheck cron:
systemctl status cronIf your distro uses crond:
systemctl status crondRestart it:
sudo systemctl restart cronor:
sudo systemctl restart crondcd ~
tar -czf admin-lab/archives/admin-lab-backup.tar.gz admin-lab/data admin-lab/logs admin-lab/scripts admin-lab/downloads
tar -tf admin-lab/archives/admin-lab-backup.tar.gz | headsudo userdel -r trainee- Navigated the filesystem
- Created folders and files
- Installed software
- Downloaded data
- Parsed JSON with
jq - Created a user
- Configured permissions
- Wrote a Bash script
- Generated a system report
- Inspected logs
- Managed a service
- Created a compressed archive
- What is the difference between
/homeand/root? - Why is
chmod 777usually unsafe? - When should you use
findinstead ofgrep? - What does
systemctl enabledo? - Why should cron jobs use absolute paths?
- What does
PATHcontrol? - What is the difference between
tarandgzip? - What command shows listening network ports?
- Why are SSH keys safer than password-only login?
- What does an exit code of
0usually mean?
You now have a practical foundation in Linux:
- Filesystem navigation
- File creation and editing
- Permissions and ownership
- Searching and text processing
- Redirection and pipelines
- Processes and services
- Packages and networking
- Compression and disk inspection
- Users, logs, security, Bash, cron, and scripting
The best way to keep learning is simple: use Linux regularly, build small labs, break things safely in a VM, read manual pages, and turn repeated tasks into scripts.
man ls
man find
man chmod
man bashHappy learning. 🐧