Linux Commands Cheat Sheet: The Top 100, Plus Vim, Nano, Git and AS/400 Equivalents

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, less and man. Everything else builds on them.
  • Modern Linux has replaced several classics: use ip not ifconfig, ss not netstat, and systemctl and journalctl for 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 is journalctl, SBMJOB is nohup and WRKJOBSCDE is cron.
  • In Git, git revert is the safe way to undo anything already shared; git reset is only for commits nobody else has.
Cover of the Ultimate Linux Cheat Sheet A5 mini-ebook

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.

Share it with someone learning Linux:LinkedInFacebookXWhatsAppEmail

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

KeysWhat they do
TabComplete a command or file name; press twice to see options
↑ / ↓Step through previous commands
Ctrl+RSearch your command history as you type
Ctrl+CStop the running command
Ctrl+ZPause it (then bg or fg)
Ctrl+DEnd input; at an empty prompt, log out
Ctrl+A / Ctrl+EJump to the start / end of the line
Ctrl+UDelete from the cursor back to the start of the line
Ctrl+LClear the screen
!!Repeat the last command (sudo !! reruns it as root)

Bash cheat sheet: pipes, redirection and wildcards

You typeWhat it means
cmd > fileSend output to a file, replacing what was there
cmd >> fileAppend output to the end of a file
cmd 2> err.logSend error messages to a file
cmd > all.log 2>&1Send output and errors to the same file
cmd < fileFeed a file in as input
cmd1 | cmd2Pipe: the output of one becomes the input of the next
cmd1 && cmd2Run cmd2 only if cmd1 succeeded
cmd1 || cmd2Run 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 | head

Each 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)

#CommandWhat it doesExampleNotes
1manRead a command’s manual. Space pages down, /word searches, q quits.man tarIBM i: F1 help
2aproposSearch the manuals by keyword when you don’t know a command’s name (same as man -k).apropos compressSame on macOS
3whichShow the full path of the program a command runs.which python3Same on macOS
4typeSay whether a name is an alias, a shell built-in or a program.type llSame on macOS
5historyList your recent commands. !42 reruns number 42; Ctrl+R searches as you type.history | grep sshIBM i: F9 retrieve
6tldrShort, example-first help pages written by the community; quicker than man.tldr tarinstall
7pwdPrint the directory you are in (the working directory).pwdSame on macOS
8echoPrint text or the value of a variable.echo $PATHSame on macOS
9aliasMake a shortcut for a longer command. Add it to ~/.bashrc to keep it.alias ll='ls -alF'Same on macOS
10exportSet an environment variable for this shell and the programs it starts.export EDITOR=nanoSame on macOS

Files and directories (11–26)

#CommandWhat it doesExampleNotes
11lsList files. -l long format, -a include hidden, -h readable sizes, -t newest first.ls -lahtIBM i: WRKLNK, DSPLIB
12cdChange directory. cd ~ goes home, cd .. up one level, cd – back to the last one.cd /var/logIBM i: CD (CHGCURDIR)
13mkdirMake a directory; -p creates any missing parent directories too.mkdir -p projects/2026/q4IBM i: MKDIR, CRTLIB
14rmdirRemove an empty directory.rmdir old-reportsIBM i: RMVDIR
15touchCreate an empty file, or update an existing file’s timestamp.touch notes.txtSame on macOS
16cpCopy. -r for directories, -i to ask before overwriting, -p to keep permissions and timestamps.cp -rp site/ site-backup/IBM i: CPY, CPYF
17mvMove or rename. Add -i to be asked before anything is overwritten.mv draft.txt final.txtIBM i: MOV, RNM
18rmDelete files. There is no recycle bin. -r for directories, -i asks first.rm -i *.tmpcarefulIBM i: DEL, DLTF
19lnCreate 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/currentIBM i: ADDLNK
20findSearch for files by name, size, age, owner or type, then act on them.find /var/log -name "*.log" -mtime -1IBM i: WRKLNK, WRKOBJ
21locateSearch a prebuilt index of file names, very fast. sudo updatedb refreshes it.locate nginx.confinstall
22treeShow a directory and its contents as a tree.tree -L 2install
23fileIdentify what a file really contains, whatever its name says.file invoice.pdfSame on macOS
24statShow a file’s size, permissions, owner and timestamps.stat report.csvmacOS: Output differs; stat -x for a similar layout.
25duShow how much disk space files and directories use.du -sh * | sort -hIBM i: RTVDSKINF
26dfShow free space on each mounted file system.df -hIBM i: WRKDSKSTS, WRKSYSSTS

Viewing and searching text (27–42)

#CommandWhat it doesExampleNotes
27catPrint a file to the screen; also joins files together.cat /etc/os-releasemacOS: No /etc/os-release; use sw_vers.IBM i: DSPF, DSPPFM
28lessPage 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/syslogIBM i: DSPF
29headShow the first lines of a file (10 unless you say otherwise).head -n 20 data.csvSame on macOS
30tailShow the last lines; -f keeps following new lines as they are written.tail -f /var/log/nginx/error.logSame on macOS
31wcCount lines, words and bytes.wc -l access.logSame on macOS
32grepSearch text for a pattern. -i ignore case, -r recurse, -n line numbers, -v invert.grep -rin "error" /var/log/nginx/IBM i: FNDSTRPDM
33sortSort lines. -n numeric, -r reverse, -k column, -t separator, -h readable sizes.sort -t, -k3,3n sales.csvSame on macOS
34uniqCollapse adjacent duplicate lines; -c counts them. Sort the input first.sort ips.txt | uniq -c | sort -rnSame on macOS
35cutPull columns out of each line.cut -d: -f1 /etc/passwdSame on macOS
36trTranslate or delete characters.tr 'a-z' 'A-Z' < names.txtSame on macOS
37sedStream editor: find and replace in a pipe, or in a file with -i.sed -i 's/http:/https:/g' links.txtmacOS: In-place edit needs an empty backup suffix: sed -i ” ‘s/a/b/’ file
38awkA small language for columns: ideal for logs and CSV (comma-separated values) files.awk -F, '$3 > 1000 {print $1}' sales.csvSame on macOS
39diffCompare two files line by line; -u gives the readable unified format.diff -u old.conf new.confIBM i: CMPPFM
40teeSend 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/hostsSame on macOS
41xargsTurn lines of input into arguments for another command.find . -name "*.tmp" -print0 | xargs -0 rmSame on macOS
42jqQuery and pretty-print JSON (JavaScript Object Notation), the format most web APIs (application programming interfaces) return.jq '.version' package.jsoninstall

Users, permissions and security (43–54)

#CommandWhat it doesExampleNotes
43whoamiShow which user you are logged in as.whoamiSame on macOS
44idShow your user ID, group ID and every group you belong to.idIBM i: DSPUSRPRF
45sudoRun one command as root (the superuser), with your own password, and log it.sudo apt updateSame on macOS
46suSwitch 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 - priyaSame on macOS
47passwdChange your password, or another user’s with sudo.passwdIBM i: CHGPWD
48chmodChange permissions, as numbers (640) or letters (u+x).chmod 640 payroll.csvIBM i: CHGAUT, GRTOBJAUT
49chownChange a file’s owner and group.sudo chown -R www-data:www-data /var/www/siteIBM i: CHGOWN, CHGPGP
50ufwOpen 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/tcpLinux onlymacOS: Use the Firewall pane in System Settings
51useraddCreate a user account. Debian and Ubuntu also offer the friendlier adduser.sudo useradd -m -s /bin/bash priyaLinux onlymacOS: Use sysadminctl -addUserIBM i: CRTUSRPRF
52usermodAdd 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 priyaLinux onlyIBM i: CHGUSRPRF
53getentLook up users, groups and hosts from every configured source.getent passwd priyaLinux onlymacOS: Use dscacheutil -q user
54ssh-keygenCreate an SSH key pair for safer, password-free logins.ssh-keygen -t ed25519 -C "priya@laptop"Same on macOS

Processes and jobs (55–68)

#CommandWhat it doesExampleNotes
55psSnapshot of running processes.ps aux --sort=-%cpu | headmacOS: No –sort; use ps aux -r | headIBM i: WRKACTJOB
56topLive view of processes and load. P sorts by CPU (processor) use, M by memory, q quits.topmacOS: Keys differ; use top -o cpuIBM i: WRKACTJOB, WRKSYSACT
57htopA friendlier top with colour, scrolling and mouse support.htopinstall
58pgrepFind process IDs by name; -a shows the full command line.pgrep -a nginxmacOS: Use pgrep -lf nginx
59killSend a signal to a process. The default (TERM) asks it to stop; -9 forces it.kill 4182carefulIBM i: ENDJOB
60pkillSignal processes by name or pattern. Check with pgrep first.pkill -f "python3 report.py"careful
61jobsList the jobs you started in the background from this shell.jobs -lSame on macOS
62bgResume a stopped job (Ctrl+Z) in the background.bg %1Same on macOS
63fgBring a background job back to the foreground.fg %1Same on macOS
64nohupRun a command that carries on after you log out.nohup ./backup.sh > backup.log 2>&1 &IBM i: SBMJOB
65niceStart a command at a lower priority; renice changes one already running.nice -n 10 ./month-end.shIBM i: CHGJOB RUNPTY
66watchRerun a command every few seconds and show the latest output.watch -n 5 df -hmacOS: Install with Homebrew
67lsofList open files and the processes using them, including network ports.sudo lsof -i :443IBM i: WRKOBJLCK
68tmuxKeep terminal sessions alive after you disconnect; split the screen.tmux new -s workinstall

System information (69–78)

#CommandWhat it doesExampleNotes
69unameShow the kernel name, release and architecture.uname -aSame on macOS
70hostnamectlShow or set the host name, with OS (operating system) and kernel details.hostnamectlLinux onlymacOS: Use scutil –get ComputerName
71uptimeTime since boot, users logged in and the load averages.uptimeIBM i: WRKSYSSTS
72freeShow memory and swap use.free -hLinux onlymacOS: Use vm_stat or Activity MonitorIBM i: WRKSYSSTS
73lscpuShow the CPU model, cores and architecture.lscpuLinux onlymacOS: Use sysctl -n machdep.cpu.brand_string
74lsblkList disks and partitions as a tree; -f adds file systems.lsblk -fLinux onlymacOS: Use diskutil listIBM i: WRKDSKSTS
75dmesgShow kernel messages: hardware, drivers and disk errors.sudo dmesg -T | tail -30macOS: No -T optionIBM i: DSPMSG QSYSOPR, WRKPRB
76dateShow or format the date and time.date "+%Y-%m-%d %H:%M"IBM i: DSPSYSVAL QDATETIME
77wWho is logged in and what each of them is running.wIBM i: WRKUSRJOB
78mountList 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/usbIBM i: MOUNT

Services, logs and scheduling (79–82)

#CommandWhat it doesExampleNotes
79systemctlControl services: start, stop, restart, enable at boot, check status.sudo systemctl restart nginxLinux onlymacOS: Uses launchd; see launchctlIBM i: STRTCPSVR, ENDTCPSVR, STRSBS, ENDSBS
80journalctlRead 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
81crontabSchedule recurring jobs. -e edits, -l lists. Never -r: it deletes them all.crontab -eIBM i: WRKJOBSCDE
82shutdownPower off or restart, now or later; shutdown -c cancels.sudo shutdown -r +5 "Restarting for updates"carefulIBM i: PWRDWNSYS

Networking (83–92)

#CommandWhat it doesExampleNotes
83ipShow and change addresses, interfaces and routes. Replaces ifconfig.ip -br aLinux onlymacOS: Use ifconfigIBM i: CFGTCP, NETSTAT *IFC
84ssShow sockets and listening ports. Replaces netstat.sudo ss -tulpnLinux onlymacOS: Use netstat -an or lsof -iIBM i: NETSTAT *CNN
85pingCheck a host is reachable; -c sets how many tries.ping -c 4 bbc.co.ukIBM i: PING
86tracerouteShow each hop on the way to a host. tracepath, usually preinstalled, does much the same.traceroute bbc.co.ukinstallIBM i: TRACEROUTE
87digQuery DNS (Domain Name System) records; it comes in the dnsutils package (bind-utils on Red Hat).dig itmanagement101.co.uk MX +shortIBM i: NSLOOKUP
88curlSend and receive data from a URL (web address); good for testing sites and APIs.curl -I https://www.itmanagement101.co.ukSame on macOS
89wgetDownload files, resuming if the connection drops.wget -c https://example.com/big.isomacOS: Install with Homebrew
90sshLog in to another machine securely.ssh priya@server.example.comIBM i: ssh in PASE (IBM i’s AIX-compatible runtime); STRTCPSVR SERVER(*SSHD) starts the server
91scpCopy files to or from another machine over SSH.scp report.pdf priya@server:/tmp/Same on macOS
92rsyncCopy 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)

#CommandWhat it doesExampleNotes
93tarBundle 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
94gzipCompress a single file; gunzip reverses it. -k keeps the original.gzip -k big.logSame on macOS
95zipMake .zip archives that Windows opens natively; unzip extracts them.zip -r site.zip site/install
96aptInstall, update and remove software on Debian and Ubuntu.sudo apt updateLinux onlymacOS: Use Homebrew: brew installIBM i: PTFs; yum for open source
97dnfThe same job on Fedora, Red Hat Enterprise Linux (RHEL), Rocky and AlmaLinux.sudo dnf upgradeLinux onlymacOS: Use Homebrew: brew install

Editing and version control (98–100)

#CommandWhat it doesExampleNotes
98nanoA simple editor; its shortcuts are listed along the bottom of the screen.nano ~/.bashrcIBM i: EDTF
99vimA powerful editor on almost every server. On minimal Red Hat systems, type vi.vim notes.txtIBM i: EDTF, SEU
100gitTrack changes to files and work with others. See the Git section.git statusSame 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.

CommandWhat it does
grep -i "error" app.logIgnore upper and lower case
grep -rn "TODO" src/Search a whole directory, with line numbers
grep -v "^#" /etc/ssh/sshd_configLines that don’t match (here, hide comments)
grep -c "404" access.logCount the matching lines
grep -l "password" *.confFile names only
grep -w "cat" notes.txtWhole words only: not ‘concatenate’
grep -E "error|warn" app.logEither pattern (extended regular expressions)
grep -A 3 -B 1 "panic" app.logThree 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.

CommandWhat it does
find . -name "*.pdf"By name, from here downwards
find / -iname "readme*" 2>/dev/nullIgnore case; hide permission errors
find . -type d -name node_modulesDirectories only
find /var -size +100MBigger than 100 MB
find . -mtime -7Changed in the last seven days
find . -mmin -60Changed in the last hour
find . -name "*.tmp" -deleteDelete 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/.

CommandWhat it does
tar -czf backup.tar.gz folder/Create a gzip-compressed archive
tar -xzf backup.tar.gzExtract it here
tar -tzf backup.tar.gzList what is inside without extracting
tar -xzf backup.tar.gz -C /tmp/restoreExtract somewhere else (the directory must exist)
tar -xf file.tar.xzExtract anything: modern tar detects the compression
tar -cJf backup.tar.xz folder/xz compression: smaller, but slower
tar -xzf backup.tar.gz folder/notes.txtExtract 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.

CommandWhat it does
ssh priya@server.example.comLog in
ssh -p 2222 priya@server.example.comUse a different port
ssh-keygen -t ed25519Create a key pair (once per computer)
ssh-copy-id priya@server.example.comInstall 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.comForward a local port to the server
Host web01
    HostName web01.example.co.uk
    User priya
    Port 2222

With 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:

PartMeaning
-File type: – file, d directory, l link
rwxOwner: read, write, execute
r-xGroup: 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.

ValuePermission
r = 4Read: open a file, or list a directory
w = 2Write: change a file, or add and delete in a directory
x = 1Execute: run a file, or enter a directory
ModeShown asUse it for
644rw-r--r--Ordinary files: you edit, everyone reads
600rw-------Private files: SSH keys, passwords
640rw-r-----Shared with your group only
755rwxr-xr-xPrograms, scripts and most directories
750rwxr-x---Directories for you and your group
700rwx------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.

  1. Work as yourself, not rootUse sudo for the one command that needs it. A mistake as root has no safety net.
  2. Check where you areRun hostname and pwd before anything destructive. Many outages start in the wrong window.
  3. List before you deleteRun ls with the same pattern first; then swap ls for rm. Use rm -i when unsure.
  4. Rehearse with a dry runrsync –dry-run, find without -delete, and git status before git reset.
  5. Mind > and >>A single > replaces a file’s contents. To add to it, use >>.
  6. Never chmod -R 777It gives everyone write access to everything. Fix the owner (chown) or the group instead.
  7. crontab -e, never -rThe keys are next to each other; -r deletes every scheduled job without asking.
  8. 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.
  9. Read before you pasteCommands copied from the web, especially curl … | sh, run with your full rights.
  10. 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 questionThe command
Which directories are filling the disk?sudo du -xh --max-depth=1 / | sort -rh | head
The biggest files (over 50 MB) under /varsudo 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 hourjournalctl -u nginx -p err --since "1 hour ago"
Watch the system log for errors as they happenjournalctl -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 memoryps aux --sort=-%mem | head
A date-stamped backup of a foldersudo tar -czf "etc-$(date +%F).tar.gz" /etc
Copy your SSH key to a serverssh-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 .jpgfor 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.

The six you need
TypeWhat it does
EscBack to Normal mode. If in doubt, press it twice
iInsert text before the cursor
:wSave
:qQuit
:wq or :x or ZZSave and quit
:q!Quit without saving
The next eighteen (Normal mode)
TypeWhat it does
a / AAppend after the cursor / at the end of the line
o / OOpen a new line below / above
h j k lLeft, down, up, right (arrow keys also work)
w / bNext / previous word
0 / $Start / end of the line
gg / GTop / bottom of the file
:42Go to line 42
xDelete one character
ddDelete (cut) the line; 3dd deletes three
yyCopy (yank) the line
p / PPaste after / before
u / Ctrl+RUndo / redo
.Repeat the last change
/word, n, NSearch; next match; previous match
:%s/old/new/gReplace every ‘old’ with ‘new’
v / VSelect characters / whole lines
:set numberShow line numbers
:helpBuilt-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).

KeysWhat they do
Ctrl+O, EnterSave (Write Out)
Ctrl+XExit (asks to save if you have changes)
Ctrl+WSearch; Alt+W finds the next match
Ctrl+\Search and replace
Ctrl+KCut the current line
Ctrl+UPaste the cut text
Alt+U / Alt+EUndo / redo
Ctrl+_Go to a line number
Alt+6Copy the current line
Ctrl+GHelp: every shortcut
nano -l fileOpen 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 -t

Add a line to the end of a file

echo 'export EDITOR=nano' >> ~/.bashrc

Write several lines to a file that needs root

sudo tee /etc/motd > /dev/null <<'EOF'
Authorised users only.
EOF

Programs 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
LineWhat it does
#!/usr/bin/env bashThe ‘shebang’: run this file with bash
set -euo pipefailStop 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.shMake 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
FieldValues
Minute0–59
Hour0–23
Day of month1–31
Month1–12
Day of week0–7 (0 and 7 are Sunday)
ScheduleRuns
30 2 * * *Every day at 02:30
0 9 * * 1-509:00, Monday to Friday
*/15 * * * *Every 15 minutes
0 0 1 * *Midnight on the 1st of each month
@rebootOnce, 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.

TermMeaning
Repository (repo)A project folder that Git is tracking, with its full history in a hidden .git directory.
CommitA saved snapshot of your changes, with a message and a unique ID (the hash).
BranchA separate line of work. main is the official version; you make changes on a branch and merge them in.
RemoteA shared copy of the repository on another machine, usually called origin.
Staging areaThe 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:

CommandWhat 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 mainCall the first branch main
git config --global core.editor nanoThe editor Git opens for messages
git config --global pull.rebase falsegit pull merges, rather than stopping when branches have diverged
git config --listCheck your settings

Making your first change

  1. Create a project and a repository
    mkdir website && cd website
    git init
  2. Make a change
    echo '# My website' > README.md
    git status
  3. Stage it and commit it
    git add README.md
    git commit -m "Add README"
  4. Change it again and see what changed
    echo 'Contact: hello@example.co.uk' >> README.md
    git diff
  5. Commit the second change and look at the history
    git commit -am "Add contact line"
    git log --oneline
  6. 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.

Git working areasEdits start in the working directory, git add moves them to the staging area, git commit saves them in the local repository, and git push sends them to the remote. git pull brings others’ commits back.Where your changes live in GitWorking directorythe files you editStaging areayour next commitLocal repositoryyour saved commitsRemoteGitHub, GitLab…git addgit commitgit pushgit pull (fetch others’ commits + merge)
A change travels from your files, to the staging area, to your local history, to the shared copy.

The Git commands you’ll use every day

CommandWhat it does
git initTurn the current directory into a repository
git clone URLCopy an existing repository, with its history
git statusWhat has changed, and what is staged
git diffThe changes you haven’t staged yet
git add fileStage a change for the next commit (git add . for all)
git commit -m "Message"Save the staged changes as a snapshot
git log --oneline --graphCompact history
git switch -c feature/xCreate a branch and move to it
git switch mainMove to another branch
git pullFetch and merge others’ changes
git push -u origin feature/xSend your branch to the shared copy
git merge feature/xMerge a branch into the one you’re on
git stash / git stash popPut 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 happenedCommandWatch out
Changed a file, not staged, want it back as it wasgit restore fileDiscards your edits: they cannot be recovered
Staged a file by mistakegit restore --staged fileYour edits stay in the file
Last commit’s message is wrong, or a file is missinggit commit --amendNot yet pushed only
Undo the last commit, keep the changesgit reset --soft HEAD~1Not yet pushed only
Throw away the last commit and its changesgit reset --hard HEAD~1Destructive: also wipes uncommitted edits. Not yet pushed only
Undo a commit that is already pushed or sharedgit revert <hash>Safe: adds a new commit that reverses it
I’ve lost a commit or a branchgit 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.

  1. Branchgit switch -c fix/login-timeout
  2. CommitMake the change; git add, then git commit
  3. Pushgit push -u origin fix/login-timeout
  4. Open the pull requestOn GitHub, Bitbucket or Azure DevOps (a merge request on GitLab): say what changed and why
  5. Review and checksColleagues comment; automated tests run; you push fixes to the same branch
  6. MergeOnce approved, it merges into main (merge commit, squash or rebase)
  7. Tidy upgit 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 .gitignore file: build output, logs, .env files.
  • 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.

Unix family treeUnix from Bell Labs in 1969 led to AT&T System V (and commercial Unix such as AIX, Solaris and HP-UX) and Berkeley BSD (FreeBSD, OpenBSD and Darwin, the core of macOS). GNU and Linux were written from scratch, inspired by Unix, and became the Linux distributions.The Unix family: who descends from whomUnixBell Labs, 1969System VAT&T, 1983BSDBerkeley, 1977Commercial UnixIBM AIX · Oracle Solaris · HP-UXFreeBSD, OpenBSDopen source BSDsmacOSDarwin core, 2001GNU + Linux1983 + 1991, new codeLinux distributionsUbuntu · Debian · Fedora · RHEL · Rocky · Androidinspired by,no shared code
Linux borrowed Unix’s design, not its code. macOS inherits BSD Unix directly.

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

LinuxUnixmacOS
What it isA kernel, plus GNU and other tools, packaged as distributionsA family of operating systems descended from AT&T’s originalApple’s desktop OS, built on the Unix-derived Darwin core
Born1991 (Linus Torvalds); GNU project from 19831969, Bell Labs (Ken Thompson, Dennis Ritchie)2001 as Mac OS X; Darwin from NeXTSTEP and BSD
KernelLinux (monolithic, loadable modules)Varies: AIX, Solaris, HP-UX, the BSDsXNU (Mach plus BSD)
LicenceFree and open source (the kernel uses the GPL, the GNU General Public License)Mostly proprietary; the BSDs are open sourceProprietary; Darwin is open source
Certified UNIX?Generally no (a ‘Unix-like’ system); a rare few, such as Huawei’s EulerOS, have been certifiedYes for AIX and some others; the name is a trademark of The Open GroupUNIX 03 from Leopard (2007); entries left the Open Group register in October 2026
Default shellbash on most distributionsksh or sh on many commercial systemszsh since Catalina (2019)
Core toolsGNU coreutils: long –optionsVendor or BSD versionsBSD versions: some flags differ from Linux
Servicessystemd (systemctl, journalctl)SMF (Service Management Facility) on Solaris, SRC (System Resource Controller) on AIXlaunchd (launchctl)
Softwareapt, dnf, zypper, pacmanVendor packages; pkg on the BSDsApp Store; Homebrew (third party)
File systemsext4, XFS, BtrfsJFS2 (AIX), ZFS (Solaris, FreeBSD)APFS, the Apple File System (case-insensitive by default)
Where you meet itWeb servers, cloud, Android, Raspberry Pi, supercomputersBanks, telcos, large enterprise back endsDeveloper 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 LinuxOn macOSWhy
sed -i 's/a/b/' fsed -i '' 's/a/b/' fBSD sed needs a backup suffix, even an empty one
date -d '+1 day'date -v+1dDate arithmetic uses different flags
ls --color=autols -G-G works on every macOS; only recent versions accept –color
du -h --max-depth=1du -h -d 1BSD du uses -d, not –max-depth
stat -c '%s' filestat -f '%z' fileBSD stat uses -f and different format letters
grep -P 'regex'grep -E 'regex'BSD grep has no Perl-style regex
ip a / ss -tulpnifconfig / lsof -iNo iproute2 on macOS
systemctl / journalctllaunchctl / log showmacOS uses launchd, not systemd
free -hvm_statNo 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

DirectoryWhat’s in it
/The root: everything hangs off here, including other disks
/etcSystem-wide configuration, as plain text files
/homeUsers’ own directories (/home/priya)
/rootThe root user’s home directory
/varThings that change: /var/log for logs, /var/www for websites
/var/libApplications’ working data, such as databases (/var/lib/mysql)
/tmpTemporary files, often cleared at boot
/usrInstalled programs and libraries (/usr/bin, /usr/lib), managed by the package manager
/usr/localSoftware you install by hand, kept apart from the package manager’s
/bin, /sbinEssential commands; on modern systems, links into /usr
/optOptional, self-contained third-party software
/devDevices as files: disks (/dev/sda), terminals, /dev/null
/proc, /sysLive kernel and process information, generated on demand
/runRuntime files that vanish at reboot, such as process ID files
/libShared libraries and kernel modules; on modern systems, a link to /usr/lib
/bootThe kernel and boot loader files
/mnt, /mediaMount points for extra disks and USB (Universal Serial Bus) drives
/srvData 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:

WhatLinux and UnixWindowsmacOS
Top of the tree/C:\ (one tree per drive)/ (the startup disk)
Your files/home/priyaC:\Users\priya/Users/priya
The administrator’s home/rootC:\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, /optC:\Program Files/Applications; Homebrew in /opt/homebrew
Operating system files/usr, /lib, /bootC:\Windows, C:\Windows\System32/System (sealed, read-only)
Logs/var/log and journalctlEvent 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:

LinuxWindowsmacOS
Path separator/\ (most tools also accept /)/
Case-sensitive names?Yes: Report.txt and report.txt are two filesNo (case-preserving)No by default (APFS is case-insensitive)
Hidden filesName starts with a dot: .bashrcA hidden attribute on the fileDot files, plus a hidden flag (Cmd+Shift+. shows them in Finder)
What makes a file runnableThe execute permission (chmod +x)Its extension: .exe, .bat, .ps1The execute permission, or an .app bundle
Line endings in text filesLFCRLF (dos2unix converts)LF
Drive lettersNone: everything is under /YesNone: 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.TXT and report.txt are different files, and commands are lower case.
  • There is no F4 prompter. Press Tab to complete names, and use --help or man to see the options.
  • Nothing asks if you are sure. rm deletes immediately and there is no recovery from a recycle bin.
  • You rarely sign on as the security officer. Work as yourself and put sudo in 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 with cron or a systemd timer.
  • Output goes to the screen or a file, not a spool. Redirect it with > and read it with less.

IBM i concepts and their Linux equivalents

On IBM iOn 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 profileUser account (/etc/passwd, /etc/shadow)
QSECOFR and *ALLOBJroot, used through sudo rather than signed on as
Object authorityPermissions: owner, group, others × read, write, execute
Subsystem (QBATCH, QINTER)systemd service units and targets
JobProcess, with a PID (process ID) instead of a job number
Job queueNo direct equivalent: cron, at, batch or systemd-run
QSYSOPR message queueThe journal (journalctl) and syslog
History log (QHST)journalctl, plus files in /var/log
Spooled fileOutput usually goes to a file or log; printing is via CUPS (Common Unix Printing System)
CL programShell 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 valuesysctl settings and files in /etc
Case: commands in capitalsEverything is case-sensitive: Report.txt ≠ report.txt

AS/400 commands and their Linux equivalents

IBM i commandLinux equivalentWhat for
WRKACTJOBtop, htop, ps auxLive view of what is running
WRKSYSSTS / WRKSYSACTtop, uptime, free -h, vmstatCPU, memory and load
WRKUSRJOBps -u priya, wOne user’s processes
WRKJOBps -fp 1234, ls /proc/1234One process in detail
ENDJOBkill 1234Ask a process to stop
ENDJOB OPTION(*IMMED)kill -9 1234Force it, as a last resort
HLDJOB / RLSJOBkill -STOP / kill -CONTPause and resume a process
CHGJOB RUNPTYreniceChange priority
SBMJOBnohup cmd &, systemd-run, atRun in the background
WRKJOBSCDE / ADDJOBSCDEcrontab -l / crontab -eScheduled jobs
WRKOBJLCKlsof /path/file, fuserWho has this file open?
STRSBS / ENDSBS, STRTCPSVR / ENDTCPSVRsystemctl start / stopStart and stop services
WRKSBSsystemctl list-units --type=serviceList services
DSPLOGjournalctlSystem log
DSPJOBLOGjournalctl -u name, the app's log fileOne job’s or service’s log
DSPMSG QSYSOPRjournalctl -p warning -bOperator-level messages
WRKDSKSTSdf -h, iostat, lsblkDisk space and activity
WRKHDWRSClshw, lspci, lsblk, dmesgHardware
DSPSFWRSCdpkg -l / rpm -qaInstalled software
DSPPTF / install PTFsapt list --upgradable, apt upgrade (dnf upgrade)Updates
PWRDWNSYSshutdown -h nowPower down
PWRDWNSYS RESTART(*YES)shutdown -r now (or reboot)Restart
CRTUSRPRFuseradd (or adduser)Create a user
CHGUSRPRFusermodChange a user
DSPUSRPRFid priya, getent passwd priyaShow a user
CHGPWDpasswdChange password
GRTOBJAUT / CHGAUTchmod, setfaclGrant access
DSPAUT / DSPOBJAUTls -l, getfaclShow access
CHGOBJOWN / CHGOWNchownChange owner
CRTLIB / MKDIRmkdirCreate a directory
WRKLNK / DSPLIBls -lList contents
CPYF / CPYcpCopy
MOVOBJ / RNMOBJmvMove or rename
DLTF / DLTLIB / DELrm, rm -rDelete (no undo)
DSPPFM / DSPFcat, lessView a file
EDTF / STRSEUnano, vimEdit a file
FNDSTRPDMgrep -rnFind text in files
CMPPFMdiff -uCompare files
SAVLIB / SAVOBJ to *SAVFtar -czfSave to an archive
RSTLIB / RSTOBJtar -xzfRestore from an archive
CFGTCP / NETSTAT *IFCip addr, ip routeNetwork settings
NETSTAT *CNNss -tulpnConnections and listening ports
PINGping -c 4 hostIs it reachable?
NSLOOKUPdig, nslookupDNS lookup
DSPSYSVAL QDATETIMEdate, timedatectlDate and time
SNDMSG / SNDBRKMSGwrite / wallMessage logged-in users
STRQSH / QP2TERMbashA shell
RUNSQLSTM / STRSQLpsql, mysql, sqlite3Run SQL (Structured Query Language)

5250 keys and their terminal equivalents

5250 keyIn 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 DownSpace in less and man
System Request, option 2Ctrl+C
Attention keyCtrl+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.

Linux architecture diagramLayers from hardware up: the Linux kernel, the system call interface, libraries and core tools, systemd and services, and the shell and applications.How Linux fits togetherYou and your programsShell (bash, zsh) · Desktop (GNOME, KDE) · Apps: nginx, Python, gitsystemd (process 1) and servicessshd · journald · cron, timers · databases, web serversLibraries and core toolsglibc (C library) · GNU coreutils: ls, cp, grep…System call interface: open, read, write, fork, exec…The Linux kernelProcessschedulerMemorymanagerFilesystemsNetworkingDevicedriversHardware: CPU · memory · disks · network cardsUSER SPACEKERNEL SPACE
Programs in user space reach the hardware only by asking the kernel, through system calls.
LayerWhat it does
HardwareCPU, memory, disks and network cards. The kernel talks to them through device drivers.
The kernelProcess scheduling, memory management, file systems, networking and drivers. Running uname -r shows its version.
System callsThe narrow doorway between programs and the kernel: open a file, read, write, start a process.
Libraries and core toolsglibc, the C library almost every program uses, and the GNU core utilities such as ls, cp and grep.
systemd and servicessystemd is the first process the kernel starts (process ID 1). It starts everything else and keeps services, also called daemons, running.
Shell and applicationsThe 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.

Services you will meet
ServiceWhat it does
sshdRemote logins over SSH
systemd-journaldCollects logs from the kernel and every service
cron / systemd timersRun jobs on a schedule
NetworkManager / systemd-networkdBring network interfaces up
firewalld / ufw (nftables)The firewall
nginx / apache2 (httpd)Web servers
mariadb / postgresqlDatabases
chronyd / systemd-timesyncdKeep the clock accurate
The commands that manage them
CommandWhat it does
systemctl status nginxIs it running? Shows the last few log lines
sudo systemctl start nginxStart it now
sudo systemctl stop nginxStop it now
sudo systemctl restart nginxStop and start
sudo systemctl reload nginxRe-read configuration without dropping connections
sudo systemctl enable --now nginxStart at every boot, and start it now
sudo systemctl disable nginxDon’t start at boot
systemctl --failedList services that failed
systemctl list-units --type=serviceList loaded services
systemctl list-timersScheduled timers and when they next run
journalctl -u nginx -fFollow one service’s log live
journalctl -p err -bErrors since the last boot
journalctl --since todayEverything 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.

JobDebian, UbuntuFedora, RHEL, RockymacOS (Homebrew)
Refresh the package listsudo apt updatednf does this itselfbrew update
Upgrade everythingsudo apt upgradesudo dnf upgradebrew upgrade
Installsudo apt install htopsudo dnf install htopbrew install htop
Removesudo apt remove htopsudo dnf remove htopbrew uninstall htop
Searchapt search htopdnf search htopbrew search htop
What’s installedapt list --installeddnf list --installedbrew 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 haveTry this
Windows 10 or 11WSL (Windows Subsystem for Linux): run wsl –install in an administrator terminal to get Ubuntu.
MacTerminal is already there; most commands here work. UTM or Canonical’s Multipass run full Linux virtual machines free.
Any PCVirtualBox (free) runs Ubuntu, Fedora or Rocky Linux in a window, with snapshots to roll back mistakes.
Raspberry PiA real Linux computer for the price of a few lunches.
IBM iSTRQSH, 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.
CloudMost cloud providers offer a free tier or trial credit for a small Linux virtual server.

Download the Ultimate Linux Cheat Sheet

Cover of the Ultimate Linux Cheat Sheet A5 mini-ebook

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.

Know someone moving to Linux? Share it:LinkedInFacebookXWhatsAppEmail

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

Leave a Comment