Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 

Repository files navigation

Linux Basics – Introduction to Linux

A beginner-friendly, practical Linux handbook for learning from scratch.

Linux Level Format

How To Use This Guide

  • 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.

Table Of Contents


Linux Basics

Estimated learning time: 45-60 minutes

What Is Linux?

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 -a

Expected output example:

Linux ubuntu 6.8.0-35-generic #35-Ubuntu SMP x86_64 GNU/Linux

History Of 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.

Why Linux Is Popular

  • 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.

Linux Distributions

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 Explained

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.

Kernel Vs Operating System

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 -r

Expected output:

6.8.0-35-generic

Where Linux Is Used

  • Web servers
  • Cloud platforms
  • Containers and Kubernetes
  • Android devices
  • Network routers and firewalls
  • Supercomputers
  • Cybersecurity labs
  • Developer workstations
  • IoT and embedded systems

Common Beginner Mistakes

  • Thinking Linux is only one operating system.
  • Installing an advanced distro too early.
  • Copying commands with sudo without understanding them.
  • Ignoring documentation and manual pages.

Best Practices

  • 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.

Chapter Summary

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.

Practice Lab

  • Run uname -a.
  • Find your distribution name:
cat /etc/os-release
  • Find your current shell:
echo "$SHELL"

Installing Linux

Estimated learning time: 60-90 minutes

Installation Options

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

Dual boot means installing Linux alongside another operating system, usually Windows.

Basic flow:

  1. Back up your files.
  2. Create free disk space.
  3. Create a bootable USB.
  4. Boot from USB.
  5. Choose "Install alongside" or manually partition.
  6. Install bootloader.
  7. Reboot and select OS.

⚠️ Warning Partitioning mistakes can erase data. Back up important files before dual booting.

Virtual Machine

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

WSL, or Windows Subsystem for Linux, lets Windows users run Linux command-line tools.

Install Ubuntu on WSL:

wsl --install -d Ubuntu

List 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.

Live USB

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.

Recommended Distributions

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

Installation Tips

  • 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.

Chapter Summary

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.

Practice Lab

  • Install Linux in a VM or WSL.
  • Run:
whoami
pwd
ls
cat /etc/os-release
  • Take a screenshot or note your distro version.

Linux File System

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 Purposes

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

Absolute Vs Relative Paths

An absolute path starts at /:

cd /var/log

A relative path starts from your current directory:

cd Documents

Show your current directory:

pwd

Common Beginner Mistakes

  • Confusing / with /root.
  • Editing files in /etc without a backup.
  • Storing personal files outside /home.
  • Deleting files in /var or /usr without knowing why.

Best Practices

  • Keep personal files in your home directory.
  • Use /tmp only for temporary work.
  • Back up configuration before editing:
sudo cp /etc/ssh/sshd_config /etc/ssh/sshd_config.bak

Chapter Summary

Linux organizes all files under /. System files, user files, device files, logs, applications, and temporary data each have common locations.

Practice Lab

cd /
ls
cd /etc
pwd
cd ~
mkdir -p linux-practice/filesystem
cd linux-practice/filesystem
pwd

Try reading system information:

cat /proc/cpuinfo | head
cat /proc/meminfo | head

Navigation Commands

Estimated learning time: 75-90 minutes

Command Syntax Pattern

Most commands follow this shape:

command [options] [arguments]

Example:

ls -la /etc
Part Meaning
ls Command
-la Options
/etc Argument

pwd

Purpose: print working directory.

Syntax:

pwd

Example:

pwd

Expected output:

/home/alex

Related commands: cd, realpath

ls

Purpose: list directory contents.

Syntax:

ls [options] [path]

Examples:

ls
ls -l
ls -la
ls -lh /var/log

Common 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/path

Expected error:

ls: cannot access '/missing/path': No such file or directory

cd

Purpose: change directory.

Syntax:

cd [path]

Examples:

cd /etc
cd ~
cd ..
cd -
Path Meaning
~ Your home directory
. Current directory
.. Parent directory
- Previous directory

tree

Purpose: show directories as a tree.

Install if missing:

sudo apt install tree

Examples:

tree
tree -L 2
tree -a

find

Purpose: search files and directories.

Syntax:

find [path] [expression]

Examples:

find . -name "*.txt"
find /etc -type f -name "*.conf"
find ~ -type d -name "Downloads"

locate

Purpose: quickly find files using a database.

Install:

sudo apt install plocate

Update database:

sudo updatedb

Search:

locate sshd_config

📝 Note locate may not find newly created files until its database is updated.

which

Purpose: show the path of a command that your shell would run.

which python3

Expected output:

/usr/bin/python3

whereis

Purpose: locate binary, source, and manual page files.

whereis bash

Expected output:

bash: /usr/bin/bash /usr/share/man/man1/bash.1.gz

realpath

Purpose: print the absolute resolved path.

realpath ../Documents

Best Practices

  • Use pwd often when learning.
  • Use quotes around paths with spaces:
cd "My Folder"
  • Use tab completion to avoid typos.

Chapter Summary

Navigation commands help you understand where you are, move around the filesystem, locate commands, and resolve paths.

Practice Lab

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 beta

Working With Files

Estimated learning time: 90-120 minutes

touch

Purpose: create an empty file or update a timestamp.

touch notes.txt
ls -l notes.txt

cat

Purpose: print or concatenate files.

cat notes.txt
cat file1.txt file2.txt

Create a small file:

cat > hello.txt
Hello Linux
Press Ctrl+D when done

less

Purpose: view files page by page.

less /var/log/syslog

Useful keys:

Key Action
Space Next page
b Previous page
/text Search
q Quit

more

Purpose: simple pager.

more /etc/services

💡 Tip Prefer less for most reading because it has better navigation.

head

Purpose: show beginning of a file.

head /etc/passwd
head -n 5 /etc/passwd

tail

Purpose: show end of a file.

tail /etc/passwd
tail -n 20 /var/log/syslog
tail -f /var/log/syslog

nano

Purpose: beginner-friendly terminal text editor.

nano notes.txt

Useful keys:

Key Action
Ctrl+O Save
Enter Confirm filename
Ctrl+X Exit
Ctrl+W Search

vim

Purpose: powerful modal terminal editor.

Open file:

vim notes.txt

Basic 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. Press Esc, type :q, then press Enter to quit.

cp

Purpose: copy files and directories.

cp notes.txt notes-backup.txt
cp -r project project-backup
cp -i notes.txt notes-backup.txt

Options:

Option Meaning
-r Recursive copy
-i Ask before overwrite
-v Verbose
-p Preserve mode, ownership, timestamps

mv

Purpose: move or rename files.

mv old.txt new.txt
mv new.txt ~/Documents/
mv -i file.txt existing.txt

rm

Purpose: remove files or directories.

rm old.txt
rm -i old.txt
rm -r old-folder

⚠️ Warning rm does not move files to a recycle bin. Be extra careful with rm -r and never run destructive commands from unknown sources.

mkdir

Purpose: create directories.

mkdir projects
mkdir -p projects/linux/scripts

rmdir

Purpose: remove empty directories.

rmdir empty-folder

ln

Purpose: create links.

Hard link:

ln original.txt hard-link.txt

Symbolic 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.

Common Beginner Mistakes

  • Running rm -r in the wrong directory.
  • Forgetting -r when copying directories.
  • Overwriting files with cp or mv.
  • Using cat on huge files instead of less.

Best Practices

  • Use -i while learning:
cp -i source.txt destination.txt
mv -i old.txt new.txt
rm -i file.txt
  • Make backups before editing config files.
  • Use less for large files.

Chapter Summary

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.

Practice Lab

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 -la

Permissions

Estimated learning time: 90-120 minutes

Linux permissions control who can read, write, or execute files.

Permission Characters

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

Users, Groups, Others

Linux permission sets apply to:

Class Meaning
User File owner
Group Users in the file's group
Others Everyone else

Example:

ls -l script.sh

Expected 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

chmod

Purpose: change permissions.

Symbolic examples:

chmod u+x script.sh
chmod g-w report.txt
chmod o-r private.txt
chmod a+r README.md

Numeric examples:

chmod 644 README.md
chmod 755 script.sh
chmod 700 private-folder

Numeric Permissions

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 Avoid chmod 777. It allows every user to read, write, and execute. On shared systems, this can expose data, allow accidental deletion, or enable malicious modification.

chown

Purpose: change owner and optionally group.

sudo chown alex file.txt
sudo chown alex:developers project/
sudo chown -R alex:developers project/

chgrp

Purpose: change group ownership.

sudo chgrp developers report.txt

umask

Purpose: set default permission mask for new files and directories.

Show current umask:

umask

Common default:

0022

This usually creates:

  • Files as 644
  • Directories as 755

sudo

Purpose: run a command with elevated privileges.

sudo apt update
sudo systemctl restart ssh

⚠️ Warning sudo means "do this with administrator-level power." Read the command carefully first.

Common Beginner Mistakes

  • Using sudo for everything.
  • Running chmod -R 777.
  • Making private SSH keys too permissive.
  • Forgetting that directory x permission controls traversal.

Best Practices

  • Use least privilege.
  • Use 644 for ordinary files and 755 for ordinary directories.
  • Use 600 or 400 for private secrets.
  • Avoid recursive permission changes unless necessary.

Chapter Summary

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.

Practice Lab

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.sh

File Searching

Estimated learning time: 75-90 minutes

find

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 -100k

Search by date:

find . -type f -mtime -7
find . -type f -mtime +30

Search by permissions:

find . -type f -perm 777
find . -type f -perm /u=x

Run a command on matches:

find . -type f -name "*.tmp" -print

locate

locate nginx.conf
locate "*.service"

grep

Purpose: search text content.

grep "error" app.log
grep -i "error" app.log
grep -R "TODO" .
grep -n "main" script.sh

Options:

Option Meaning
-i Ignore case
-n Show line numbers
-R Recursive
-v Invert match
-E Extended regular expressions

ripgrep

Command: rg

Purpose: fast recursive text search.

Install:

sudo apt install ripgrep

Examples:

rg "error"
rg -n "TODO" .
rg -i "failed" /var/log
rg --files
rg --files -g "*.md"

Common Beginner Mistakes

  • Searching the whole filesystem when home directory is enough.
  • Forgetting quotes around patterns with spaces.
  • Confusing filename search with content search.

Best Practices

  • Use find for file metadata.
  • Use grep or rg for file contents.
  • Prefer rg in code projects when available.

Chapter Summary

Use find and locate to discover files by path or metadata. Use grep and rg to search inside files.

Practice Lab

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" .

Text Processing

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
EOF

grep

grep "blue" people.csv
grep -v "red" people.csv

awk

Purpose: process columns and records.

Print first column:

awk -F, '{print $1}' people.csv

Print names and scores:

awk -F, 'NR > 1 {print $1, $3}' people.csv

sed

Purpose: stream editing.

Replace text:

sed 's/blue/green/g' people.csv

Print lines 2-3:

sed -n '2,3p' people.csv

cut

Purpose: extract fields.

cut -d, -f1 people.csv
cut -d, -f1,3 people.csv

sort

sort people.csv
sort -t, -k3 -n people.csv

uniq

cut -d, -f2 people.csv | sort | uniq
cut -d, -f2 people.csv | sort | uniq -c

wc

wc people.csv
wc -l people.csv
wc -w people.csv
wc -c people.csv

tr

echo "hello" | tr 'a-z' 'A-Z'
echo "a,b,c" | tr ',' '\n'

xargs

Purpose: build command arguments from input.

printf "one\ntwo\nthree\n" | xargs echo

Find 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

Common Beginner Mistakes

  • Parsing complex formats with simple tools when a structured parser is better.
  • Forgetting sort before uniq.
  • Using xargs unsafely with filenames containing spaces.

Best Practices

  • Build pipelines step by step.
  • Test on sample data first.
  • Use awk -F, for simple CSV only; real CSV can contain quoted commas.

Chapter Summary

Linux text tools can filter, transform, count, sort, and summarize data. Pipelines let small tools work together.

Practice Lab

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.log

Redirection

Estimated learning time: 60-75 minutes

Redirection controls where input and output go.

Operators

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.txt

<

wc -l < notes.txt

<<

cat > todo.txt <<'EOF'
Learn pwd
Learn ls
Learn cd
EOF

|

cat /etc/passwd | head
ps aux | grep ssh

tee

echo "hello" | tee output.txt
echo "another line" | tee -a output.txt

Use with sudo:

echo "example" | sudo tee /etc/example.conf

Common Beginner Mistakes

  • Accidentally overwriting a file with >.
  • Forgetting -a with tee when appending.
  • Building very long pipelines without testing each step.

Best Practices

  • Use >> when preserving existing content matters.
  • Use tee when you want to see and save output.
  • Break pipelines into pieces while learning.

Chapter Summary

Redirection and pipes make Linux commands powerful. They let you save output, append data, read from files, and combine commands.

Practice Lab

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.txt

Processes

Estimated learning time: 75-90 minutes

A process is a running program.

ps

ps
ps aux
ps aux | grep ssh

top

top

Keys:

Key Action
q Quit
P Sort by CPU
M Sort by memory

htop

Install:

sudo apt install htop

Run:

htop

kill

Purpose: send a signal to a process by PID.

kill 1234
kill -9 1234

⚠️ Warning kill -9 forcefully terminates a process. Try normal kill first.

killall

killall firefox

pkill

pkill -f "python app.py"

jobs, bg, fg

Start a long command:

sleep 300

Press Ctrl+Z, then:

jobs
bg %1
fg %1

nice And renice

Start with lower priority:

nice -n 10 long-command

Change priority:

sudo renice -n 5 -p 1234

Common Beginner Mistakes

  • Killing the wrong PID.
  • Using kill -9 too quickly.
  • Forgetting background jobs are still running.

Best Practices

  • Inspect with ps, top, or htop before killing.
  • Try graceful termination first.
  • Use service management for system services instead of killing random processes.

Chapter Summary

Processes are running programs. Linux provides tools to inspect, pause, resume, prioritize, and terminate them.

Practice Lab

sleep 120 &
jobs
ps
kill %1
jobs

Package Managers

Estimated learning time: 75-90 minutes

Package managers install, update, remove, and search software from trusted repositories.

Package Manager Overview

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

APT

sudo apt update
sudo apt upgrade
sudo apt install tree
sudo apt remove tree
apt search nginx
apt show nginx

DNF

sudo dnf check-update
sudo dnf upgrade
sudo dnf install tree
sudo dnf remove tree
dnf search nginx
dnf info nginx

YUM

sudo yum update
sudo yum install tree
sudo yum remove tree
yum search nginx

Pacman

sudo pacman -Syu
sudo pacman -S tree
sudo pacman -R tree
pacman -Ss nginx
pacman -Qi bash

Zypper

sudo zypper refresh
sudo zypper update
sudo zypper install tree
sudo zypper remove tree
zypper search nginx

Snap

sudo snap install hello-world
snap list
sudo snap remove hello-world
snap find code

Flatpak

flatpak search vlc
flatpak install flathub org.videolan.VLC
flatpak run org.videolan.VLC
flatpak uninstall org.videolan.VLC

Common Beginner Mistakes

  • Mixing package sources without understanding them.
  • Skipping updates for months.
  • Running random install scripts from the internet.
  • Confusing package names with command names.

Best Practices

  • Prefer official repositories.
  • Update package indexes before installing with APT.
  • Read package details before installing unfamiliar tools.
  • Remove software you no longer use.

Chapter Summary

Package managers are the safest normal way to install software on Linux. Use the one designed for your distribution.

Practice Lab

Install tree using your distro's package manager, then run:

tree --version

Search for nginx with your package manager without installing it.


Networking

Estimated learning time: 90-120 minutes

ip

Show addresses:

ip addr

Show routes:

ip route

ifconfig

Older networking command, often not installed by default.

ifconfig

Install on Debian/Ubuntu:

sudo apt install net-tools

ping

ping example.com
ping -c 4 example.com

traceroute

traceroute example.com

Install if missing:

sudo apt install traceroute

ss

Show listening ports:

ss -tuln

Show TCP connections:

ss -tan

netstat

Older alternative:

netstat -tuln

curl

curl https://example.com
curl -I https://example.com
curl -o page.html https://example.com

wget

wget https://example.com
wget -O page.html https://example.com

dig

dig example.com
dig example.com A
dig example.com MX

nslookup

nslookup example.com

ssh

ssh user@server.example.com
ssh -p 2222 user@server.example.com

scp

scp file.txt user@server:/home/user/
scp user@server:/var/log/app.log .

rsync

rsync -av project/ backup/
rsync -avz project/ user@server:/home/user/project/

Common Beginner Mistakes

  • Using ifconfig on systems where ip is preferred.
  • Leaving SSH open with weak passwords.
  • Confusing local and remote paths in scp.
  • Downloading files without checking the URL.

Best Practices

  • Prefer ip and ss on modern Linux.
  • Use SSH keys instead of passwords.
  • Use rsync for repeat transfers.
  • Check listening ports regularly on servers.

Chapter Summary

Linux networking tools help inspect interfaces, test connectivity, resolve DNS, download files, connect remotely, and transfer data.

Practice Lab

ip addr
ip route
ping -c 4 example.com
curl -I https://example.com
ss -tuln

Compression

Estimated learning time: 60-75 minutes

zip And unzip

zip archive.zip file1.txt file2.txt
zip -r project.zip project/
unzip archive.zip
unzip archive.zip -d extracted/

gzip And gunzip

gzip app.log
gunzip app.log.gz

tar

Create archive:

tar -cf files.tar file1.txt file2.txt

Extract archive:

tar -xf files.tar

Create gzip-compressed tarball:

tar -czf project.tar.gz project/

Extract gzip-compressed tarball:

tar -xzf project.tar.gz

List archive contents:

tar -tf project.tar.gz

xz

xz largefile
unxz largefile.xz
tar -cJf project.tar.xz project/
tar -xJf project.tar.xz

bzip2

bzip2 file.txt
bunzip2 file.txt.bz2
tar -cjf project.tar.bz2 project/
tar -xjf project.tar.bz2

Common Beginner Mistakes

  • Confusing archiving with compression.
  • Extracting archives in the wrong directory.
  • Forgetting -z, -J, or -j with compressed tar files.

Best Practices

  • 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 extracted

Chapter Summary

Archives group files together. Compression reduces size. tar.gz is one of the most common Linux archive formats.

Practice Lab

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 extracted

Disk Management

Estimated learning time: 75-90 minutes

df

Purpose: show filesystem disk usage.

df -h
df -h /

du

Purpose: show file and directory sizes.

du -sh .
du -h --max-depth=1

lsblk

lsblk
lsblk -f

blkid

sudo blkid

mount

mount
sudo mount /dev/sdb1 /mnt

umount

sudo umount /mnt

fdisk

Inspect disks:

sudo fdisk -l

Edit 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.

Common Beginner Mistakes

  • Confusing /dev/sda and /dev/sdb.
  • Unmounting the wrong filesystem.
  • Running partition commands on the system disk accidentally.

Best Practices

  • Use lsblk -f before mounting or formatting.
  • Back up data before partitioning.
  • Prefer graphical disk tools while learning if available.

Chapter Summary

Disk tools show storage usage, block devices, partitions, filesystems, and mount points. Treat partitioning commands with caution.

Practice Lab

df -h
du -sh ~
lsblk
lsblk -f

Users

Estimated learning time: 75-90 minutes

whoami

whoami

id

id
id username

passwd

Change your password:

passwd

Change another user's password:

sudo passwd username

useradd

Create user:

sudo useradd -m student

Create user with shell:

sudo useradd -m -s /bin/bash student

usermod

Add user to group:

sudo usermod -aG sudo student

Change shell:

sudo usermod -s /bin/bash student

userdel

Delete user:

sudo userdel student

Delete user and home directory:

sudo userdel -r student

groups

groups
groups student

Common Beginner Mistakes

  • Forgetting -m when creating a user.
  • Forgetting -a with usermod -aG, which can replace group membership.
  • Deleting a user before backing up their home directory.

Best Practices

  • Use named users instead of sharing one account.
  • Grant admin privileges only when needed.
  • Lock or remove unused accounts.

Chapter Summary

Linux is a multi-user system. User and group commands manage identity, access, shells, passwords, and administrative privileges.

Practice Lab

⚠️ 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 student

Services

Estimated learning time: 60-75 minutes

Most modern Linux systems use systemd. The main command is systemctl.

systemctl status

systemctl status ssh
systemctl status nginx

Start, Stop, Restart

sudo systemctl start nginx
sudo systemctl stop nginx
sudo systemctl restart nginx

Enable And Disable

Enable at boot:

sudo systemctl enable nginx

Disable at boot:

sudo systemctl disable nginx

Enable and start now:

sudo systemctl enable --now nginx

List Services

systemctl list-units --type=service
systemctl list-unit-files --type=service

Common Beginner Mistakes

  • Starting a service without enabling it for boot.
  • Enabling a service without starting it now.
  • Managing services by killing processes instead of using systemctl.

Best Practices

  • Check status after changes.
  • Read logs if a service fails:
journalctl -u nginx --no-pager

Chapter Summary

systemctl manages services: start, stop, restart, enable, disable, and inspect status.

Practice Lab

If cron is available:

systemctl status cron
sudo systemctl restart cron
systemctl status cron

On some distributions, use:

systemctl status crond

Environment Variables

Estimated learning time: 45-60 minutes

Environment variables store configuration values available to the shell and processes.

Common Variables

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"

export

Create shell variable:

EDITOR=nano

Export environment variable:

export EDITOR=nano

Use it:

echo "$EDITOR"

env

env
env | sort

printenv

printenv
printenv PATH

PATH Example

mkdir -p ~/bin
export PATH="$HOME/bin:$PATH"

To make it persistent, add it to ~/.bashrc:

echo 'export PATH="$HOME/bin:$PATH"' >> ~/.bashrc
source ~/.bashrc

Common Beginner Mistakes

  • Forgetting $ when reading a variable.
  • Adding broken entries to PATH.
  • Editing shell config files without opening a new shell or using source.

Best Practices

  • Quote variable expansions:
echo "$HOME"
  • Put personal scripts in ~/bin or ~/.local/bin.
  • Avoid storing secrets in shell history.

Chapter Summary

Environment variables configure shells and programs. PATH is especially important because it controls where Linux looks for commands.

Practice Lab

echo "$HOME"
echo "$USER"
printenv SHELL
export FAVORITE_OS=Linux
echo "$FAVORITE_OS"

Bash Basics

Estimated learning time: 75-90 minutes

Bash is a common Linux shell. It reads commands, expands variables, runs programs, and supports scripting.

Variables

name="Alex"
echo "Hello, $name"

No spaces around =:

city="Prague"

Functions

greet() {
  echo "Hello, $1"
}

greet "Linux learner"

Aliases

alias ll='ls -lah'
ll

Make persistent:

echo "alias ll='ls -lah'" >> ~/.bashrc
source ~/.bashrc

History

history
history | grep ssh

Run previous command:

!!

Tab Completion

Type part of a command or path, then press Tab.

Example:

cd ~/Doc<Tab>

Common Beginner Mistakes

  • Writing name = Alex instead of name="Alex".
  • Forgetting quotes around variables.
  • Making aliases that hide important command behavior.

Best Practices

  • Use meaningful variable names.
  • Keep aliases simple.
  • Learn shell history search with Ctrl+R.

Chapter Summary

Bash lets you run commands interactively and build reusable shortcuts with variables, aliases, functions, history, and completion.

Practice Lab

mkdir -p ~/linux-practice/bash
cd ~/linux-practice/bash
name="Student"
echo "Welcome, $name"
alias today='date'
today
history | tail

Bash Scripting

Estimated learning time: 2-3 hours

A Bash script is a file containing shell commands.

Script Header

#!/bin/bash

This is called a shebang. It tells Linux which interpreter to use.

First Script

Create hello.sh:

nano hello.sh

Content:

#!/bin/bash

echo "Hello from Bash"

Run:

chmod +x hello.sh
./hello.sh

Expected output:

Hello from Bash

Variables

#!/bin/bash

name="Alex"
echo "Hello, $name"

Arguments

#!/bin/bash

echo "Script name: $0"
echo "First argument: $1"
echo "All arguments: $@"

Run:

./args.sh one two three

if

#!/bin/bash

if [ -f "$1" ]; then
  echo "File exists: $1"
else
  echo "File not found: $1"
fi

case

#!/bin/bash

case "$1" in
  start)
    echo "Starting"
    ;;
  stop)
    echo "Stopping"
    ;;
  *)
    echo "Usage: $0 {start|stop}"
    exit 1
    ;;
esac

for

#!/bin/bash

for file in *.txt; do
  echo "Found text file: $file"
done

while

#!/bin/bash

count=1

while [ "$count" -le 5 ]; do
  echo "Count: $count"
  count=$((count + 1))
done

Functions

#!/bin/bash

log() {
  echo "[$(date +%F_%T)] $1"
}

log "Script started"

Exit Codes

Linux commands return exit codes:

Code Meaning
0 Success
Non-zero Error or special condition

Check previous command:

echo "$?"

Exit manually:

exit 1

Beginner-Friendly Script: Backup Folder

backup-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 ~/backups

Beginner-Friendly Script: Disk Report

disk-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 | tail

Beginner-Friendly Script: Website Check

check-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

Common Beginner Mistakes

  • Forgetting chmod +x.
  • Running a script from the wrong directory.
  • Not quoting variables.
  • Ignoring exit codes.
  • Using Bash-specific features with /bin/sh.

Best Practices

  • Start scripts with #!/bin/bash.
  • Use set -e for simple scripts where stopping on error is desired.
  • Quote variables: "$file".
  • Validate arguments.
  • Print helpful usage messages.

Chapter Summary

Bash scripts automate repeated tasks. Start small, validate inputs, quote variables, and check errors.

Practice Lab

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 Sam

Cron Jobs

Estimated learning time: 45-60 minutes

Cron runs scheduled commands.

crontab

Edit current user's cron jobs:

crontab -e

List jobs:

crontab -l

Remove all current user's jobs:

crontab -r

⚠️ Warning crontab -r removes your crontab without editing. Use carefully.

Cron Format

* * * * * command
| | | | |
| | | | day of week
| | | month
| | day of month
| hour
minute

Examples

Run every minute:

* * * * * echo "hello" >> /tmp/hello.log

Run every day at 2:30 AM:

30 2 * * * /home/alex/scripts/backup.sh

Run every Monday at 9:00 AM:

0 9 * * 1 /home/alex/scripts/report.sh

Run every 15 minutes:

*/15 * * * * /home/alex/scripts/check-site.sh https://example.com

Common Beginner Mistakes

  • Using relative paths in cron jobs.
  • Forgetting cron has a limited environment.
  • Not redirecting output.
  • Assuming cron ran without checking logs.

Best Practices

  • Use absolute paths.
  • Log output:
0 2 * * * /home/alex/scripts/backup.sh >> /home/alex/backup.log 2>&1
  • Test scripts manually before scheduling.

Chapter Summary

Cron schedules recurring jobs. Use absolute paths, explicit logging, and tested scripts.

Practice Lab

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.sh

Add to crontab:

* * * * * /home/YOUR_USER/linux-practice/cron/timestamp.sh

Replace YOUR_USER with your actual username.


Logs

Estimated learning time: 60-75 minutes

Logs help you understand what happened on a system.

/var/log

ls -lah /var/log

Common 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

journalctl

Show logs:

journalctl

Current boot:

journalctl -b

Service logs:

journalctl -u ssh
journalctl -u nginx --since "1 hour ago"

Follow logs:

journalctl -f

dmesg

Kernel ring buffer:

dmesg
dmesg | tail
dmesg | grep -i usb

auth.log

sudo less /var/log/auth.log
sudo grep "sudo" /var/log/auth.log

syslog

sudo less /var/log/syslog
sudo tail -f /var/log/syslog

Common Beginner Mistakes

  • Not checking logs when a service fails.
  • Using cat on huge logs.
  • Forgetting logs differ between distributions.

Best Practices

  • Use less, tail, and journalctl.
  • Filter by time and service.
  • Check logs before restarting repeatedly.

Chapter Summary

Logs are essential for troubleshooting. journalctl, /var/log, and dmesg are the most important starting points.

Practice Lab

ls -lah /var/log
journalctl -b --no-pager | tail
dmesg | tail

If available:

sudo grep "sudo" /var/log/auth.log | tail

Security Basics

Estimated learning time: 90-120 minutes

SSH Keys

Generate a key:

ssh-keygen -t ed25519 -C "your_email@example.com"

Show public key:

cat ~/.ssh/id_ed25519.pub

Copy key to server:

ssh-copy-id user@server

Private key permissions:

chmod 700 ~/.ssh
chmod 600 ~/.ssh/id_ed25519

Firewall

A firewall controls network access.

UFW

Install:

sudo apt install ufw

Allow SSH:

sudo ufw allow ssh

Enable:

sudo ufw enable

Status:

sudo ufw status verbose

⚠️ Warning On a remote server, allow SSH before enabling the firewall or you may lock yourself out.

Fail2Ban

Fail2Ban blocks repeated suspicious login attempts.

sudo apt install fail2ban
sudo systemctl enable --now fail2ban
sudo systemctl status fail2ban

Updates

sudo apt update
sudo apt upgrade

Least Privilege

Give users and services only the access they need.

Examples:

chmod 600 private.conf
sudo usermod -aG developers alex

Strong Passwords

Use:

  • Long passwords
  • Unique passwords
  • Password managers
  • Multi-factor authentication where available

Backups

Simple archive backup:

tar -czf backup-$(date +%Y%m%d).tar.gz ~/Documents

Rsync backup:

rsync -av --delete ~/Documents/ /mnt/backup/Documents/

Common Beginner Mistakes

  • Password SSH login exposed to the internet.
  • Reusing passwords.
  • No backups.
  • Overusing root privileges.
  • Ignoring security updates.

Best Practices

  • Use SSH keys.
  • Disable unused services.
  • Keep software updated.
  • Back up before major changes.
  • Avoid chmod 777.

Chapter Summary

Linux security starts with updates, least privilege, strong authentication, firewall rules, careful permissions, and backups.

Practice Lab

ssh-keygen -t ed25519 -C "practice@example.com"
ls -la ~/.ssh
chmod 700 ~/.ssh
chmod 600 ~/.ssh/id_ed25519

If using Ubuntu in a VM:

sudo ufw status

Useful Linux Tools

Estimated 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 jq

Fedora:

sudo dnf install htop ncdu tmux fzf ripgrep jq

Common Beginner Mistakes

  • 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.

Best Practices

  • Learn core commands first.
  • Add helpful tools gradually.
  • Keep your dotfiles documented.

Chapter Summary

Modern Linux tools can make the terminal more comfortable, but they work best after you understand the standard commands.

Practice Lab

Install two tools from this section and try them:

htop
ncdu ~
rg "Linux" ~/linux-practice

Keyboard Shortcuts

Estimated 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

Chapter Summary

Shortcuts make terminal use faster and less frustrating. Learn Ctrl+C, Ctrl+R, Ctrl+A, and Ctrl+E early.

Practice Lab

  • Run ping example.com, then stop it with Ctrl+C.
  • Type a long command and move with Ctrl+A and Ctrl+E.
  • Search history with Ctrl+R.

Practice Exercises

Estimated learning time: 2-4 hours

Use these labs to combine chapters.

Lab 1: Create Folders And Files

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/lab1

Checklist:

  • Create nested folders.
  • Create a file.
  • Write text to a file.
  • Display the folder tree.

Lab 2: Move And Copy Files

cd ~/linux-labs/lab1
cp docs/readme.txt docs/readme-copy.txt
mv docs/readme-copy.txt docs/notes.txt
ls -lah docs

Checklist:

  • Copy a file.
  • Rename a file.
  • List the result.

Lab 3: Search Logs

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.

Lab 4: Change Permissions

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.log

Checklist:

  • Make a script executable.
  • Restrict a log file.
  • Read permission output.

Lab 5: Create Users

⚠️ Run only in a VM or lab environment.

sudo useradd -m -s /bin/bash labuser
id labuser
sudo passwd labuser
sudo userdel -r labuser

Checklist:

  • Create a user.
  • Inspect user ID.
  • Set password.
  • Remove the user.

Lab 6: Install Software

Debian/Ubuntu:

sudo apt update
sudo apt install tree htop
tree --version
htop

Fedora:

sudo dnf install tree htop

Checklist:

  • Update package metadata.
  • Install software.
  • Confirm command works.

Lab 7: Write Scripts

mkdir -p ~/linux-labs/scripts
nano ~/linux-labs/scripts/report.sh

Script:

#!/bin/bash

echo "System report"
date
whoami
df -h /

Run:

chmod +x ~/linux-labs/scripts/report.sh
~/linux-labs/scripts/report.sh

Checklist:

  • Create a script.
  • Make it executable.
  • Run it.

Lab 8: Archive Files

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-test

Checklist:

  • Create a tarball.
  • List its contents.
  • Extract safely.

Lab 9: Download Files

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 -lh

Checklist:

  • Download with curl.
  • Download with wget.
  • Compare file sizes.

Lab 10: Connect Via SSH

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.

Linux Cheat Sheet

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

Final Project

Estimated learning time: 3-6 hours

Project: Build A Mini Linux Admin Lab

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 use sudo.

Scenario

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.

Step 1: Create Project Structure

mkdir -p ~/admin-lab/{data,logs,scripts,archives,downloads}
tree ~/admin-lab

Checklist:

  • Created data
  • Created logs
  • Created scripts
  • Created archives
  • Created downloads

Step 2: Install Software

Debian/Ubuntu:

sudo apt update
sudo apt install tree curl jq htop

Fedora:

sudo dnf install tree curl jq htop

Checklist:

  • Installed tree
  • Installed curl
  • Installed jq
  • Installed htop

Step 3: Download Data

cd ~/admin-lab/downloads
curl -o sample.json https://api.github.com/repos/torvalds/linux
jq '.name, .description, .stargazers_count' sample.json

Expected output example:

"linux"
"Linux kernel source tree"
123456

Step 4: Create A User

⚠️ Use a VM or lab system.

sudo useradd -m -s /bin/bash trainee
id trainee

Step 5: Configure Permissions

echo "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.txt

Step 6: Write A Bash Script

Create ~/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/logs

Step 7: Inspect Logs

journalctl -b --no-pager | tail -n 20
dmesg | tail -n 20

If available:

sudo tail -n 20 /var/log/syslog

Step 8: Manage A Service

Check cron:

systemctl status cron

If your distro uses crond:

systemctl status crond

Restart it:

sudo systemctl restart cron

or:

sudo systemctl restart crond

Step 9: Archive Files

cd ~
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 | head

Step 10: Clean Up Lab User

sudo userdel -r trainee

Final Project Checklist

  • 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

Final Review Questions

  1. What is the difference between /home and /root?
  2. Why is chmod 777 usually unsafe?
  3. When should you use find instead of grep?
  4. What does systemctl enable do?
  5. Why should cron jobs use absolute paths?
  6. What does PATH control?
  7. What is the difference between tar and gzip?
  8. What command shows listening network ports?
  9. Why are SSH keys safer than password-only login?
  10. What does an exit code of 0 usually mean?

Closing Summary

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 bash

Happy learning. 🐧

About

A comprehensive beginner-friendly Linux Basics guide covering terminal commands, file system navigation, permissions, Bash scripting, networking, package management, security, and hands-on exercises. Perfect for students, developers, and anyone starting their Linux journey.

Topics

Resources

Stars

1 star

Watchers

0 watching

Forks

Contributors