Snap packages controversial (slower startup, sandboxed), GNOME can be resource-heavy, some proprietary drivers need manual install, 6-month releases can break things, Canonical telemetry (opt-out available).
Use Cases
Desktop computing, web/app servers, cloud VMs (AWS/Azure/GCP), Docker/Kubernetes hosts, development environments, WSL2 on Windows, Raspberry Pi, CI/CD pipelines.
wsl --install # installs Ubuntu by defaultwsl --install -d Ubuntu-24.04 # specific version
Ubuntu on Cloud
# AWS: search "Ubuntu" in AMI marketplace — official Canonical AMIs# Azure: az vm create --image Ubuntu2204 ...# GCP: gcloud compute instances create ... --image-family ubuntu-2404-lts# DigitalOcean, Linode, Vultr: Ubuntu available as default droplet/instance image
Kernel & Architecture
Linux Kernel
Ubuntu runs the Linux kernel — a monolithic kernel with loadable modules.
Kernel file: /boot/vmlinuz-<version>
Ubuntu ships with the HWE (Hardware Enablement) kernel on LTS for newer hardware support.
uname -r # current kernel versionuname -a # full kernel + system infocat /proc/version # kernel version + compilerls /boot/vmlinuz* # installed kernelssudo apt install linux-generic-hwe-22.04 # install HWE kernel
Boot Process
Power On
→ BIOS/UEFI POST
→ GRUB2 bootloader (/boot/grub/grub.cfg)
→ Kernel decompresses → mounts initramfs (early root filesystem)
→ Kernel initializes hardware → mounts real root filesystem
→ systemd (PID 1) starts
→ systemd targets: sysinit → basic → multi-user / graphical
→ Login prompt (TTY or GDM display manager)
Linux File System Hierarchy (FHS)
/ Root of entire filesystem
├── /bin → Essential user binaries (ls, cp, cat) — symlink to /usr/bin in Ubuntu 20+
├── /boot → Kernel, initramfs, GRUB files
├── /dev → Device files (hardware as files)
├── /etc → System-wide configuration files
├── /home → User home directories (/home/username)
├── /lib → Shared libraries — symlink to /usr/lib in Ubuntu 20+
├── /media → Auto-mounted removable media (USB, CD)
├── /mnt → Manual temporary mount point
├── /opt → Optional/third-party software
├── /proc → Virtual fs: process & kernel info (not on disk)
├── /root → Root user home directory
├── /run → Runtime data (PIDs, sockets) — cleared on reboot
├── /sbin → System admin binaries — symlink to /usr/sbin in Ubuntu 20+
├── /snap → Snap package mount points (Ubuntu-specific)
├── /srv → Data served by system (web/FTP files)
├── /sys → Virtual fs: hardware/driver info (not on disk)
├── /tmp → Temporary files (cleared on reboot)
├── /usr → User programs, libraries, docs
│ ├── /usr/bin Most user commands
│ ├── /usr/lib Libraries
│ ├── /usr/local Locally compiled software
│ └── /usr/share Architecture-independent data
└── /var → Variable data
├── /var/log System and app logs
├── /var/cache Package and app caches
└── /var/www Web server document root
File Types
- Regular file
d Directory
l Symbolic link
c Character device (keyboard, terminal)
b Block device (hard drives, USB)
s Socket (IPC)
p Named pipe (FIFO)
Shell & Terminal
Shell Types
bash Bourne Again Shell → default Ubuntu shell, $ prompt
zsh Z Shell → popular alternative, % prompt
fish Friendly Shell → user-friendly, auto-suggestions
sh Bourne Shell → POSIX-compliant minimal shell
dash Debian Almquist → Ubuntu's /bin/sh, fast, minimal
echo $SHELL # current shellcat /etc/shells # available shellschsh -s /bin/zsh # change default shell
File & Directory Commands
pwd # print working directoryls # list filesls -la # detailed + hidden filesls -lh # human-readable sizesls -lt # sort by modification timecd /path cd ~ cd .. cd - # navigatetouch file.txt # create file / update timestamptouch file{1..5}.txt # create file1.txt through file5.txtmkdir dirname # create directorymkdir -p a/b/c # create nested directoriescp source dest # copy filecp -r src/ dest/ # copy directory recursivelycp -p source dest # preserve permissions + timestampsmv source dest # move or renamerm file.txt # delete filerm -rf dirname/ # delete directory (careful!)ln -s target linkname # create symbolic linkln target hardlink # create hard linkcat file.txt # print fileless file.txt # paginated view (q to quit)head -n 20 file.txt # first 20 linestail -n 20 file.txt # last 20 linestail -f /var/log/syslog # follow log livefile filename # show file typewc -l file.txt # count linesstat file.txt # detailed file info (size, inode, times)
Search & Find
find / -name "*.conf" # find by namefind /home -type f -size +1M # files > 1MBfind . -mtime -7 # modified in last 7 daysfind . -perm 777 # files with 777 permissionsfind . -name "*.log" -delete # find and deletelocate filename # fast search (uses updatedb database)sudo updatedb # update locate databasewhich python3 # find executable locationwhereis nginx # find binary + man page + sourcetype ls # show if alias/builtin/file
File Permissions
Format: -rwxrwxrwx (type | owner | group | others)
r=4 w=2 x=1 → 7=rwx 6=rw- 5=r-x 4=r-- 0=---
chmod 755 script.sh # owner:rwx group:r-x others:r-x
chmod 644 file.txt # owner:rw- group:r-- others:r--
chmod 600 ~/.ssh/id_rsa # owner:rw- only (SSH private key)
chmod +x script.sh # add execute for all
chmod u+x script.sh # add execute for owner only
chmod go-w file # remove write from group+others
chmod -R 755 dir/ # recursive
chown user file.txt # change owner
chown user:group file.txt # change owner and group
chown -R user:group dir/ # recursive
# Special bits
chmod u+s binary # SUID: run as file owner (e.g. passwd)
chmod g+s dir/ # SGID: new files inherit group
chmod +t /tmp # Sticky bit: only owner can delete
# ACL (fine-grained permissions)
getfacl file.txt # view ACL
setfacl -m u:username:rw file.txt # grant user rw
setfacl -x u:username file.txt # remove user ACL
Ctrl+A/E → start/end of line
Ctrl+W → delete word before cursor
Ctrl+U/K → delete to start/end of line
Ctrl+R → reverse history search
Ctrl+C → cancel command
Ctrl+Z → suspend (fg to resume, bg to background)
Ctrl+L → clear screen
Ctrl+D → logout / EOF
Tab → autocomplete
!! → repeat last command
!string → repeat last command starting with string
Alt+. → insert last argument of previous command
Process Management
Viewing Processes
ps aux # all running processesps aux | grep nginx # filter by nameps -ef --forest # process tree with parent infotop # real-time monitor (q to quit)htop # improved top (sudo apt install htop)pgrep nginx # get PID by namepstree # visual process treepstree -p # with PIDs
Controlling Processes
kill PID # SIGTERM — graceful stopkill -9 PID # SIGKILL — force killkill -HUP PID # SIGHUP — reload configkillall nginx # kill all by namepkill -f "python script.py" # kill by patterncommand & # run in backgroundCtrl+Z → bg # suspend then backgroundfg # bring to foregroundfg %2 # bring job 2 to foregroundjobs # list background jobsnohup command & # survive logoutdisown %1 # detach job from shell
System Information
uname -a # kernel + system infohostname # system hostnamehostname -I # all IP addresseswhoami # current userid # UID, GID, groupsuptime # uptime + load averagew # who is logged in + what they're doinglast # login historydf -h # disk space usagedf -hT # with filesystem typedu -sh /path # directory sizedu -sh /* 2>/dev/null | sort -rh | head -20 # top 20 largest dirsfree -h # RAM + swap usagelscpu # CPU infolsblk # block deviceslsblk -f # with filesystem typeslsusb # USB deviceslspci # PCI deviceslshw -short # hardware summarycat /proc/cpuinfo # detailed CPU infocat /proc/meminfo # detailed memory infocat /etc/os-release # Ubuntu version infolsb_release -a # Ubuntu release details
Systemd & Service Management
systemctl
systemctl start nginx # start servicesystemctl stop nginx # stop servicesystemctl restart nginx # restart servicesystemctl reload nginx # reload config (no downtime)systemctl enable nginx # start on bootsystemctl disable nginx # don't start on bootsystemctl status nginx # status + recent logssystemctl is-active nginx # active / inactivesystemctl is-enabled nginx # enabled / disabledsystemctl list-units --type=service --state=runningsystemctl list-units --type=service --state=failedsystemctl daemon-reload # reload after editing unit filessystemctl reboot # reboot systemsystemctl poweroff # shutdown
root → superuser, UID 0, full system control
sudo user → regular user with sudo privileges (Ubuntu default)
system user → no login shell, used by services (www-data, mysql, etc.)
regular user → normal login user
User Commands
adduser username # interactive: creates home dir + sets passworduseradd -m -s /bin/bash user # manual: -m=home dir, -s=shellpasswd username # set/change passwordpasswd -l username # lock accountpasswd -u username # unlock accountusermod -aG sudo username # add to sudo group (grant sudo)usermod -aG docker username # add to docker groupusermod -s /bin/zsh username # change shellusermod -d /new/home username # change home directoryuserdel username # delete user (keep home dir)userdel -r username # delete user + home dirsu - username # switch user (load their environment)sudo -i # root shellsudo -u username command # run command as another userid username # show UID, GID, groupswho # who is logged inw # who + what they're doinglast # login history
sudo visudo # safely edit /etc/sudoers# Add user to sudoers file:username ALL=(ALL:ALL) ALL# Allow without password:username ALL=(ALL) NOPASSWD: ALL# Allow specific command only:username ALL=(ALL) NOPASSWD: /usr/bin/apt
Group Commands
groupadd groupname # create groupgroupdel groupname # delete groupgroupmod -n newname oldname # rename groupusermod -aG group1,group2 user # add user to groupsgpasswd -a user group # add user to groupgpasswd -d user group # remove user from groupgroups username # show user's groupsgetent group groupname # group detailsnewgrp groupname # switch active group (current session)
ip a # all interfaces + IPsip addr show eth0 # specific interfaceip route # routing tableip route show default # default gatewayhostname -I # all IP addressescat /etc/hosts # local DNS overridescat /etc/resolv.conf # DNS serversss -tulnp # listening ports + processesss -tulnp | grep :80 # filter by portlsof -i :80 # what uses port 80netstat -tulnp # (older, needs net-tools)
Network Testing
ping -c 4 google.com # ping 4 timesping -i 0.2 google.com # fast pingtraceroute google.com # trace routemtr google.com # real-time traceroute (sudo apt install mtr)dig google.com # DNS lookupdig google.com MX # MX recordsdig google.com ANY # all recordsnslookup google.com # simple DNS lookupcurl -I https://example.com # HTTP headers onlycurl -L https://example.com # follow redirectswget https://example.com/file # download filewget -r -np https://site.com # recursive downloadnc -zv host 80 # test TCP port connectivitync -zvu host 53 # test UDP port
Network Configuration (Netplan — Ubuntu 18.04+)
ls /etc/netplan/ # netplan config filessudo nano /etc/netplan/01-netcfg.yaml
lsblk # list block deviceslsblk -f # with filesystem types + UUIDsfdisk -l # all disks and partitions (sudo)df -h # disk space usagedf -hT # with filesystem typedu -sh /path # directory sizedu -sh /* 2>/dev/null | sort -rh | head -20 # top 20 largest dirsblkid # UUIDs and filesystem types
Partitioning
sudo fdisk /dev/sdb # partition disk (MBR/GPT)sudo parted /dev/sdb # partition disk (GPT preferred)sudo parted /dev/sdb mklabel gptsudo parted /dev/sdb mkpart primary ext4 0% 100%sudo mkfs.ext4 /dev/sdb1 # format as ext4sudo mkfs.xfs /dev/sdb1 # format as XFSsudo mkfs.vfat /dev/sdb1 # format as FAT32
Mounting
sudo mount /dev/sdb1 /mnt # mount partitionsudo mount -o ro /dev/sdb1 /mnt # read-onlysudo mount -t ext4 /dev/sdb1 /mntsudo umount /mnt # unmount# Permanent mount — add to /etc/fstabsudo blkid /dev/sdb1 # get UUIDsudo nano /etc/fstab# UUID=xxxx-xxxx /mnt/data ext4 defaults 0 2sudo mount -a # test fstab without reboot
Swap
swapon --show # show swapfree -h # RAM + swap usage# Create swap filesudo fallocate -l 4G /swapfilesudo chmod 600 /swapfilesudo mkswap /swapfilesudo swapon /swapfileecho '/swapfile none swap sw 0 0' | sudo tee -a /etc/fstab# Adjust swappiness (0-100, default 60)sudo sysctl vm.swappiness=10echo 'vm.swappiness=10' | sudo tee -a /etc/sysctl.conf
LVM (Logical Volume Manager)
# Physical Volumessudo pvcreate /dev/sdb # create PVsudo pvdisplay # show PVs# Volume Groupssudo vgcreate myvg /dev/sdb # create VGsudo vgdisplay # show VGssudo vgextend myvg /dev/sdc # add disk to VG# Logical Volumessudo lvcreate -L 20G -n mylv myvg # create 20GB LVsudo lvcreate -l 100%FREE -n mylv myvg # use all free spacesudo lvdisplay # show LVssudo mkfs.ext4 /dev/myvg/mylv # format LVsudo lvextend -L +10G /dev/myvg/mylv # extend LVsudo resize2fs /dev/myvg/mylv # resize filesystem after extend
Ubuntu Desktop (GNOME)
GNOME Basics
Super key → Activities overview (search + app grid)
Super + A → App grid
Super + Tab → switch apps
Alt + Tab → switch windows of same app
Super + D → show desktop
Super + L → lock screen
Super + ←/→ → snap window left/right
Super + ↑ → maximize
Super + ↓ → restore
Ctrl + Alt + T → open terminal
Ctrl + Alt + ←/→ → switch workspaces
Super + Shift + ←/→ → move window to workspace
PrtScn → screenshot tool
GNOME Tweaks & Extensions
sudo apt install gnome-tweaks -y # GNOME Tweaks toolsudo apt install gnome-shell-extensions -y# Install extensions from: extensions.gnome.org# Popular extensions:# Dash to Dock → macOS-style dock# AppIndicator → system tray icons# Blur my Shell → blur effects# GSConnect → KDE Connect for GNOME (phone integration)
sudo apt install certbot python3-certbot-nginx -ysudo certbot --nginx -d example.com -d www.example.comsudo certbot renew --dry-run # test auto-renewal# Auto-renewal is set up automatically via systemd timersystemctl status certbot.timer
top # real-time process monitorhtop # improved top (sudo apt install htop)btop # modern resource monitor (sudo apt install btop)glances # all-in-one monitor (sudo apt install glances)iotop # disk I/O per process (sudo apt install iotop)nethogs # network usage per process (sudo apt install nethogs)iftop # network bandwidth monitor (sudo apt install iftop)vmstat 1 # virtual memory stats every 1 secondiostat -x 1 # disk I/O stats (sudo apt install sysstat)sar -u 1 5 # CPU usage 5 times every 1 second
Performance Tuning
# Check CPU governorcat /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor# Set to performance modesudo apt install cpufrequtils -ysudo cpufreq-set -g performance# Disable unnecessary servicessystemctl list-units --type=service --state=runningsudo systemctl disable bluetooth # if not needed# Adjust swappinesssudo sysctl vm.swappiness=10echo 'vm.swappiness=10' | sudo tee -a /etc/sysctl.conf# Increase file descriptor limitsecho '* soft nofile 65536' | sudo tee -a /etc/security/limits.confecho '* hard nofile 65536' | sudo tee -a /etc/security/limits.conf
Cron Jobs
crontab -e # edit current user's crontabcrontab -l # list current user's crontabsudo crontab -e # edit root's crontabcrontab -r # remove crontab# Cron syntax: minute hour day month weekday command# * * * * * command# ┬ ┬ ┬ ┬ ┬# │ │ │ │ └── weekday (0-7, 0=Sun)# │ │ │ └───── month (1-12)# │ │ └──────── day (1-31)# │ └─────────── hour (0-23)# └────────────── minute (0-59)# Examples:0 2 * * * /usr/bin/backup.sh # daily at 2:00 AM*/15 * * * * /usr/bin/check.sh # every 15 minutes0 0 * * 0 /usr/bin/weekly.sh # every Sunday midnight@reboot /usr/bin/startup.sh # on every reboot@daily /usr/bin/daily.sh # once a day# System-wide cron directoriesls /etc/cron.daily/ls /etc/cron.weekly/ls /etc/cron.monthly/ls /etc/cron.d/
Development Environment Setup
Common Dev Tools
sudo apt install build-essential git curl wget vim -ysudo apt install python3 python3-pip python3-venv -ysudo apt install nodejs npm -y# Or use nvm for Node.js version management:curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.0/install.sh | bashnvm install --ltsnvm use --lts
export MYVAR="hello" # set for current sessionecho $MYVAR # print variableprintenv # list all env varsunset MYVAR # remove variable# Permanent — add to ~/.bashrc or ~/.profileecho 'export MYVAR="hello"' >> ~/.bashrcsource ~/.bashrc# System-wide — add to /etc/environmentsudo nano /etc/environment# MYVAR="hello"