Galle, LK--:--5/6 sites live

70 Essential Linux Commands Quick Reference

Use the table below for rapid lookup during server maintenance, shell scripting, or technical interviews.

3 Jun 20266 min readSelf Guide · Stage 1#Linux#Bash#W3DevOps

Lesson 3 of 26 · Module: Linux

10 min read

Use the table below for rapid lookup during server maintenance, shell scripting, or technical interviews.

#CommandCategoryDevOps Syntax ExampleWhat It Does
1lsFilesystemls -lah /var/logList directory contents including hidden dotfiles with file sizes.
2pwdFilesystempwdPrint current working directory absolute path.
3cdFilesystemcd /etc/nginx && cd -Change directory; cd - returns to previous path.
4touchFilesystemtouch app.js .envCreate blank files or update modification timestamp.
5echoFilesystemecho "PORT=3000" >> .envPrint text or append strings to files.
6nanoEditingnano config.iniSimple beginner terminal text editor.
7vimEditingvim deployment.yamlIndustry standard modal text editor available on all UNIX systems.
8catFilesystemcat /etc/os-releasePrint file contents to stdout.
9shredSecurityshred -u -z token.txtSecurely overwrite and destroy sensitive credential files.
10mkdirFilesystemmkdir -p /opt/app/logsCreate nested directories without failing if parents exist.
11cpFilesystemcp -r src/ dist/Copy files and directories recursively.
12mvFilesystemmv server.js index.jsMove or rename files and directories.
13rmFilesystemrm -rf /tmp/cache_*Force delete files and directories recursively.
14rmdirFilesystemrmdir empty_dir/Remove empty directories safely.
15lnFilesystemln -s /etc/nginx/sites-available/x /etc/nginx/sites-enabled/Create symbolic links for virtual hosts.
16clearTerminalclearClear terminal screen buffer (Shortcut: Ctrl+L).
17whoamiUserswhoamiDisplay currently logged-in effective username.
18useraddUserssudo useradd -m deployerCreate new system user account with home folder.
19sudoSecuritysudo apt updateExecute command with elevated superuser (root) privileges.
20adduserUserssudo adduser devops_userInteractive user creation script.
21suUserssu - postgresSwitch to another user context with full login shell.
22whoUserswhoList all users currently logged into the server.
23exitTerminalexitExit current shell session or close SSH connection.
24passwdSecuritysudo passwd ubuntuChange user account password.
25getent passwdUsersgetent passwd | grep ubuntuQuery user database entries from NSSwitch sources.
26idUsersid ubuntuShow numeric UID, primary GID, and secondary groups.
27userdelUserssudo userdel -r old_userDelete user account and remove their home folder.
28fingerUsersfinger ubuntuInspect user account details and login history.
29aptPackagessudo apt update && sudo apt install -y nginxManage Debian/Ubuntu software packages.
30manHelpman curlDisplay comprehensive system manual page for a command.
31whatisHelpwhatis iptablesOne-line summary description of a command.
32whichHelpwhich python3Print full absolute path of the executable found in $PATH.
33whereisHelpwhereis nginxLocate binary, source code, and manual page paths.
34wgetNetworkingwget https://example.com/archive.tar.gzDownload files from the web via CLI.
35curlNetworkingcurl -IL https://api.company.comTransfer data and test REST API endpoints / headers.
36zipArchiveszip -r app.zip ./distPackage and compress files into a zip archive.
37unzipArchivesunzip app.zip -d /var/wwwExtract compressed zip archive.
38lessFilesystemless /var/log/syslogView large log files page-by-page without filling memory.
39headFilesystemhead -n 20 error.logView first N lines of a file.
40tailFilesystemtail -f -n 50 /var/log/nginx/access.logStream and follow live updates appended to a file.
41cmpComparisoncmp fileA.bin fileB.binCompare two files byte by byte.
42diffComparisondiff -u old.conf new.confShow unified differences between two configuration files.
43sortTextsort -n -r numbers.txtSort lines of text alphabetically or numerically.
44findFilesystemfind / -name "*.pem" 2>/dev/nullSearch entire filesystem for files matching criteria.
45chmodSecuritychmod 600 id_rsa && chmod 755 run.shChange file permission bits for Owner, Group, and Others.
46chownSecuritysudo chown -R www-data:www-data /var/wwwChange file and directory user and group ownership.
47ifconfigNetworkingifconfigLegacy utility to inspect network interfaces and IPs.
48ip addressNetworkingip a show eth0Modern utility to inspect network interfaces and IPv4/IPv6.
49grepTextgrep -rn "ERROR" /var/log/Filter text and recursively search directories using regex.
50awkTextawk '{print $1, $7}' access.logProcess and extract columnar fields from logs.
51resolvectl statusNetworkingresolvectl statusCheck active systemd DNS servers and resolution protocols.
52pingNetworkingping -c 4 1.1.1.1Test ICMP network reachability and packet latency.
53tracerouteNetworkingtraceroute aws.amazon.comInspect network hop routing path and intermediate latency.
54netstatNetworkingnetstat -tulpnDisplay active network connections and listening ports.
55ssNetworkingsudo ss -tulpnModern high-performance replacement for netstat.
56ufwSecuritysudo ufw allow 80/tcp && sudo ufw enableConfigure Uncomplicated FireWall rules.
57unameSystemuname -mrsDisplay kernel release name, version, and architecture.
58neofetchSystemneofetchDisplay aesthetic system hardware and OS summary.
59calSystemcal 2026Display command-line calendar.
60freeMonitoringfree -hInspect total, used, and free RAM and Swap space.
61dfMonitoringdf -h /Inspect partition disk usage and available capacity.
62psMonitoringps aux | grep nginxSnapshot of all running processes across all users.
63topMonitoringtopReal-time dynamic display of running system processes.
64htopMonitoringhtopInteractive colored terminal process viewer with mouse support.
65killProcesseskill -9 14522Send termination signal (SIGKILL) to process ID.
66pkillProcessespkill -f "python worker.py"Terminate processes matching regex pattern.
67systemctlServicessudo systemctl restart dockerControl systemd service daemons (start, stop, status).
68historyTerminalhistory | grep sshDisplay command history list with timestamps and line IDs.
69rebootSystemsudo rebootSafely restart operating system instance.
70shutdownSystemsudo shutdown -h nowHalt and power off virtual machine.

Keep going: ← Lesson 2 · Lesson 4 → · Module overview · Track it in the Self Guide