Fundamentals 15 min read

Essential Linux Commands: Classification, Usage, and Tips

This article provides a comprehensive guide to common Linux commands, covering internal vs external classification, help lookup methods, command syntax, practical examples for file management, system monitoring, compression, shutdown, pipelines, quoting, and best learning habits.

ZhiKe AI
ZhiKe AI
ZhiKe AI
Essential Linux Commands: Classification, Usage, and Tips

Command Classification

Internal commands – part of the shell interpreter.

External commands – independent executable files.

Distinguish internal vs external with type : <code>type cd cd is a shell builtin type cat cat is /bin/cat</code> Help for internal commands: <code>man cd help cd info cd</code> Help for external commands: <code>man cat info cat cat --help</code>

Command Syntax

Format: command [options] [arguments] <code>ls -al /</code>

Common Commands

ls – List files or directories

Options: -l – detailed list. -a – include hidden entries.

Examples:

mkdir aaa
cd aaa/
touch 1.txt
ls
1.txt
ls -a
. .. 1.txt
ls -l
total 0
-rw-rw-r--. 1 user user 0 Feb 7 15:03 1.txt

cd – Change directory

Examples:

Go to the user home directory:

cd
# or
cd ~

Enter directory aaa: cd aaa/ Return to previous directory: cd - Go up one level: cd .. Switch to another user's home:

cd ~test/

pwd – Print working directory

cd tmp
pwd

mkdir – Make directory

Option -p – create parent directories as needed.

Examples:

Create a single directory: mkdir bbb Create nested directories:

mkdir -p ccc/ddd

rmdir – Remove empty directory

rmdir bbb

Fails if the directory is not empty.

touch – Create an empty file

touch 1.txt

rm – Remove files or directories

Options: -f, --force – force deletion. -r, -R – recursive delete.

Examples:

Delete a file: rm 1.txt Delete a directory recursively:

rm -r ccc/

cat – Concatenate and display file contents

echo aaaa > 1.txt
cat 1.txt

head – Show the first N lines (default 10)

Option -n, --lines=[-]K – show first K lines; a leading - excludes the last K lines.

Examples:

Show first 10 lines of a log: head /var/log/messages Show first 5 lines: head -n 5 /var/log/messages Exclude the last 5 lines:

head -n -5 /var/log/messages

tail – Show the last N lines (default 10)

Option -n, --lines=[+]K – show last K lines; a leading + starts from line K to the end. -f – follow file growth. -F – like -f but continues after log rotation.

Examples:

Show last 10 lines: tail /var/log/messages Show last 5 lines: tail -n 5 /var/log/messages Follow a file:

tail -f /var/log/messages

more – Page through output

Option -num – number of lines per screen.

Commands: SPACE – next screen. q – quit. / – search. = – show line number. ! or :! – run a command in a subshell.

less – Page through output with backward scrolling

Commands: b – scroll back one screen. f – scroll forward one screen. / – search.

echo – Display a line of text

echo hello world

cp – Copy files

Copy a single file: cp 1.txt /cc Copy multiple files using brace expansion:

cp ./{1.txt,2.txt} /cc

mv – Move or rename files

Move a file: mv 1.txt /cc Move multiple files: mv ./{1.txt,2.txt} cc/ Rename a file:

mv 1.txt a.txt

find – Search for files

Find a specific file: find 1.txt Wildcard search:

find *.txt

wc – Count lines, words, characters

Options: -m – characters. -w – words. -l – lines.

wc 1.txt

grep – Search text using patterns

Option -i – ignore case.

grep -i a 1.txt

ln – Create links

Option -s – create symbolic link.

Default creates a hard link; hard links remain valid if the source file is deleted, while symbolic links become dangling.

ln 1.txt x.txt
1.txt

is the source; x.txt is the link.

System Management Commands

stat – Detailed file information (more than ls )

stat 1.txt

who – Show logged‑in users

who

whoami – Show current user

whoami

hostname – Show or set the host name

Show: hostname Temporarily change:

hostname tempname

uname – Show system information

uname -a

top – Interactive process viewer (press q to quit)

top

ps – Snapshot of processes

ps -aux

du – Estimate directory size

Option -h – human‑readable units.

du -h /home

df – Report file system disk space usage

Option -h – human‑readable.

df -h

ifconfig – Network interface configuration

Show current configuration: ifconfig Temporarily set IP address:

ifconfig eth0 192.168.1.125

ping – Test network connectivity

ping 192.168.1.1

netstat – Network statistics

Options: -a – all sockets. -l – listening services. -t – TCP connections. -p, --programs – show PID and program name.

netstat -altpn

clear – Clear the terminal screen

clear

alias – Define command shortcuts

alias showmeit="ps -aux"

unalias – Remove an alias

unalias showmeit

kill – Terminate processes

kill -9 5231

5231 is the process ID.

free – Show memory and swap usage

free

Packaging and Compression Commands

gzip

bzip2

tar

Tar options: -c, --create – create archive. -x, --extract, --get – extract archive. -z – gzip compression. -j – bzip2 compression. -v – verbose (show progress).

Create archive: tar -cvf 1.txt.tar 1.txt Extract archive: tar -xvf 1.txt.tar Extract to a specific directory: tar -xvf 1.txt.tar -C bb/ Gzip archive: tar -zcvf 1.txt.tar.gz 1.txt Extract gzip archive: tar -zxvf 1.txt.tar.gz 1.txt Bzip2 archive: tar -jcvf 1.txt.tar.gz 1.txt Extract bzip2 archive:

tar -jxvf 1.txt.tar.gz 1.txt

Shutdown / Reboot Commands

shutdown

– schedule shutdown or reboot. -r – reboot. -h – halt (no reboot). now – immediate action. halt – halt the system. reboot – reboot the system. poweroff – power off.

Linux Pipelines and Redirection

|

– pipe output of one command to the next. > – redirect output to a file (overwrite). >> – append output to a file.

Command substitution with backticks: echo `date` Single quotes suppress special characters: echo '$PATH' Double quotes allow variable expansion but preserve most characters:

echo "$PATH"

Good Linux Learning Habits

Read manual pages ( man) and other help documents.

Use the Tab key for auto‑completion.

Master useful shortcuts: Ctrl+C – interrupt current process. Ctrl+R – search command history. Ctrl+L – clear screen (same as clear).

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.

LinuxShellcommand-linenetworkingSystem Administrationcompressionfile management
ZhiKe AI
Written by

ZhiKe AI

We dissect AI-era technologies, tools, and trends with a hardcore perspective. Focused on large models, agents, MCP, function calling, and hands‑on AI development. No fluff, no hype—only actionable insights, source code, and practical ideas. Get a daily dose of intelligence to simplify tech and make efficiency tangible.

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.