Essential Linux Command Cheat Sheet: Paths, Files, Processes, and More
This guide compiles essential Linux shell commands covering path notation, directory navigation, file operations, process management, permissions, searching, environment variables, aliases, and useful utilities, providing a quick reference for beginners and system administrators alike.
Question 1: How are absolute, current, parent, and home directories represented, and which command changes directories?
Absolute path: e.g., /etc/init.d Current and parent directories: ./ and ../ Home directory: ~/ Change directory command: cd Question 2: How to view current processes, exit the shell, and display the current path?
View processes: ps Exit shell: exit Show current path: pwd Question 3: How to clear the screen, terminate a command, suspend a process, view user ID, and get help for a command?
Clear screen: clear Terminate command: Ctrl+C Suspend process: Ctrl+Z (resume with fg) Show user ID: id Command help: man adduser, adduser --help, or info adduser Question 4: What does ls do and which options are common? ls lists directory contents. Common options: -a (all files), -l (long format with permissions, size, etc.)
Question 5: How to create symbolic and hard links?
Symbolic link: ln -s target source Hard link: ln target source Question 6: Commands for creating directories, files, copying files, and changing permissions?
Create directory: mkdir Create file: touch or vi Copy file: cp Change permissions: chmod (e.g., chmod u+x file, chmod 751 file)
Examples of chmod usage: chmod u+x file – add execute permission for owner chmod 751 file – set rwx for owner, r-x for group, --x for others chmod u=rwx,g=rx,o=x file chmod =r file – read for all chmod -R u+r directory – recursively add read permission for owner
Question 8: Commands to view file contents? vi filename (edit), cat filename (show all), more filename, less filename, tail filename, head filename Question 9: How to write to a file and echo a string with spaces?
Write file: vi Echo with spaces: echo hello world Question 10: Where are the terminal device and the null device located?
Terminal: /dev/tty Null device: /dev/null Question 11: Commands to move/rename files?
Move/rename: mv Question 12: Copy files and directories, with prompts?
Copy file: cp Copy recursively: cp -r (add -i for interactive prompts)
Question 13: Delete files, directories, and empty directories?
Delete file: rm Delete recursively: rm -r Remove empty directory: rmdir Question 14: Common shell wildcards and their meanings? ? – single character * – any number of characters [charset] – any single character in the set (e.g., [a-z])
Question 15: How to count lines, words, and bytes in a file?
Use wc ( -l lines, -w words, -c bytes)
Question 16: What does grep do and how to ignore case or invert match? grep searches text using patterns. Ignore case: grep -i pattern file Invert match: grep -v pattern file Question 17: Linux process states and their symbols?
Uninterruptible: D Running: R Sleeping: S Stopped/Traced: T Zombie: Z Swapped (obsolete): W Dead: X
Question 18: How to run a command in the background?
Append & to the command (e.g., mycmd &)
Question 19: Show all processes and filter by PID?
All processes: ps -ef (System V) or ps -aux (BSD) Filter by PID: ps -ef | grep pid Question 20: Command to list background jobs? jobs -l Question 21: Bring a background job to the foreground or resume a stopped job?
Foreground: fg Resume in background: bg Question 22: Terminate a process? kill with signal (e.g., kill -9 pid)
Question 23: List all supported signals? kill -l Question 24: Search for files? find [path] [conditions] [actions] Other tools: whereis, locate Question 25: Who is logged in and which terminal am I on?
Current user terminal: who am i All logged‑in users: who Question 26: Show command history? history Question 27: Disk usage and free space? df -hl Question 28: Check network connectivity? netstat Question 29: Show IP addresses and interfaces? ifconfig Question 30: View environment variables?
All: env Specific: env VAR_NAME Question 31: Customize the shell prompt?
Prompt escape sequences: \u (user), \h (host), \W (basename of cwd), \w (full cwd, ~ for home), \$ (prompt char), \# (command number), \d (date), \t (24‑h time), \T (12‑h time), \A (HH:MM), \v (bash version)
Question 32: Where does the shell look for executable files and how to modify the search path?
Use whereis with options (e.g., -b binaries, -m manuals) and which to locate commands in $PATH.
Question 33: Find the location of an executable? which command (executable only) and whereis command (binary, source, docs).
Question 34: Create an alias? alias la='ls -a' Question 35: Difference between du and df? du reports disk usage of files/directories. df reports filesystem‑level space information, including metadata.
Question 36: Brief awk overview.
Pattern‑action syntax: awk '{pattern + action}' file Example: cat /etc/passwd | awk -F ':' '{print $1"\t"$7}'
Question 37: Bind a macro or key in Bash?
Use bind (e.g., bind '"\e[24~":"date"') after obtaining the key’s escape sequence with Ctrl+V or showkey -a.
Question 38: List all available commands for a new Linux user? compgen -c Question 39: Print the current directory stack? dirs (managed with pushd / popd)
Question 40: Remove all running processes without rebooting? disown -r detaches jobs from the shell.
Question 41: Purpose of the hash builtin?
Maintains a hash table of command paths; hash displays commands and hit counts.
Question 42: Bash builtin for arithmetic? let performs integer arithmetic.
Question 43: View a large file page by page?
Pipe cat filename to more (or less).
Question 44: Which user owns the data dictionary?
It belongs to the system user SYS (and SYSEM).
Question 45: Get a brief description of an unknown command?
Use whatis command (e.g., whatis zcat).
Question 46: Check filesystem quota? repquota (requires root for other users).
Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
MaGe Linux Operations
Founded in 2009, MaGe Education is a top Chinese high‑end IT training brand. Its graduates earn 12K+ RMB salaries, and the school has trained tens of thousands of students. It offers high‑pay courses in Linux cloud operations, Python full‑stack, automation, data analysis, AI, and Go high‑concurrency architecture. Thanks to quality courses and a solid reputation, it has talent partnerships with numerous internet firms.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
