Master Essential Linux Commands: From Navigation to File Management
This guide provides a comprehensive overview of essential Linux commands for directory navigation, file manipulation, permission management, searching, compression, and system shutdown, complete with descriptions, usage examples, and options to help users efficiently manage their Unix-like environments.
1. Common Commands
1. Directory operation commands
1.1.1 ls command
ls is the most common directory operation command, used to list the contents of a directory.
Command name: ls
English meaning: list
Location: /bin/ls
Description: display directory contents
Code:
# ls [options] [filename or directory name]
-a show all files
--color=when support colored output, when defaults to always (always show color), can be never or auto
-d show directory information, not the files inside
-h human‑readable format
-i show inode number
-l long format display Demo:
# ls -l
total 16
drwxr-xr-x. 2 root root 29 Dec 23 11:24 123
-rw-------. 1 root root 1687 Nov 25 21:49 anaconda-ks.cfg
...1.1.2 cd command
cd changes the current directory.
Command name: cd
English meaning: change directory
Location: built‑in shell command
Permissions: all users
Description: switch current directory
# cd [filename or directory name]
~ home directory
- previous directory
. current directory
.. parent directory1.1.3 Absolute and relative paths
Absolute path: starts from the root directory.
Relative path: based on the current directory.
1.1.4 pwd command
pwd prints the current working directory.
Command name: pwd
English meaning: print working directory
Location: /bin/pwd
Permissions: all users
Description: query current directory
1.1.5 mkdir command
mkdir creates a directory.
Command name: mkdir
English meaning: make directory
Location: /bin/mkdir
Permissions: all users
Description: create empty directory
# mkdir [options] directory_name
Options:
-p create parent directories as needed1.1.6 rmdir command
rmdir removes an empty directory.
Command name: rmdir
English meaning: remove directory
Location: /bin/rmdir
Permissions: all users
Description: delete empty directory
# rmdir [options] directory_name
Options:
-p remove parent directories recursively2. File operation commands
1.2.1 touch command
touch creates an empty file or updates its timestamps.
Command name: touch
English meaning: change file timestamps
Location: /bin/touch
Permissions: all users
Description: create empty file or modify timestamps
# touch filename1.2.2 stat command
stat displays detailed file information, including three timestamps.
Command name: stat
English meaning: display file or file system status
Location: /bin/stat
Permissions: all users
Description: show file details
# stat b1001
File: "b1001"
Size: 41 Blocks: 8 IO Block: 4096 regular file
Device: 803h/2051d Inode: 33582185 Links: 1
Access: (0644/-rw-r--r--) Uid: (0/ root) Gid: (0/ root)
...1.2.3 cat command
cat concatenates files and prints to standard output.
Command name: cat
English meaning: concatenate files and print on the standard output
Location: /bin/cat
Permissions: all users
Description: display file contents
# cat [options] filename
Options:
-A show all hidden characters
-E display $ at end of each line
-n show line numbers
-T display tabs as ^I
-v show non‑printing characters1.2.4 more command
more displays file contents page by page.
Command name: more
English meaning: file perusal filter for CRT viewing
Location: /bin/more
Permissions: all users
Description: paginate file display
more opens an interactive page
Space next page
b previous page
Enter scroll one line
/str search string
q quit1.2.5 less command
less is similar to more but allows backward movement.
Command name: less
English meaning: opposite of more
Location: /bin/less
Permissions: all users
Description: view file contents with scrolling
1.2.6 head command
head shows the beginning of a file.
Command name: head
English meaning: output the first part of files
Location: /usr/bin/head
Permissions: all users
Description: display file header
# head -n 19 anaconda-ks.cfg
#version=DEVEL
# System authorization information
auth --enableshadow --passalgo=sha512
...1.2.7 tail command
tail shows the end of a file.
Command name: tail
English meaning: output the last part of files
Location: /usr/bin/tail
Permissions: all users
Description: display file tail
Options:
-n number of lines from end
-f follow file as it grows1.2.8 ln command
ln creates links between files.
Command name: ln
English meaning: link
Location: /bin/ln
Permissions: all users
Description: create hard or symbolic links
# ln [options] source_file target_file
Options:
-s create symbolic link
-f force, remove existing target3. Commands usable on both files and directories
1.3.1 rm command
rm removes files or directories.
Command name: rm
English meaning: remove file or directory
Location: /bin/rm
Permissions: all users
Description: delete files or directories
# rm [options] file_or_directory
Options:
-r recursive delete, can remove directories
-f force delete
-i interactive delete1.3.2 cp command
cp copies files or directories.
Command name: cp
English meaning: copy file or directory
Location: /bin/cp
Permissions: all users
Description: duplicate files or directories
# cp [options] source_file target_file
Options:
-a same as -dpr (archive)
-d if source is a symlink, create symlink
-i prompt before overwrite
-p preserve attributes
-r recursive copy1.3.3 mv command
mv moves or renames files.
Command name: mv
English meaning: move (rename) files
Location: /bin/mv
Permissions: all users
Description: move or rename files
# mv [options] source_file target_file
Options:
-f force overwrite
-d interactive move
-v verbose output4. Basic permission management
1.4.1 chmod command
chmod changes file mode bits.
Command name: chmod
English meaning: change file mode
Location: /bin/chmod
Permissions: all users
Description: modify file permission mode
# chmod [options] mode file
Options:
-R recursive change1.4.2 Permission modes
chmod mode format: [ugoa][+-=][perms] where u=user, g=group, o=others, a=all.
+ adds permission, - removes, = sets exactly.
Permissions: r=read, w=write, x=execute.
1.4.3 Numeric permissions
4=read, 2=write, 1=execute.
Owner and group commands
1.4.4 chown command
chown changes file owner and group.
Command name: chown
English meaning: change file owner and group
Location: /bin/chown
Permissions: all users
Description: modify owner or group of a file or directory
# chown [options] owner:group file_or_directory
Options:
-R recursive1.4.5 chgrp command
chgrp changes the group ownership.
Command name: chgrp
English meaning: change group ownership
Location: /bin/chgrp
Permissions: all users
Description: modify group of a file or directory
# chgrp [options] group file_or_directoryumask default permissions
5. Help commands
1.5.1 man command
man displays the manual pages.
Command name: man
English meaning: manual
Location: /usr/bin/man
Permissions: all users
Description: show online help manual
# man [options] command
Options:
-f show which help level a command has
-k search related help topicsShortcut
Function
Up Arrow
move up one line
Down Arrow
move down one line
PgUp
page up
PgDn
page down
g
go to first page
G
go to last page
q
quit
/string
search forward
?string
search backward
n
next match
N
previous match
Man help level image:
1.5.2 info command
info provides GNU info manuals.
1.5.3 help command
help shows help for shell built‑in commands.
Command name: help
English meaning: help
Location: built‑in shell command
Permissions: all users
Description: display help for built‑in commands
1.5.4 --help option
Most commands support the --help option to display usage information.
6. Search commands
1.6.1 whereis command
whereis locates the binary, source, and manual page files for a command.
Command name: whereis
English meaning: locate the binary, source, and manual page files for a command
Location: /usr/bin/whereis
Permissions: all users
Description: find binary, source, and documentation
1.6.2 which command
which shows the full path of a command and can reveal aliases.
Command name: which
English meaning: shows the full path of (shell) commands
Location: /usr/bin/which
Permissions: all users
Description: display command path
1.6.3 locate command
locate searches for files by name using a database.
Advantages: fast, low resource, database at /var/lib/mlocate/mlocate.db, updated with updatedb.
Disadvantage: can only search by filename.
1.6.4 find command
find searches for files in a directory hierarchy.
Command name: find
Location: /bin/find
Permissions: all users
Description: search files
Search by name:
# find path [options] pattern
-name name (case‑sensitive)
-iname name (case‑insensitive)
-inum inode numberSearch by size:
# find path -size [+|-]size
+ larger than size
- smaller than size
Units: b (512‑byte blocks), c (bytes), k (KB), w (two‑byte words)Search by time:
-atime [+|-]days access time
-mtime [+|-]days modification time
-ctime [+|-]days status change timeSearch by permission:
-perm mode exact match
-perm -mode all bits of mode set
-perm +mode any of the bits in mode setSearch by owner/group:
-uid uid owner uid
-gid gid group gid
-user name owner name
-group name group name
-nouser files without ownerSearch by type:
-type d directories
-type f regular files
-type l symbolic linksLogical operators:
-a and
-o or
-not notOther options:
-exec command {} \; execute command on each match
-ok command {} \; like -exec but asks for confirmation1.6.5 grep command
grep searches for patterns in files.
# grep [options] "search pattern" filename
Options:
-i ignore case
-n show line numbers
-v invert match
--color=auto highlight matches1.6.6 Pipe operator
Command1 | Command2 passes the output of Command1 as input to Command2.
1.6.7 Command aliases
# alias list aliases
# alias ser='systemctl start network' define alias1.6.8 Common shortcuts
Shortcut
Function
TAB
auto‑complete
CTRL+A
move cursor to start of line
CTRL+E
move cursor to end of line
CTRL+C
interrupt current command
CTRL+U
cut line before cursor
CTRL+L
clear screen
CTRL+Y
paste after CTRL+U
7. Compression commands
1. zip format
zip creates zip archives, compatible with Windows.
Command name: zip
English meaning: package and compress files
Location: /usr/bin/zip
Permissions: all users
Description: compress directories or files
# zip [options] archive_name files
Options:
-r recurse into directories1.2 unzip format
unzip extracts zip archives.
Command name: unzip
Location: /usr/bin/unzip
Permissions: all users
Description: decompress zip files
# unzip [options] archive.zip
Options:
-d extract to directory2. gz format
gzip compresses files; gunzip or gzip -d decompresses.
# gzip [options] file
Options:
-c write to stdout, keep original
-d decompress
-r compress directories4. tar format
tar creates and extracts archive files.
Command name: tar
Location: /bin/tar
Permissions: all users
Description: pack and unpack archives
# tar [options] [-f archive] files
Options:
-c create
-f archive file name
-v verbose
-x extract
-t list contents
-C change to directory before operation
-z handle .tar.gz
-j handle .tar.bz28. Shutdown and reboot
1. sync command
sync flushes file system buffers.
Command name: sync
English meaning: flush file system buffers
Location: /bin/sync
Permissions: all users
Description: synchronize cached writes to persistent storage
2. shutdown command
shutdown brings the system down.
Command name: shutdown
English meaning: bring the system down
Location: /sbin/shutdown
Permissions: superuser
Description: power off or reboot
# shutdown [options] time [message]
Options:
-c cancel a pending shutdown
-h halt
-r reboot3. reboot command
# reboot # restart the system4. halt and poweroff commands
halt and poweroff immediately power off the machine; they do not gracefully stop services.
# halt
# poweroff5. init command
# init 0 # halt (runlevel 0)
# init 6 # reboot (runlevel 6)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.
