Fundamentals 14 min read

Master Essential Linux Commands in 8 Minutes: A Quick Cheat Sheet

This concise guide walks you through the most commonly used Linux commands—such as ls, cd, pwd, mkdir, cp, mv, rm, du, df, cat, echo, grep, and more—explaining their key options, typical usage patterns, and helpful examples for everyday shell operations.

MaGe Linux Operations
MaGe Linux Operations
MaGe Linux Operations
Master Essential Linux Commands in 8 Minutes: A Quick Cheat Sheet

1. ls – similar to the DOS dir command. Frequently used options are -a, -l, and -F. -a shows hidden files (those beginning with a dot). -l displays detailed file information. -F appends symbols to indicate file types (e.g., * for executables, / for directories, @ for links).

2. cd – changes the current working directory. Examples: cd aaa enters directory aaa; cd or cd ~ returns to the user’s home directory; cd - goes back to the previous directory; cd .. moves up one level.

3. pwd – prints the current working directory.

4. mkdir and rmdir – mkdir creates directories, rmdir removes empty directories. Both support the -p option: mkdir -p 1/2/3 creates the whole path, while rmdir -p 1/2/3 removes nested empty directories.

5. cp – copies files or directories. Examples: cp 1.txt ../test2 copies a file to another directory; cp 1.txt 2.txt copies and renames; cp -r a b copies directory a to b.

6. mv – moves or renames files. Examples: mv 1.txt ../test1 moves a file; mv 1.txt 2.txt renames a file; mv 1.txt ../test1/2.txt moves and renames simultaneously.

7. rm – deletes files. Common options: -i (prompt before deletion), -r (recursive, also removes directories), -f (force, no prompt). Deletions are irreversible.

8. du and df – du shows disk space used by directories; df shows available disk space. du -hs ./* lists sizes of all items in the current directory. Options -k, -m, and -h control units (kilobytes, megabytes, human‑readable).

9. cat – concatenates and displays file contents. Examples: cat file1, cat file1 file2, cat file1 file2 > file3. Redirection symbols > (overwrite) and >> (append) control output.

10. echo – prints strings to standard output, often used in scripts. Syntax: echo [-ne] [string]. Options: -n (no trailing newline), -e (enable escape sequences such as \n, \t, etc.).

11. more, less, clear – more and less paginate long file output; less allows scrolling with arrow keys. clear clears the terminal screen, analogous to DOS cls.

12. head and tail – head shows the first n lines of a file, tail shows the last n lines (default 10). Use -n to specify a different count, e.g., head -100 file. tail -f follows a file in real time.

13. wc – counts lines ( -l), words ( -w), and bytes ( -c) in files. Options can be combined; output order follows the option order.

14. grep – searches files for patterns using regular expressions. Returns matching lines and sets exit status (0 = match, 1 = no match, 2 = error). Example: ls -l | grep '^a' shows entries starting with “a”.

15. man and logout – man displays the manual page for a command (e.g., man ls). logout exits the current shell session.

16. Pipes and xargs – the pipe symbol | passes the output of one command as input to another (e.g., ls | grep a). xargs builds command lines from standard input, useful for handling large argument lists (e.g., ls | xargs rm).

17. basename and dirname – basename extracts the filename without its path; dirname extracts the directory path. Examples: basename /home/hj/1.txt1.txt, dirname /home/hj/1.txt/home/hj.

18. set (without arguments) – displays all shell variables and functions.

Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

Linuxcommand-lineUnixbasics
MaGe Linux Operations
Written by

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.

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.