The Linux commands most people use every day are pwd, ls, cd, cp, mv, rm, mkdir, cat, less, grep, find, sudo, nano and systemctl, with man for help. Below are the 100 most useful Linux commands, each with a working example, grouped by job from the basic Linux commands to the ones administrators use daily, with the macOS differences and the nearest IBM i (AS/400) command marked. Most of them also work as Unix commands on macOS, AIX and the BSDs. The same guide covers how Linux, Unix and macOS relate, how a Linux system fits together, editing files in nano and vim, and Git from first set-up to your first pull request.
By Linda Garrould · Updated 1 November 2026 · Covers Ubuntu, Debian, Fedora and the Red Hat family, with macOS differences marked
I first used Unix at college. My first job was at a company replacing its Unix system with an IBM System/36, later upgraded to an AS/400, and I saw DOS give way to Windows along the way. These days most of the systems I manage are Unix based, so technology has come full circle. This page started as my own notebook while I got back up to speed. It is now a complete rewrite: modern commands where the old ones have been replaced, warnings where a command can hurt you, and a free printable version to keep beside the keyboard.
Key takeaways
- Learn ten commands first:
pwd,ls,cd,cp,mv,rm,mkdir,cat,lessandman. Everything else builds on them. - Modern Linux has replaced several classics: use
ipnotifconfig,ssnotnetstat, andsystemctlandjournalctlfor services and logs. - macOS is Unix underneath but uses BSD tools, so some flags differ (
sed -i ''is the one that catches everyone). - If you know IBM i, you already know the ideas (see the AS/400 cross-reference): WRKACTJOB is
top, DSPLOG isjournalctl, SBMJOB isnohupand WRKJOBSCDE iscron. - In Git,
git revertis the safe way to undo anything already shared;git resetis only for commits nobody else has.

Free download: the Ultimate Linux Cheat Sheet (A5 PDF)
The essentials of this page, laid out as a 36-page A5 mini-ebook you can print or read on screen: the 100 commands, the shell shortcuts, Linux vs Unix vs macOS, the AS/400 cross-reference, vim and nano keys, and Git from set-up to pull request.
Download the PDF (36 pages, free, no sign-up)Edition 1 · November 2026. Print at A5, or two pages to a sheet of A4. Free to print and share for non-commercial use, including in schools, colleges and user groups, under the CC BY-NC-ND 4.0 licence: credit IT Management 101, don’t sell it and don’t share altered versions. The QR code inside brings you back here for the latest edition.
Get an email when we update it. We will let you know when a new edition is out, plus the occasional practical IT guide. Unsubscribe any time.
Before you start: the terminal in five minutes
The terminal (or shell) is a text window where you type a command and press Enter. On a desktop, open Terminal from the applications menu (Ctrl+Alt+T on Ubuntu). On a server you usually connect with ssh from your own computer (SSH, Secure Shell, is the encrypted way to log in remotely): Windows 10 and 11 include an OpenSSH client, so ssh priya@server.example.com works from PowerShell, and macOS has had it in Terminal for years.
The prompt tells you who and where you are. In priya@web01:~$, priya is the user, web01 is the machine, ~ is the current directory (your home directory) and $ means an ordinary user. A # instead of $ means you are root, the all-powerful superuser, so slow down.
Almost every command follows the same pattern: the command, then options that change how it behaves (a dash and a letter, or two dashes and a word), then the things it should act on, called arguments.
Three ways to get help without leaving the terminal: man ls opens the full manual, ls --help prints a short summary, and apropos disk searches every manual for a keyword. Commands are case-sensitive: ls works, LS does not.
Bash keyboard shortcuts
| Keys | What they do |
|---|---|
Tab | Complete a command or file name; press twice to see options |
↑ / ↓ | Step through previous commands |
Ctrl+R | Search your command history as you type |
Ctrl+C | Stop the running command |
Ctrl+Z | Pause it (then bg or fg) |
Ctrl+D | End input; at an empty prompt, log out |
Ctrl+A / Ctrl+E | Jump to the start / end of the line |
Ctrl+U | Delete from the cursor back to the start of the line |
Ctrl+L | Clear the screen |
!! | Repeat the last command (sudo !! reruns it as root) |
Bash cheat sheet: pipes, redirection and wildcards
| You type | What it means |
|---|---|
cmd > file | Send output to a file, replacing what was there |
cmd >> file | Append output to the end of a file |
cmd 2> err.log | Send error messages to a file |
cmd > all.log 2>&1 | Send output and errors to the same file |
cmd < file | Feed a file in as input |
cmd1 | cmd2 | Pipe: the output of one becomes the input of the next |
cmd1 && cmd2 | Run cmd2 only if cmd1 succeeded |
cmd1 || cmd2 | Run cmd2 only if cmd1 failed |
cmd & | Run in the background |
* ? [abc] | Wildcards: any characters, one character, one of a set |
~ . .. | Your home directory, this directory, the parent directory |
$VAR $(cmd) | A variable’s value; the output of a command |
'single' "double" | Single quotes are literal; double quotes still expand $VAR |
echo $? | Exit status of the last command: 0 means success |
Putting it together: the ten IP addresses that hit your website most
awk '{print $1}' /var/log/nginx/access.log | sort | uniq -c | sort -rn | headEach command does one job and passes its output along the pipe: awk takes the first column (the visitor’s IP address), sort groups identical lines, uniq -c counts them, the second sort ranks them and head keeps the top ten.
The top 100 Linux commands
These are the 100 Linux commands worth knowing, grouped by the job you are trying to do. Each has a working example you can copy. The notes column marks where macOS behaves differently and the nearest IBM i (AS/400) command, for anyone crossing over. To find a command quickly, press Ctrl+F (Cmd+F on a Mac).
careful Can delete data or interrupt users: read the note first
install Not always installed: add it with apt or dnf
Linux only Not on macOS
Help and finding your way (1–10)
| # | Command | What it does | Example | Notes |
|---|---|---|---|---|
| 1 | man | Read a command’s manual. Space pages down, /word searches, q quits. | man tar | IBM i: F1 help |
| 2 | apropos | Search the manuals by keyword when you don’t know a command’s name (same as man -k). | apropos compress | Same on macOS |
| 3 | which | Show the full path of the program a command runs. | which python3 | Same on macOS |
| 4 | type | Say whether a name is an alias, a shell built-in or a program. | type ll | Same on macOS |
| 5 | history | List your recent commands. !42 reruns number 42; Ctrl+R searches as you type. | history | grep ssh | IBM i: F9 retrieve |
| 6 | tldr | Short, example-first help pages written by the community; quicker than man. | tldr tar | install |
| 7 | pwd | Print the directory you are in (the working directory). | pwd | Same on macOS |
| 8 | echo | Print text or the value of a variable. | echo $PATH | Same on macOS |
| 9 | alias | Make a shortcut for a longer command. Add it to ~/.bashrc to keep it. | alias ll='ls -alF' | Same on macOS |
| 10 | export | Set an environment variable for this shell and the programs it starts. | export EDITOR=nano | Same on macOS |
Files and directories (11–26)
| # | Command | What it does | Example | Notes |
|---|---|---|---|---|
| 11 | ls | List files. -l long format, -a include hidden, -h readable sizes, -t newest first. | ls -laht | IBM i: WRKLNK, DSPLIB |
| 12 | cd | Change directory. cd ~ goes home, cd .. up one level, cd – back to the last one. | cd /var/log | IBM i: CD (CHGCURDIR) |
| 13 | mkdir | Make a directory; -p creates any missing parent directories too. | mkdir -p projects/2026/q4 | IBM i: MKDIR, CRTLIB |
| 14 | rmdir | Remove an empty directory. | rmdir old-reports | IBM i: RMVDIR |
| 15 | touch | Create an empty file, or update an existing file’s timestamp. | touch notes.txt | Same on macOS |
| 16 | cp | Copy. -r for directories, -i to ask before overwriting, -p to keep permissions and timestamps. | cp -rp site/ site-backup/ | IBM i: CPY, CPYF |
| 17 | mv | Move or rename. Add -i to be asked before anything is overwritten. | mv draft.txt final.txt | IBM i: MOV, RNM |
| 18 | rm | Delete files. There is no recycle bin. -r for directories, -i asks first. | rm -i *.tmp | carefulIBM i: DEL, DLTF |
| 19 | ln | Create a link; -s makes a symbolic link, the Linux version of a shortcut. -fn re-points an existing one. | sudo ln -sfn /opt/app/v2 /opt/app/current | IBM i: ADDLNK |
| 20 | find | Search for files by name, size, age, owner or type, then act on them. | find /var/log -name "*.log" -mtime -1 | IBM i: WRKLNK, WRKOBJ |
| 21 | locate | Search a prebuilt index of file names, very fast. sudo updatedb refreshes it. | locate nginx.conf | install |
| 22 | tree | Show a directory and its contents as a tree. | tree -L 2 | install |
| 23 | file | Identify what a file really contains, whatever its name says. | file invoice.pdf | Same on macOS |
| 24 | stat | Show a file’s size, permissions, owner and timestamps. | stat report.csv | macOS: Output differs; stat -x for a similar layout. |
| 25 | du | Show how much disk space files and directories use. | du -sh * | sort -h | IBM i: RTVDSKINF |
| 26 | df | Show free space on each mounted file system. | df -h | IBM i: WRKDSKSTS, WRKSYSSTS |
Viewing and searching text (27–42)
| # | Command | What it does | Example | Notes |
|---|---|---|---|---|
| 27 | cat | Print a file to the screen; also joins files together. | cat /etc/os-release | macOS: No /etc/os-release; use sw_vers.IBM i: DSPF, DSPPFM |
| 28 | less | Page through a file. Space and b page, /word searches, F follows, q quits. Ubuntu logs to /var/log/syslog and RHEL to /var/log/messages; Debian 12+ and Fedora keep logs only in journalctl. | less /var/log/syslog | IBM i: DSPF |
| 29 | head | Show the first lines of a file (10 unless you say otherwise). | head -n 20 data.csv | Same on macOS |
| 30 | tail | Show the last lines; -f keeps following new lines as they are written. | tail -f /var/log/nginx/error.log | Same on macOS |
| 31 | wc | Count lines, words and bytes. | wc -l access.log | Same on macOS |
| 32 | grep | Search text for a pattern. -i ignore case, -r recurse, -n line numbers, -v invert. | grep -rin "error" /var/log/nginx/ | IBM i: FNDSTRPDM |
| 33 | sort | Sort lines. -n numeric, -r reverse, -k column, -t separator, -h readable sizes. | sort -t, -k3,3n sales.csv | Same on macOS |
| 34 | uniq | Collapse adjacent duplicate lines; -c counts them. Sort the input first. | sort ips.txt | uniq -c | sort -rn | Same on macOS |
| 35 | cut | Pull columns out of each line. | cut -d: -f1 /etc/passwd | Same on macOS |
| 36 | tr | Translate or delete characters. | tr 'a-z' 'A-Z' < names.txt | Same on macOS |
| 37 | sed | Stream editor: find and replace in a pipe, or in a file with -i. | sed -i 's/http:/https:/g' links.txt | macOS: In-place edit needs an empty backup suffix: sed -i ” ‘s/a/b/’ file |
| 38 | awk | A small language for columns: ideal for logs and CSV (comma-separated values) files. | awk -F, '$3 > 1000 {print $1}' sales.csv | Same on macOS |
| 39 | diff | Compare two files line by line; -u gives the readable unified format. | diff -u old.conf new.conf | IBM i: CMPPFM |
| 40 | tee | Send output to a file and the screen at once; the tidy way to write as root. | echo "10.0.0.5 nas" | sudo tee -a /etc/hosts | Same on macOS |
| 41 | xargs | Turn lines of input into arguments for another command. | find . -name "*.tmp" -print0 | xargs -0 rm | Same on macOS |
| 42 | jq | Query and pretty-print JSON (JavaScript Object Notation), the format most web APIs (application programming interfaces) return. | jq '.version' package.json | install |
Users, permissions and security (43–54)
| # | Command | What it does | Example | Notes |
|---|---|---|---|---|
| 43 | whoami | Show which user you are logged in as. | whoami | Same on macOS |
| 44 | id | Show your user ID, group ID and every group you belong to. | id | IBM i: DSPUSRPRF |
| 45 | sudo | Run one command as root (the superuser), with your own password, and log it. | sudo apt update | Same on macOS |
| 46 | su | Switch to another user’s shell; su – also loads their environment. It asks for that user’s password; for service accounts use sudo -iu postgres. | su - priya | Same on macOS |
| 47 | passwd | Change your password, or another user’s with sudo. | passwd | IBM i: CHGPWD |
| 48 | chmod | Change permissions, as numbers (640) or letters (u+x). | chmod 640 payroll.csv | IBM i: CHGAUT, GRTOBJAUT |
| 49 | chown | Change a file’s owner and group. | sudo chown -R www-data:www-data /var/www/site | IBM i: CHGOWN, CHGPGP |
| 50 | ufw | Open or close firewall ports on Ubuntu. The Red Hat family uses firewall-cmd instead. Allow SSH before you run sudo ufw enable, or you lock yourself out. | sudo ufw allow 22/tcp | Linux onlymacOS: Use the Firewall pane in System Settings |
| 51 | useradd | Create a user account. Debian and Ubuntu also offer the friendlier adduser. | sudo useradd -m -s /bin/bash priya | Linux onlymacOS: Use sysadminctl -addUserIBM i: CRTUSRPRF |
| 52 | usermod | Add a user to a group. Always -aG, or you replace all groups. The admin group is sudo on Ubuntu, wheel on Red Hat; log in again to pick it up. | sudo usermod -aG sudo priya | Linux onlyIBM i: CHGUSRPRF |
| 53 | getent | Look up users, groups and hosts from every configured source. | getent passwd priya | Linux onlymacOS: Use dscacheutil -q user |
| 54 | ssh-keygen | Create an SSH key pair for safer, password-free logins. | ssh-keygen -t ed25519 -C "priya@laptop" | Same on macOS |
Processes and jobs (55–68)
| # | Command | What it does | Example | Notes |
|---|---|---|---|---|
| 55 | ps | Snapshot of running processes. | ps aux --sort=-%cpu | head | macOS: No –sort; use ps aux -r | headIBM i: WRKACTJOB |
| 56 | top | Live view of processes and load. P sorts by CPU (processor) use, M by memory, q quits. | top | macOS: Keys differ; use top -o cpuIBM i: WRKACTJOB, WRKSYSACT |
| 57 | htop | A friendlier top with colour, scrolling and mouse support. | htop | install |
| 58 | pgrep | Find process IDs by name; -a shows the full command line. | pgrep -a nginx | macOS: Use pgrep -lf nginx |
| 59 | kill | Send a signal to a process. The default (TERM) asks it to stop; -9 forces it. | kill 4182 | carefulIBM i: ENDJOB |
| 60 | pkill | Signal processes by name or pattern. Check with pgrep first. | pkill -f "python3 report.py" | careful |
| 61 | jobs | List the jobs you started in the background from this shell. | jobs -l | Same on macOS |
| 62 | bg | Resume a stopped job (Ctrl+Z) in the background. | bg %1 | Same on macOS |
| 63 | fg | Bring a background job back to the foreground. | fg %1 | Same on macOS |
| 64 | nohup | Run a command that carries on after you log out. | nohup ./backup.sh > backup.log 2>&1 & | IBM i: SBMJOB |
| 65 | nice | Start a command at a lower priority; renice changes one already running. | nice -n 10 ./month-end.sh | IBM i: CHGJOB RUNPTY |
| 66 | watch | Rerun a command every few seconds and show the latest output. | watch -n 5 df -h | macOS: Install with Homebrew |
| 67 | lsof | List open files and the processes using them, including network ports. | sudo lsof -i :443 | IBM i: WRKOBJLCK |
| 68 | tmux | Keep terminal sessions alive after you disconnect; split the screen. | tmux new -s work | install |
System information (69–78)
| # | Command | What it does | Example | Notes |
|---|---|---|---|---|
| 69 | uname | Show the kernel name, release and architecture. | uname -a | Same on macOS |
| 70 | hostnamectl | Show or set the host name, with OS (operating system) and kernel details. | hostnamectl | Linux onlymacOS: Use scutil –get ComputerName |
| 71 | uptime | Time since boot, users logged in and the load averages. | uptime | IBM i: WRKSYSSTS |
| 72 | free | Show memory and swap use. | free -h | Linux onlymacOS: Use vm_stat or Activity MonitorIBM i: WRKSYSSTS |
| 73 | lscpu | Show the CPU model, cores and architecture. | lscpu | Linux onlymacOS: Use sysctl -n machdep.cpu.brand_string |
| 74 | lsblk | List disks and partitions as a tree; -f adds file systems. | lsblk -f | Linux onlymacOS: Use diskutil listIBM i: WRKDSKSTS |
| 75 | dmesg | Show kernel messages: hardware, drivers and disk errors. | sudo dmesg -T | tail -30 | macOS: No -T optionIBM i: DSPMSG QSYSOPR, WRKPRB |
| 76 | date | Show or format the date and time. | date "+%Y-%m-%d %H:%M" | IBM i: DSPSYSVAL QDATETIME |
| 77 | w | Who is logged in and what each of them is running. | w | IBM i: WRKUSRJOB |
| 78 | mount | List mounted file systems, or attach a new one to an existing directory. Add it to /etc/fstab to mount it at every boot. | sudo mkdir -p /mnt/usb && sudo mount /dev/sdb1 /mnt/usb | IBM i: MOUNT |
Services, logs and scheduling (79–82)
| # | Command | What it does | Example | Notes |
|---|---|---|---|---|
| 79 | systemctl | Control services: start, stop, restart, enable at boot, check status. | sudo systemctl restart nginx | Linux onlymacOS: Uses launchd; see launchctlIBM i: STRTCPSVR, ENDTCPSVR, STRSBS, ENDSBS |
| 80 | journalctl | Read the system journal, for everything or one service. | journalctl -u nginx --since "1 hour ago" | Linux onlymacOS: Use log show –last 1hIBM i: DSPLOG, DSPJOBLOG |
| 81 | crontab | Schedule recurring jobs. -e edits, -l lists. Never -r: it deletes them all. | crontab -e | IBM i: WRKJOBSCDE |
| 82 | shutdown | Power off or restart, now or later; shutdown -c cancels. | sudo shutdown -r +5 "Restarting for updates" | carefulIBM i: PWRDWNSYS |
Networking (83–92)
| # | Command | What it does | Example | Notes |
|---|---|---|---|---|
| 83 | ip | Show and change addresses, interfaces and routes. Replaces ifconfig. | ip -br a | Linux onlymacOS: Use ifconfigIBM i: CFGTCP, NETSTAT *IFC |
| 84 | ss | Show sockets and listening ports. Replaces netstat. | sudo ss -tulpn | Linux onlymacOS: Use netstat -an or lsof -iIBM i: NETSTAT *CNN |
| 85 | ping | Check a host is reachable; -c sets how many tries. | ping -c 4 bbc.co.uk | IBM i: PING |
| 86 | traceroute | Show each hop on the way to a host. tracepath, usually preinstalled, does much the same. | traceroute bbc.co.uk | installIBM i: TRACEROUTE |
| 87 | dig | Query DNS (Domain Name System) records; it comes in the dnsutils package (bind-utils on Red Hat). | dig itmanagement101.co.uk MX +short | IBM i: NSLOOKUP |
| 88 | curl | Send and receive data from a URL (web address); good for testing sites and APIs. | curl -I https://www.itmanagement101.co.uk | Same on macOS |
| 89 | wget | Download files, resuming if the connection drops. | wget -c https://example.com/big.iso | macOS: Install with Homebrew |
| 90 | ssh | Log in to another machine securely. | ssh priya@server.example.com | IBM i: ssh in PASE (IBM i’s AIX-compatible runtime); STRTCPSVR SERVER(*SSHD) starts the server |
| 91 | scp | Copy files to or from another machine over SSH. | scp report.pdf priya@server:/tmp/ | Same on macOS |
| 92 | rsync | Copy or sync efficiently; only the changes are sent. Try –dry-run first. | rsync -avh --dry-run src/ backup/ | IBM i: SAVRST |
Archives and software (93–97)
| # | Command | What it does | Example | Notes |
|---|---|---|---|---|
| 93 | tar | Bundle files into one archive. c create, x extract, z gzip, v verbose, f file name. | tar -czvf docs-2026-11-01.tar.gz docs/ | IBM i: SAVLIB to a *SAVF |
| 94 | gzip | Compress a single file; gunzip reverses it. -k keeps the original. | gzip -k big.log | Same on macOS |
| 95 | zip | Make .zip archives that Windows opens natively; unzip extracts them. | zip -r site.zip site/ | install |
| 96 | apt | Install, update and remove software on Debian and Ubuntu. | sudo apt update | Linux onlymacOS: Use Homebrew: brew installIBM i: PTFs; yum for open source |
| 97 | dnf | The same job on Fedora, Red Hat Enterprise Linux (RHEL), Rocky and AlmaLinux. | sudo dnf upgrade | Linux onlymacOS: Use Homebrew: brew install |
Editing and version control (98–100)
| # | Command | What it does | Example | Notes |
|---|---|---|---|---|
| 98 | nano | A simple editor; its shortcuts are listed along the bottom of the screen. | nano ~/.bashrc | IBM i: EDTF |
| 99 | vim | A powerful editor on almost every server. On minimal Red Hat systems, type vi. | vim notes.txt | IBM i: EDTF, SEU |
| 100 | git | Track changes to files and work with others. See the Git section. | git status | Same on macOS |
Want all 100 on paper? Download the free A5 PDF: 36 pages, made to print.
grep, find, tar and ssh in more depth
Four commands account for a large share of what people look up: grep, find, tar and ssh. Each gets one line in the top 100; these are the options you will reach for next.
grep command: search inside files
grep prints every line that matches a pattern. Give it a pattern and a file, or pipe text into it: grep "error" app.log.
| Command | What it does |
|---|---|
grep -i "error" app.log | Ignore upper and lower case |
grep -rn "TODO" src/ | Search a whole directory, with line numbers |
grep -v "^#" /etc/ssh/sshd_config | Lines that don’t match (here, hide comments) |
grep -c "404" access.log | Count the matching lines |
grep -l "password" *.conf | File names only |
grep -w "cat" notes.txt | Whole words only: not ‘concatenate’ |
grep -E "error|warn" app.log | Either pattern (extended regular expressions) |
grep -A 3 -B 1 "panic" app.log | Three lines after and one before each match |
find command: search for files
find searches a directory tree for files that match tests such as name, size, age or type, then can act on each one: find /var/log -name "*.log". Quote the pattern, or the shell expands the * before find sees it.
| Command | What it does |
|---|---|
find . -name "*.pdf" | By name, from here downwards |
find / -iname "readme*" 2>/dev/null | Ignore case; hide permission errors |
find . -type d -name node_modules | Directories only |
find /var -size +100M | Bigger than 100 MB |
find . -mtime -7 | Changed in the last seven days |
find . -mmin -60 | Changed in the last hour |
find . -name "*.tmp" -delete | Delete matches: run it without -delete first |
find . -name "*.sh" -exec chmod +x {} + | Run a command on every match |
tar command: create and extract archives
To extract a .tar.gz file, run tar -xzf file.tar.gz; to create one, tar -czf backup.tar.gz folder/.
| Command | What it does |
|---|---|
tar -czf backup.tar.gz folder/ | Create a gzip-compressed archive |
tar -xzf backup.tar.gz | Extract it here |
tar -tzf backup.tar.gz | List what is inside without extracting |
tar -xzf backup.tar.gz -C /tmp/restore | Extract somewhere else (the directory must exist) |
tar -xf file.tar.xz | Extract anything: modern tar detects the compression |
tar -cJf backup.tar.xz folder/ | xz compression: smaller, but slower |
tar -xzf backup.tar.gz folder/notes.txt | Extract one file by giving its path |
The letters: c create, x extract, t list; z gzip, j bzip2, J xz; v verbose; f comes last, before the file name.
ssh command: log in to another machine
ssh logs you in to another machine over an encrypted connection: ssh user@host. Set up a key once and you stop typing passwords; add an entry to ~/.ssh/config and you stop typing addresses too.
| Command | What it does |
|---|---|
ssh priya@server.example.com | Log in |
ssh -p 2222 priya@server.example.com | Use a different port |
ssh-keygen -t ed25519 | Create a key pair (once per computer) |
ssh-copy-id priya@server.example.com | Install your public key on the server |
ssh priya@server.example.com 'df -h' | Run one command and come back |
ssh -L 8080:localhost:80 priya@server.example.com | Forward a local port to the server |
Host web01
HostName web01.example.co.uk
User priya
Port 2222With that in ~/.ssh/config, ssh web01 is all you type. If a session hangs, press Enter, then ~ then . to close it.
Linux file permissions explained
Every file belongs to one user and one group, and has three sets of permissions: for the owner, the group and everyone else. ls -l shows them as ten characters at the start of each line. Read -rwxr-x--- like this:
| Part | Meaning |
|---|---|
- | File type: – file, d directory, l link |
rwx | Owner: read, write, execute |
r-x | Group: read and execute, no write |
--- | Everyone else: nothing |
chmod’s numbers are the three sets added up. Read is 4, write is 2 and execute is 1, so rwx is 7, r-x is 5 and r-- is 4. chmod 750 script.sh therefore means rwx for the owner, r-x for the group and nothing for anyone else. The letter form changes one thing at a time: chmod u+x adds execute for the owner, chmod o-r removes read for others.
| Value | Permission |
|---|---|
r = 4 | Read: open a file, or list a directory |
w = 2 | Write: change a file, or add and delete in a directory |
x = 1 | Execute: run a file, or enter a directory |
| Mode | Shown as | Use it for |
|---|---|---|
644 | rw-r--r-- | Ordinary files: you edit, everyone reads |
600 | rw------- | Private files: SSH keys, passwords |
640 | rw-r----- | Shared with your group only |
755 | rwxr-xr-x | Programs, scripts and most directories |
750 | rwxr-x--- | Directories for you and your group |
700 | rwx------ | Your private directories, such as ~/.ssh |
Three special bits sit in front of the usual three digits. setuid (4) runs a program as its owner, which is how passwd can update /etc/shadow. setgid (2) on a directory makes new files inherit its group, useful for shared folders. The sticky bit (1) on a directory lets people delete only their own files, which is why /tmp shows drwxrwxrwt and has mode 1777.
Ten habits that stop you breaking a Linux server
Linux trusts you completely, which is what makes it powerful and what makes it dangerous. These habits prevent most self-inflicted outages.
- Work as yourself, not rootUse sudo for the one command that needs it. A mistake as root has no safety net.
- Check where you areRun hostname and pwd before anything destructive. Many outages start in the wrong window.
- List before you deleteRun ls with the same pattern first; then swap ls for rm. Use rm -i when unsure.
- Rehearse with a dry runrsync –dry-run, find without -delete, and git status before git reset.
- Mind > and >>A single > replaces a file’s contents. To add to it, use >>.
- Never chmod -R 777It gives everyone write access to everything. Fix the owner (chown) or the group instead.
- crontab -e, never -rThe keys are next to each other; -r deletes every scheduled job without asking.
- Don’t lock yourself outBefore changing SSH, firewall or sudo settings, keep a second session open and test the file (sshd -t, visudo -c) before restarting anything.
- Read before you pasteCommands copied from the web, especially curl … | sh, run with your full rights.
- Keep a way backCopy a config file before editing it (cp file file.bak) and keep backups you have tested.
Everyday Linux one-liners
Single commands answer most questions; chained together they answer the awkward ones. These are the one-liners that come up again and again on real servers. Run them as they are, then change the paths.
| The question | The command |
|---|---|
| Which directories are filling the disk? | sudo du -xh --max-depth=1 / | sort -rh | head |
| The biggest files (over 50 MB) under /var | sudo find /var -xdev -type f -size +50M -exec du -h {} + | sort -rh | head |
| What is listening on port 443? | sudo ss -tlpn 'sport = :443' |
| Errors from one service in the last hour | journalctl -u nginx -p err --since "1 hour ago" |
| Watch the system log for errors as they happen | journalctl -f | grep -i --line-buffered error |
| Which config files changed in the last 24 hours? | sudo find /etc -type f -mtime -1 -ls |
| The processes using the most memory | ps aux --sort=-%mem | head |
| A date-stamped backup of a folder | sudo tar -czf "etc-$(date +%F).tar.gz" /etc |
| Copy your SSH key to a server | ssh-copy-id priya@server.example.com |
| Which package installed this file? | dpkg -S /usr/bin/curl (Red Hat family: rpm -qf) |
| Rename every .jpeg to .jpg | for f in *.jpeg; do mv -- "$f" "${f%.jpeg}.jpg"; done |
| When does a site’s certificate expire? | echo | openssl s_client -connect example.com:443 -servername example.com 2>/dev/null | openssl x509 -noout -enddate |
Editing text files from the command line
To edit a file from the command line, use nano if you want something easy and vim if you want something powerful. nano shows its shortcuts on screen and behaves like a basic word processor. vi, or its modern version vim, is on almost every Linux and Unix server ever built, so it is worth knowing enough to save and quit, even if you prefer nano. To edit a system file, use sudo nano /etc/hosts, or the safer sudoedit /etc/hosts, which edits a copy and only writes it back when you save.
Vim cheat sheet: how to save, exit and edit in vi
To exit vim, press Esc, type :q and press Enter. Use :wq to save and quit, or :q! to quit without saving. vim confuses people because it has modes. In Normal mode, the one it starts in, letters are commands: x deletes a character, dd deletes a line. Press i to enter Insert mode and type text; press Esc to go back. Commands beginning with a colon, such as :w to save, are typed in Normal mode and appear at the bottom of the screen. If you remember nothing else, remember the six below.
| Type | What it does |
|---|---|
Esc | Back to Normal mode. If in doubt, press it twice |
i | Insert text before the cursor |
:w | Save |
:q | Quit |
:wq or :x or ZZ | Save and quit |
:q! | Quit without saving |
| Type | What it does |
|---|---|
a / A | Append after the cursor / at the end of the line |
o / O | Open a new line below / above |
h j k l | Left, down, up, right (arrow keys also work) |
w / b | Next / previous word |
0 / $ | Start / end of the line |
gg / G | Top / bottom of the file |
:42 | Go to line 42 |
x | Delete one character |
dd | Delete (cut) the line; 3dd deletes three |
yy | Copy (yank) the line |
p / P | Paste after / before |
u / Ctrl+R | Undo / redo |
. | Repeat the last change |
/word, n, N | Search; next match; previous match |
:%s/old/new/g | Replace every ‘old’ with ‘new’ |
v / V | Select characters / whole lines |
:set number | Show line numbers |
:help | Built-in help; vimtutor is a 30-minute lesson |
To learn vim properly, type vimtutor at the prompt: it is a free, built-in lesson that takes about half an hour.
nano commands: the easy editor
nano: open a file with nano filename, type, then Ctrl+O to save and Ctrl+X to exit. In nano’s on-screen help, ^ means Ctrl and M- means Alt, so ^X is Ctrl+X. Recent versions also accept Ctrl+S to save, and from version 8.0 Ctrl+F searches forwards (Ubuntu 24.04 ships nano 7.2 and RHEL 9 ships 5.6, so use Ctrl+W there).
| Keys | What they do |
|---|---|
Ctrl+O, Enter | Save (Write Out) |
Ctrl+X | Exit (asks to save if you have changes) |
Ctrl+W | Search; Alt+W finds the next match |
Ctrl+\ | Search and replace |
Ctrl+K | Cut the current line |
Ctrl+U | Paste the cut text |
Alt+U / Alt+E | Undo / redo |
Ctrl+_ | Go to a line number |
Alt+6 | Copy the current line |
Ctrl+G | Help: every shortcut |
nano -l file | Open with line numbers |
Editing without an editor
You don’t always need an editor. For one-line changes, especially in scripts, edit from the command line:
Change a setting in place, keeping a .bak copy; sshd -t checks the file before you reload the service
sudo sed -i.bak 's/^#\?PermitRootLogin .*/PermitRootLogin no/' /etc/ssh/sshd_config && sudo sshd -tAdd a line to the end of a file
echo 'export EDITOR=nano' >> ~/.bashrcWrite several lines to a file that needs root
sudo tee /etc/motd > /dev/null <<'EOF'
Authorised users only.
EOFPrograms such as crontab -e and git commit open your default editor. If vim appears and you wanted nano, export EDITOR=nano sets it for the session; add that line to ~/.bashrc to make it permanent.
Your first shell script, and how to schedule it
A shell script is a text file of commands that runs in order, the Linux equivalent of a CL (Control Language) program on IBM i. This one makes a dated backup and deletes copies older than a fortnight. Save it in your home directory as backup.sh, run chmod +x backup.sh, then test it with ./backup.sh.
#!/usr/bin/env bash
# backup.sh - archive a folder with today's date, keep about a fortnight
set -euo pipefail
SRC="/home/priya/documents"
DEST="/home/priya/backups" # ideally on a different disk
STAMP=$(date +%F) # e.g. 2026-11-01
mkdir -p "$DEST"
tar -czf "$DEST/docs-$STAMP.tar.gz" -C "$SRC" .
echo "Saved $DEST/docs-$STAMP.tar.gz"
# Delete archives older than 14 days
find "$DEST" -maxdepth 1 -type f -name 'docs-*.tar.gz' -mtime +14 -delete| Line | What it does |
|---|---|
#!/usr/bin/env bash | The ‘shebang’: run this file with bash |
set -euo pipefail | Stop at the first error, an unset variable or a failed pipe |
"$DEST" | Quote variables, so names with spaces don’t break things |
$(date +%F) | Insert a command’s output, here the date |
chmod +x backup.sh | Make it executable once; then run it as ./backup.sh |
To run it automatically, schedule it with cron. Type crontab -e and add a line: five time fields, then the command. Always send the output to a log, or you will never know why it failed.
30 2 * * * /home/priya/backup.sh >> /home/priya/backup.log 2>&1| Field | Values |
|---|---|
| Minute | 0–59 |
| Hour | 0–23 |
| Day of month | 1–31 |
| Month | 1–12 |
| Day of week | 0–7 (0 and 7 are Sunday) |
| Schedule | Runs |
|---|---|
30 2 * * * | Every day at 02:30 |
0 9 * * 1-5 | 09:00, Monday to Friday |
*/15 * * * * | Every 15 minutes |
0 0 1 * * | Midnight on the 1st of each month |
@reboot | Once, each time the machine starts |
Git on Linux: the basics in ten minutes
Git is version control: it records every saved change to a set of files, who made it and why, so you can compare versions, undo mistakes and work alongside other people without overwriting each other. It was written by Linus Torvalds in 2005 to manage the Linux kernel itself. Git runs on your computer; GitHub, GitLab, Bitbucket and Azure DevOps are online services that host shared copies of Git repositories and add reviews, issue tracking and automation around them.
This is the short version, with everything you need to get started. For branching, merge conflicts, rebasing and every command in one place, see the Git cheat sheet.
| Term | Meaning |
|---|---|
| Repository (repo) | A project folder that Git is tracking, with its full history in a hidden .git directory. |
| Commit | A saved snapshot of your changes, with a message and a unique ID (the hash). |
| Branch | A separate line of work. main is the official version; you make changes on a branch and merge them in. |
| Remote | A shared copy of the repository on another machine, usually called origin. |
| Staging area | The list of changes that will go into your next commit, so you can commit some edits and not others. |
Getting Git set up
Install Git with sudo apt install git (Debian, Ubuntu) or sudo dnf install git (Fedora, Red Hat family). On a Mac, typing git offers to install Apple’s command-line tools; on Windows, install Git for Windows. Check it worked with git --version, then tell Git who you are, once per computer:
| Command | What it does |
|---|---|
git config --global user.name "Priya Shah" | Your name on every commit |
git config --global user.email "priya@example.co.uk" | Your email on every commit |
git config --global init.defaultBranch main | Call the first branch main |
git config --global core.editor nano | The editor Git opens for messages |
git config --global pull.rebase false | git pull merges, rather than stopping when branches have diverged |
git config --list | Check your settings |
Making your first change
- Create a project and a repository
mkdir website && cd website git init - Make a change
echo '# My website' > README.md git status - Stage it and commit it
git add README.md git commit -m "Add README" - Change it again and see what changed
echo 'Contact: hello@example.co.uk' >> README.md git diff - Commit the second change and look at the history
git commit -am "Add contact line" git log --oneline - Connect to a shared copy and push (after creating an empty repository on GitHub or similar)
git remote add origin git@github.com:priya/website.git git push -u origin main
git commit -am stages every file Git already tracks and commits in one go; new files still need git add first.
The Git commands you’ll use every day
| Command | What it does |
|---|---|
git init | Turn the current directory into a repository |
git clone URL | Copy an existing repository, with its history |
git status | What has changed, and what is staged |
git diff | The changes you haven’t staged yet |
git add file | Stage a change for the next commit (git add . for all) |
git commit -m "Message" | Save the staged changes as a snapshot |
git log --oneline --graph | Compact history |
git switch -c feature/x | Create a branch and move to it |
git switch main | Move to another branch |
git pull | Fetch and merge others’ changes |
git push -u origin feature/x | Send your branch to the shared copy |
git merge feature/x | Merge a branch into the one you’re on |
git stash / git stash pop | Put changes aside, then bring them back |
Reversing a change: which undo do you need?
How you reverse a change in Git depends on how far it has travelled. The rule that matters most: if a commit has been pushed or shared, undo it with git revert, which adds a new commit that cancels it out. Rewriting shared history with git reset causes trouble for everyone who already has it. Find what you did in the left column:
| What happened | Command | Watch out |
|---|---|---|
| Changed a file, not staged, want it back as it was | git restore file | Discards your edits: they cannot be recovered |
| Staged a file by mistake | git restore --staged file | Your edits stay in the file |
| Last commit’s message is wrong, or a file is missing | git commit --amend | Not yet pushed only |
| Undo the last commit, keep the changes | git reset --soft HEAD~1 | Not yet pushed only |
| Throw away the last commit and its changes | git reset --hard HEAD~1 | Destructive: also wipes uncommitted edits. Not yet pushed only |
| Undo a commit that is already pushed or shared | git revert <hash> | Safe: adds a new commit that reverses it |
| I’ve lost a commit or a branch | git reflog, then git switch -c rescue <hash> | The reflog keeps unreachable commits for 30 days by default, so act soon |
What is a pull request?
A pull request (PR) is a request to merge the changes on your branch into the main branch, with a place for colleagues to review them first. It shows exactly what changed, line by line, lets reviewers comment and approve, and runs any automated tests before anything reaches main. The name comes from asking the project’s maintainers to pull your work in. GitHub, Bitbucket and Azure DevOps call it a pull request; GitLab calls the same thing a merge request.
- Branch
git switch -c fix/login-timeout - CommitMake the change; git add, then git commit
- Push
git push -u origin fix/login-timeout - Open the pull requestOn GitHub, Bitbucket or Azure DevOps (a merge request on GitLab): say what changed and why
- Review and checksColleagues comment; automated tests run; you push fixes to the same branch
- MergeOnce approved, it merges into main (merge commit, squash or rebase)
- Tidy up
git switch main, git pull, then git branch -d fix/login-timeout (use -D if it was squash-merged)
Pull requests are how most teams keep main working: nobody commits to it directly, every change gets a second pair of eyes, and the PR itself becomes the record of why the change was made. In larger projects the same flow starts from a fork, your own copy of someone else’s repository.
Four Git habits worth having from day one
- Ignore what shouldn’t be tracked. List files and folders in a
.gitignorefile: build output, logs,.envfiles. - Never commit passwords or keys. Deleting them in a later commit leaves them in the history; if it happens, change the password or revoke the key straight away.
- Write messages for the next person. A short line in the imperative mood, such as “Fix login timeout on slow connections”, beats “updates”.
- Commit small and often. Small commits are easier to review, and easier to revert.
Ready for more? The Git cheat sheet covers branching, merge conflicts, stash, tags and rebasing.
Linux vs Unix vs macOS: how they differ and what they share
Linux, Unix and macOS share the same ideas and most of the same commands, but they are different operating systems with different histories. Unix came first, written at AT&T’s Bell Labs in 1969. Linux is a Unix-like system written from scratch: Linus Torvalds released the kernel in 1991, and paired with the GNU project’s tools it became a complete, free operating system. macOS descends from Unix more directly, through BSD (the Berkeley Software Distribution of Unix) and NeXT, Steve Jobs’s company that Apple bought in 1997.
What Linux, Unix and macOS have in common
- The same file system shape: one tree starting at
/, with no drive letters. - The same building blocks:
ls,cd,cp,grep,find, pipes, redirection and shell scripts. - The same security model: users, groups, and read, write and execute permissions.
- The same standards: POSIX (the Portable Operating System Interface) defines the common commands and behaviour, which is why a script written carefully runs on all three.
Where they differ is in the details. Linux uses the GNU versions of the core tools, with long options such as --human-readable; macOS uses BSD versions, where some flags are missing or work differently. Linux manages services with systemd; macOS uses launchd; commercial Unix systems each have their own. And only Linux has distributions: the same kernel packaged differently by Ubuntu, Debian, Fedora, Red Hat and others, which is why installing software means apt on one and dnf on another.
Linux vs Unix vs macOS at a glance
| Linux | Unix | macOS | |
|---|---|---|---|
| What it is | A kernel, plus GNU and other tools, packaged as distributions | A family of operating systems descended from AT&T’s original | Apple’s desktop OS, built on the Unix-derived Darwin core |
| Born | 1991 (Linus Torvalds); GNU project from 1983 | 1969, Bell Labs (Ken Thompson, Dennis Ritchie) | 2001 as Mac OS X; Darwin from NeXTSTEP and BSD |
| Kernel | Linux (monolithic, loadable modules) | Varies: AIX, Solaris, HP-UX, the BSDs | XNU (Mach plus BSD) |
| Licence | Free and open source (the kernel uses the GPL, the GNU General Public License) | Mostly proprietary; the BSDs are open source | Proprietary; Darwin is open source |
| Certified UNIX? | Generally no (a ‘Unix-like’ system); a rare few, such as Huawei’s EulerOS, have been certified | Yes for AIX and some others; the name is a trademark of The Open Group | UNIX 03 from Leopard (2007); entries left the Open Group register in October 2026 |
| Default shell | bash on most distributions | ksh or sh on many commercial systems | zsh since Catalina (2019) |
| Core tools | GNU coreutils: long –options | Vendor or BSD versions | BSD versions: some flags differ from Linux |
| Services | systemd (systemctl, journalctl) | SMF (Service Management Facility) on Solaris, SRC (System Resource Controller) on AIX | launchd (launchctl) |
| Software | apt, dnf, zypper, pacman | Vendor packages; pkg on the BSDs | App Store; Homebrew (third party) |
| File systems | ext4, XFS, Btrfs | JFS2 (AIX), ZFS (Solaris, FreeBSD) | APFS, the Apple File System (case-insensitive by default) |
| Where you meet it | Web servers, cloud, Android, Raspberry Pi, supercomputers | Banks, telcos, large enterprise back ends | Developer laptops and creative studios |
A note on the word Unix. It is a trademark of The Open Group, which certifies systems against its standard. IBM’s AIX is certified; Linux distributions generally are not, so Linux is described as Unix-like. Apple’s macOS was certified as UNIX 03 from Mac OS X 10.5 Leopard in 2007, but in October 2026 Apple’s entries disappeared from the Open Group register without explanation. Nothing about how the Mac Terminal works has changed (OSnews reported the change on 20 October 2026).
Linux commands that work differently on a Mac
Most commands in this guide work in the Mac Terminal. These are the differences that catch Linux users out. If you would rather have the Linux versions on a Mac, brew install coreutils gnu-sed grep installs the GNU tools with a g prefix (gsed, gdate, gls).
| On Linux | On macOS | Why |
|---|---|---|
sed -i 's/a/b/' f | sed -i '' 's/a/b/' f | BSD sed needs a backup suffix, even an empty one |
date -d '+1 day' | date -v+1d | Date arithmetic uses different flags |
ls --color=auto | ls -G | -G works on every macOS; only recent versions accept –color |
du -h --max-depth=1 | du -h -d 1 | BSD du uses -d, not –max-depth |
stat -c '%s' file | stat -f '%z' file | BSD stat uses -f and different format letters |
grep -P 'regex' | grep -E 'regex' | BSD grep has no Perl-style regex |
ip a / ss -tulpn | ifconfig / lsof -i | No iproute2 on macOS |
systemctl / journalctl | launchctl / log show | macOS uses launchd, not systemd |
free -h | vm_stat | No free command on macOS |
The Linux directory structure, compared with Windows and macOS
Linux keeps everything in one tree that starts at /, with no drive letters. Windows gives each drive its own tree (C:, D:) and keeps settings in the Registry; macOS uses the same single tree as Linux but with its own names for the top-level folders. Unix systems such as AIX and Solaris follow broadly the same layout as Linux, which is described by the Filesystem Hierarchy Standard.
In Linux, almost everything is a file. Configuration lives in plain-text files under /etc, so you can read it with less and change it with nano. Disks appear as files under /dev, and live system information appears under /proc: cat /proc/cpuinfo lists your processors. Learn the handful of directories below and you will know where to look on any distribution.
Standard Linux directories and what they hold
| Directory | What’s in it |
|---|---|
/ | The root: everything hangs off here, including other disks |
/etc | System-wide configuration, as plain text files |
/home | Users’ own directories (/home/priya) |
/root | The root user’s home directory |
/var | Things that change: /var/log for logs, /var/www for websites |
/var/lib | Applications’ working data, such as databases (/var/lib/mysql) |
/tmp | Temporary files, often cleared at boot |
/usr | Installed programs and libraries (/usr/bin, /usr/lib), managed by the package manager |
/usr/local | Software you install by hand, kept apart from the package manager’s |
/bin, /sbin | Essential commands; on modern systems, links into /usr |
/opt | Optional, self-contained third-party software |
/dev | Devices as files: disks (/dev/sda), terminals, /dev/null |
/proc, /sys | Live kernel and process information, generated on demand |
/run | Runtime files that vanish at reboot, such as process ID files |
/lib | Shared libraries and kernel modules; on modern systems, a link to /usr/lib |
/boot | The kernel and boot loader files |
/mnt, /media | Mount points for extra disks and USB (Universal Serial Bus) drives |
/srv | Data served by this machine, on some systems |
Linux vs Windows vs macOS: where things live
The same job, in three places. Where to look on each system:
| What | Linux and Unix | Windows | macOS |
|---|---|---|---|
| Top of the tree | / | C:\ (one tree per drive) | / (the startup disk) |
| Your files | /home/priya | C:\Users\priya | /Users/priya |
| The administrator’s home | /root | C:\Users\Administrator | /var/root |
| System settings | /etc (text files) | The Registry, C:\ProgramData | /etc and /Library/Preferences (.plist files) |
| Your app settings | ~/.config and dotfiles | %APPDATA% (C:\Users\priya\AppData\Roaming) | ~/Library/Preferences, ~/Library/Application Support |
| Installed programs | /usr/bin, /usr/local/bin, /opt | C:\Program Files | /Applications; Homebrew in /opt/homebrew |
| Operating system files | /usr, /lib, /boot | C:\Windows, C:\Windows\System32 | /System (sealed, read-only) |
| Logs | /var/log and journalctl | Event Viewer (C:\Windows\System32\winevt\Logs) | /var/log, ~/Library/Logs and log show |
| Temporary files | /tmp, /var/tmp | %TEMP% (C:\Users\priya\AppData\Local\Temp) | /tmp and $TMPDIR |
| Other disks and USB sticks | /mnt, /media (mounted into the tree) | D:, E: and so on (drive letters) | /Volumes |
| Devices | /dev (as files) | Device Manager; no files | /dev (as files) |
On a Mac, /etc, /tmp and /var are links into a hidden /private folder, and the system itself sits on a sealed, read-only volume, so you can look but not change it.
Six differences that trip people up when moving between them:
| Linux | Windows | macOS | |
|---|---|---|---|
| Path separator | / | \ (most tools also accept /) | / |
| Case-sensitive names? | Yes: Report.txt and report.txt are two files | No (case-preserving) | No by default (APFS is case-insensitive) |
| Hidden files | Name starts with a dot: .bashrc | A hidden attribute on the file | Dot files, plus a hidden flag (Cmd+Shift+. shows them in Finder) |
| What makes a file runnable | The execute permission (chmod +x) | Its extension: .exe, .bat, .ps1 | The execute permission, or an .app bundle |
| Line endings in text files | LF | CRLF (dos2unix converts) | LF |
| Drive letters | None: everything is under / | Yes | None: other disks appear under /Volumes |
Linux for AS/400 (IBM i) operators: a cross-reference
If you have spent years on an AS/400, iSeries or IBM i, you already understand most of Linux. The concepts map closely: jobs are processes, subsystems are services, the history log is the journal. What changes is the style. CL commands are long, consistent and self-describing, with F4 to prompt every parameter; Linux commands are short, terse and expect you to know the options. This section grew out of the AS/400 comparisons in my original notebook; this is the full version.
Six things that will feel different
- Everything is case-sensitive.
Report.TXTandreport.txtare different files, and commands are lower case. - There is no F4 prompter. Press Tab to complete names, and use
--helpormanto see the options. - Nothing asks if you are sure.
rmdeletes immediately and there is no recovery from a recycle bin. - You rarely sign on as the security officer. Work as yourself and put
sudoin front of the one command that needs root. - Job queues don’t exist as such. Run things in the background with
nohup, on a schedule withcronor a systemd timer. - Output goes to the screen or a file, not a spool. Redirect it with
>and read it withless.
IBM i concepts and their Linux equivalents
| On IBM i | On Linux |
|---|---|
| Object (*PGM, *FILE, *DTAARA) | File. In Linux, almost everything is a file, including devices |
| Library (QSYS.LIB) | Directory. IBM i’s IFS (Integrated File System: /home, /QOpenSys) already works this way |
| Library list (*LIBL) | PATH, the list of directories searched for commands |
| User profile | User account (/etc/passwd, /etc/shadow) |
| QSECOFR and *ALLOBJ | root, used through sudo rather than signed on as |
| Object authority | Permissions: owner, group, others × read, write, execute |
| Subsystem (QBATCH, QINTER) | systemd service units and targets |
| Job | Process, with a PID (process ID) instead of a job number |
| Job queue | No direct equivalent: cron, at, batch or systemd-run |
| QSYSOPR message queue | The journal (journalctl) and syslog |
| History log (QHST) | journalctl, plus files in /var/log |
| Spooled file | Output usually goes to a file or log; printing is via CUPS (Common Unix Printing System) |
| CL program | Shell script (bash) |
| IPL (initial program load) | Boot or reboot |
| PTF (program temporary fix) | Package update (apt or dnf) |
| Save file (*SAVF) | tar archive, often compressed (.tar.gz) |
| System value | sysctl settings and files in /etc |
| Case: commands in capitals | Everything is case-sensitive: Report.txt ≠ report.txt |
AS/400 commands and their Linux equivalents
| IBM i command | Linux equivalent | What for |
|---|---|---|
| WRKACTJOB | top, htop, ps aux | Live view of what is running |
| WRKSYSSTS / WRKSYSACT | top, uptime, free -h, vmstat | CPU, memory and load |
| WRKUSRJOB | ps -u priya, w | One user’s processes |
| WRKJOB | ps -fp 1234, ls /proc/1234 | One process in detail |
| ENDJOB | kill 1234 | Ask a process to stop |
| ENDJOB OPTION(*IMMED) | kill -9 1234 | Force it, as a last resort |
| HLDJOB / RLSJOB | kill -STOP / kill -CONT | Pause and resume a process |
| CHGJOB RUNPTY | renice | Change priority |
| SBMJOB | nohup cmd &, systemd-run, at | Run in the background |
| WRKJOBSCDE / ADDJOBSCDE | crontab -l / crontab -e | Scheduled jobs |
| WRKOBJLCK | lsof /path/file, fuser | Who has this file open? |
| STRSBS / ENDSBS, STRTCPSVR / ENDTCPSVR | systemctl start / stop | Start and stop services |
| WRKSBS | systemctl list-units --type=service | List services |
| DSPLOG | journalctl | System log |
| DSPJOBLOG | journalctl -u name, the app's log file | One job’s or service’s log |
| DSPMSG QSYSOPR | journalctl -p warning -b | Operator-level messages |
| WRKDSKSTS | df -h, iostat, lsblk | Disk space and activity |
| WRKHDWRSC | lshw, lspci, lsblk, dmesg | Hardware |
| DSPSFWRSC | dpkg -l / rpm -qa | Installed software |
| DSPPTF / install PTFs | apt list --upgradable, apt upgrade (dnf upgrade) | Updates |
| PWRDWNSYS | shutdown -h now | Power down |
| PWRDWNSYS RESTART(*YES) | shutdown -r now (or reboot) | Restart |
| CRTUSRPRF | useradd (or adduser) | Create a user |
| CHGUSRPRF | usermod | Change a user |
| DSPUSRPRF | id priya, getent passwd priya | Show a user |
| CHGPWD | passwd | Change password |
| GRTOBJAUT / CHGAUT | chmod, setfacl | Grant access |
| DSPAUT / DSPOBJAUT | ls -l, getfacl | Show access |
| CHGOBJOWN / CHGOWN | chown | Change owner |
| CRTLIB / MKDIR | mkdir | Create a directory |
| WRKLNK / DSPLIB | ls -l | List contents |
| CPYF / CPY | cp | Copy |
| MOVOBJ / RNMOBJ | mv | Move or rename |
| DLTF / DLTLIB / DEL | rm, rm -r | Delete (no undo) |
| DSPPFM / DSPF | cat, less | View a file |
| EDTF / STRSEU | nano, vim | Edit a file |
| FNDSTRPDM | grep -rn | Find text in files |
| CMPPFM | diff -u | Compare files |
| SAVLIB / SAVOBJ to *SAVF | tar -czf | Save to an archive |
| RSTLIB / RSTOBJ | tar -xzf | Restore from an archive |
| CFGTCP / NETSTAT *IFC | ip addr, ip route | Network settings |
| NETSTAT *CNN | ss -tulpn | Connections and listening ports |
| PING | ping -c 4 host | Is it reachable? |
| NSLOOKUP | dig, nslookup | DNS lookup |
| DSPSYSVAL QDATETIME | date, timedatectl | Date and time |
| SNDMSG / SNDBRKMSG | write / wall | Message logged-in users |
| STRQSH / QP2TERM | bash | A shell |
| RUNSQLSTM / STRSQL | psql, mysql, sqlite3 | Run SQL (Structured Query Language) |
5250 keys and their terminal equivalents
| 5250 key | In a Linux terminal |
|---|---|
| F1 (Help) | man command, command –help |
| F3 (Exit) | q in less, man and top; exit to log out |
| F4 (Prompt) | Tab completion and –help; there is no prompter |
| F5 (Refresh) | Rerun, or watch -n 5 command |
| F9 (Retrieve) | ↑ arrow, history, Ctrl+R |
| Page Down | Space in less and man |
| System Request, option 2 | Ctrl+C |
| Attention key | Ctrl+Z (pause, then bg or fg) |
You can practise on the IBM i you already have. STRQSH starts QShell, and CALL QP2TERM starts a PASE shell (PASE is IBM i’s AIX-compatible runtime), both working in the Integrated File System. Better still, start the SSH server (STRTCPSVR SERVER(*SSHD)), install IBM’s open-source packages, which use yum, and you get bash, git, vim and Python on the machine you know. See also our AS400 command cheat sheet and how to check your IBM i version.
How Linux works: architecture and services
A Linux system is a stack of layers, with the kernel in the middle of everything. The kernel is the core program that owns the hardware: it decides which process runs on which CPU, hands out memory, reads and writes disks, and moves network traffic. Programs never touch the hardware directly. They ask the kernel through system calls, which is what keeps one misbehaving program from bringing down the rest.
| Layer | What it does |
|---|---|
| Hardware | CPU, memory, disks and network cards. The kernel talks to them through device drivers. |
| The kernel | Process scheduling, memory management, file systems, networking and drivers. Running uname -r shows its version. |
| System calls | The narrow doorway between programs and the kernel: open a file, read, write, start a process. |
| Libraries and core tools | glibc, the C library almost every program uses, and the GNU core utilities such as ls, cp and grep. |
| systemd and services | systemd is the first process the kernel starts (process ID 1). It starts everything else and keeps services, also called daemons, running. |
| Shell and applications | The shell (usually bash) reads what you type and runs it; desktops, web servers and databases sit alongside. |
What happens when Linux starts
What happens when Linux starts: the firmware (UEFI, the Unified Extensible Firmware Interface) starts a boot loader, usually GRUB; GRUB loads the kernel; the kernel finds the disks and starts systemd; systemd starts the services for the chosen target, such as multi-user for a server or graphical for a desktop; and finally you get a login prompt. If a machine had trouble booting, once it is back up journalctl -b -1 shows the log from the previous boot, provided the journal is kept on disk (the /var/log/journal directory exists).
Services: systemctl and journalctl
A service is a program that runs in the background, waiting for work. Web servers, databases, the SSH server and the scheduler are all services. On almost every current distribution, systemd manages them with two commands: systemctl to control them and journalctl to read their logs.
| Service | What it does |
|---|---|
sshd | Remote logins over SSH |
systemd-journald | Collects logs from the kernel and every service |
cron / systemd timers | Run jobs on a schedule |
NetworkManager / systemd-networkd | Bring network interfaces up |
firewalld / ufw (nftables) | The firewall |
nginx / apache2 (httpd) | Web servers |
mariadb / postgresql | Databases |
chronyd / systemd-timesyncd | Keep the clock accurate |
| Command | What it does |
|---|---|
systemctl status nginx | Is it running? Shows the last few log lines |
sudo systemctl start nginx | Start it now |
sudo systemctl stop nginx | Stop it now |
sudo systemctl restart nginx | Stop and start |
sudo systemctl reload nginx | Re-read configuration without dropping connections |
sudo systemctl enable --now nginx | Start at every boot, and start it now |
sudo systemctl disable nginx | Don’t start at boot |
systemctl --failed | List services that failed |
systemctl list-units --type=service | List loaded services |
systemctl list-timers | Scheduled timers and when they next run |
journalctl -u nginx -f | Follow one service’s log live |
journalctl -p err -b | Errors since the last boot |
journalctl --since today | Everything logged today |
Installing software: apt, dnf and Homebrew
Software comes from your distribution’s repositories, through a package manager. It downloads, installs and updates software and everything it depends on, from sources your distribution has checked. The commands differ by family, but the jobs are the same.
| Job | Debian, Ubuntu | Fedora, RHEL, Rocky | macOS (Homebrew) |
|---|---|---|---|
| Refresh the package list | sudo apt update | dnf does this itself | brew update |
| Upgrade everything | sudo apt upgrade | sudo dnf upgrade | brew upgrade |
| Install | sudo apt install htop | sudo dnf install htop | brew install htop |
| Remove | sudo apt remove htop | sudo dnf remove htop | brew uninstall htop |
| Search | apt search htop | dnf search htop | brew search htop |
| What’s installed | apt list --installed | dnf list --installed | brew list |
| Package files | .deb (dpkg) | .rpm (rpm) | formulae and casks |
Where to practise Linux commands for free
The best way to learn these commands is somewhere you can’t break anything that matters. All of these are free, or close to it.
| If you have | Try this |
|---|---|
| Windows 10 or 11 | WSL (Windows Subsystem for Linux): run wsl –install in an administrator terminal to get Ubuntu. |
| Mac | Terminal is already there; most commands here work. UTM or Canonical’s Multipass run full Linux virtual machines free. |
| Any PC | VirtualBox (free) runs Ubuntu, Fedora or Rocky Linux in a window, with snapshots to roll back mistakes. |
| Raspberry Pi | A real Linux computer for the price of a few lunches. |
| IBM i | STRQSH, or CALL QP2TERM for PASE, gives a Unix-style shell. SSH plus IBM’s open-source packages (installed with yum) adds bash, git and vim. |
| Cloud | Most cloud providers offer a free tier or trial credit for a small Linux virtual server. |
Download the Ultimate Linux Cheat Sheet

Keep it beside the keyboard
The essentials of this page as a 36-page A5 booklet: the 100 commands, vim and nano keys, Git and the AS/400 cross-reference, with a pin-up survival card on the back.
Download the PDF (36 pages, free, no sign-up)Edition 1 · November 2026. Print at A5, or two pages to a sheet of A4. Free to print and share for non-commercial use, including in schools, colleges and user groups, under the CC BY-NC-ND 4.0 licence: credit IT Management 101, don’t sell it and don’t share altered versions. The QR code inside brings you back here for the latest edition.
Linux commands: your questions answered
What are the most useful Linux commands to learn first?
Start with ten: pwd, ls, cd, cp, mv, rm, mkdir, cat, less and man. Add grep, find, sudo, nano, tail -f and systemctl next. Together they cover moving around, reading and editing files, finding things and managing services, which is most day-to-day work on a server.
How do I exit vim?
Press Esc to make sure you are in Normal mode, then type :q and press Enter to quit. Use :wq to save and quit, or :q! to quit without saving. If nothing happens, press Esc twice and try again.
What is the difference between Linux and Unix?
Unix is the original operating system family, created at Bell Labs in 1969; the name is now a trademark certified by The Open Group. Linux is a free, Unix-like kernel written by Linus Torvalds in 1991 and, combined with GNU tools, behaves much like Unix without being certified as one. Most commands work the same on both.
Is macOS Linux?
No. macOS is built on Darwin, which combines the Mach kernel with code from BSD Unix. It held UNIX 03 certification from Mac OS X 10.5 Leopard (2007), though Apple’s entries left The Open Group’s register in October 2026. Most Linux commands work in the Mac Terminal, but some flags differ and Linux-only tools such as ip, systemctl and apt are missing.
What is the Linux equivalent of ipconfig?
Use ip a (short for ip address) to see interfaces and addresses, and ip r to see routes. The older ifconfig command still exists on some systems but has been replaced by ip on most modern distributions. On IBM i the nearest equivalents are CFGTCP and NETSTAT *IFC.
What is the Linux equivalent of WRKACTJOB?
top gives the closest experience: a live, refreshing list of processes sorted by CPU use. htop is friendlier if it is installed, and ps aux gives a one-off snapshot you can search with grep.
What is the difference between sudo and su?
sudo runs a single command as root using your own password, and logs it. su switches your whole session to another user, usually needing that user’s password. sudo is safer and is the default on Ubuntu, where the root account is locked.
How do I check which Linux version I am running?
cat /etc/os-release shows the distribution and version, uname -r shows the kernel release, and hostnamectl shows both on systems that use systemd.
How do I find a file in Linux?
Use find with a starting directory and a name pattern: find / -name “report*.pdf” 2>/dev/null searches the whole system and hides permission errors. Add -iname to ignore case, or -mtime -7 for files changed in the last week. If plocate or mlocate is installed, locate report searches a prebuilt index and answers almost instantly.
How do I extract a tar.gz file?
Run tar -xzf file.tar.gz to extract it into the current directory, or add -C /path/to/folder to extract it somewhere else (the folder must exist). Use tar -tzf file.tar.gz first to list what is inside without extracting anything.
Is there a free printable Linux cheat sheet PDF?
Yes. The A5 Ultimate Linux Cheat Sheet on this page is free to download, with no sign-up. It prints as an A5 booklet or two pages to a sheet of A4, and its QR code brings you back here for the latest edition.
Further reading
Official references
If there is a command you use every week that isn’t here, or an AS/400 command you’d like mapped, leave a comment below and I’ll consider it for the next edition.
