Linux commands are used to manage the Linux system. For the Linux system, everything, including the CPU, memory, disk drives, keyboard, mouse, and users, is treated as a file. The commands for managing the Linux system are the core of its normal operation.Below are 166 of the most commonly used commands; there is bound to be one you will need, so feel free to bookmark it.
1. Online Query and Help Commands
man: View command help; info is more complex but not commonly used.
help: View help for built-in Linux commands, such as the cd command.
2. File and Directory Operation Commands
ls: Full name list, its function is to list the contents of a directory and its attribute information.
cd: Full name change directory, its function is to switch from the current working directory to a specified working directory.
cp: Full name copy, its function is to copy files or directories.
find: Means to find, used to search for directories and files within them.
mkdir: Full name make directories, its function is to create directories.
mv: Full name move, its function is to move or rename files.
pwd: Full name print working directory, its function is to display the absolute path of the current working directory.
rename: Used to rename files.
rm: Full name remove, its function is to delete one or more files or directories.
rmdir: Full name remove empty directories, its function is to delete empty directories.
touch: Create a new empty file or change the timestamp attributes of an existing file.
tree: Its function is to display the contents of a directory in a tree structure.
basename: Display file or directory name.
dirname: Display file or directory path.
chattr: Change file extended attributes.
lsattr: View file extended attributes.
file: Display the type of the file.
md5sum: Calculate and verify the MD5 value of a file.
3. View Files and Content Processing Commands
cat: Full name concatenate, its function is to connect multiple files and print them to the screen or redirect to a specified file.
tac: The reverse spelling of cat, so the function of the command is to display file content in reverse.
more: Paginate file content display.
less: Paginate file content display, the opposite use of the more command.
head: Display the head of the file content.
tail: Display the tail of the file content.
cut: Split each line of a file by a specified delimiter and output.
split: Split a file into different smaller segments.
paste: Merge file contents by line.
sort: Sort the text content of a file.
uniq: Remove duplicate lines.
wc: Count the number of lines, words, or bytes in a file.
iconv: Convert the encoding format of a file.
dos2unix: Convert DOS format files to UNIX format.
diff: Full name difference, compare the differences between files, commonly used for text files.
vimdiff: Command-line visualization file comparison tool, commonly used for text files.
rev: Reverse output the content of a file.
grep/egrep: Filter strings, the three musketeers’ old third.
join: Merge by the same fields of two files.
tr: Replace or delete characters.
vi/vim: Command-line text editor.
4. File Compression and Decompression Commands
5. Information Display Commands(11 items)
uname: Command to display operating system-related information.
hostname: Display or set the current system’s hostname.
dmesg: Display boot information, used for diagnosing system failures.
uptime: Display system uptime and load.
stat: Display the status of a file or filesystem.
du: Calculate disk space usage.
df: Report the usage of filesystem disk space.
top: Real-time display of system resource usage.
free: View system memory.
date: Display and set system time.
cal: View calendar and other time information.
which: Find binary commands, searching according to the environment variable PATH.
find: Traverse the disk to find files or directories.
whereis: Find binary commands, searching according to the environment variable PATH.
locate: Find commands from the database (/var/lib/mlocate/mlocate.db), using updatedb to update the database.
7. User Management Commands
usermod: Modify the attributes of an existing user in the system.
groupadd: Add a user group.
passwd: Change user password.
chage: Change the validity period of a user password.
id: View the user’s uid, gid, and the user groups they belong to.
su: Switch user identity.
visudo: A dedicated command to edit the /etc/sudoers file.
sudo: Execute commands allowed in the sudoers file as another user (default root user).
8. Basic Network Operation Commands
telnet: Use the TELNET protocol for remote login.
ssh: Use the SSH encryption protocol for remote login.
scp: Full name secure copy, used to copy files between different hosts.
wget: Command line download files.
ping: Test the connectivity between hosts.
route: Display and set the routing table of the Linux system.
ifconfig: Command to view, configure, enable, or disable network interfaces.
ifup: Start the network card.
ifdown: Shut down the network card.
netstat: View network status.
9. Advanced Network Operation Commands
nmap: Network scanning command.
lsof: Full name list open files, which lists the files that are currently opened in the system.
mail: Send and receive emails.
mutt: Email management command.
nslookup: Command to interactively query internet DNS servers.
dig: Find DNS resolution process.
host: Command to query DNS.
traceroute: Trace the routing status of data transmission.
tcpdump: Command-line packet capture tool.
10. Disk and Filesystem Commands
mount: Mount a filesystem.
umount: Unmount a filesystem.
fsck: Check and repair the Linux filesystem.
dd: Convert or copy files.
dumpe2fs: Export ext2/ext3/ext4 filesystem information.
dumpe: xt2/3/4 filesystem backup tool.
fdisk: Disk partition command, suitable for partitions below 2TB.
parted: Disk partition command, no size limit, commonly used for partitions below 2TB.
mkfs: Format and create a Linux filesystem.
partprobe: Update the kernel’s hard disk partition table information.
e2fsck: Check ext2/ext3/ext4 type filesystems.
mkswap: Create a Linux swap partition.
swapon: Enable swap partition.
swapoff: Disable swap partition.
sync: Write data in memory buffers to disk.
resize2fs: Adjust the size of the ext2/ext3/ext4 filesystem.
11. System Permissions and User Authorization Commands
chmod: Change file or directory permissions.
chown: Change the owner and group of a file or directory.
chgrp: Change the user group of a file.
umask: Display or set the permission mask.
12. System User Login Information Commands
whoami: Display the current effective user name, equivalent to executing id -un command.
who: Display information about currently logged-in users.
w: Display a list of users who have logged into the system and the commands they are currently executing.
last: Display users who have logged into the system.
lastlog: Display the last login information of all users in the system.
users: Display a list of all users currently logged into the system.
finger: Find and display user information.
13. Built-in Commands and Others
echo: Print variables or directly output specified strings.
printf: Format the output of results to standard output.
rpm: Command to manage rpm packages.
yum: Command to automate and simplify the management of rpm packages.
watch: Periodically execute a given command and display its output in full screen.
alias: Set system aliases.
unalias: Cancel system aliases.
date: View or set system time.
clear: Clear the screen, abbreviated as clear screen.
history: View the history of executed commands.
eject: Eject the CD-ROM drive.
time: Calculate the execution time of a command.
nc: A powerful network tool.
xargs: Convert standard input into command line arguments.
exec: Command to call and execute instructions.
export: Set or display environment variables.
unset: Delete variables or functions.
type: Used to determine whether another command is a built-in command.
bc: Command-line scientific calculator.
14. System Management and Performance Monitoring Commands
chkconfig: Manage Linux system boot startup items.
vmstat: Virtual memory statistics.
mpstat: Display status statistics of each available CPU.
iostat: Statistics of system IO.
sar: Comprehensive acquisition of performance data such as CPU, running queue, disk I/O, paging (swap area), memory, CPU interrupts, and network.
ipcs: Used to report the status of inter-process communication facilities in Linux, including information about message lists, shared memory, and semaphores.
ipcrm: Used to delete one or more message queues, semaphore sets, or shared memory identifiers.
strace: Used for diagnosing and debugging Linux user space tracers. We use it to monitor interactions between user space processes and the kernel, such as system calls, signal passing, and process state changes.
ltrace: The command will trace the library function calls of a process, showing which library functions are called.
15. Shutdown/Reboot/Logout and View System Information Commands
poweroff: Turn off power.
logout: Exit the current logged-in shell.
exit: Exit the current logged-in shell.
Ctrl+d: Shortcut key to exit the current logged-in shell.
16. Process Management Related Commands
bg: Turn a command that is paused in the background into a command that continues to execute (execute in the background).
fg: Bring a command from the background to the foreground to continue running.
jobs: View how many commands are currently running in the background.
kill: Terminate a process.
killall: Terminate processes by process name.
pkill: Terminate processes by process name.
crontab: Scheduled task command.
ps: Display a snapshot of processes.
pstree: Display processes in a tree structure.
nice/renice: Adjust the priority of program execution.
nohup: Run a specified command ignoring hang-up signals.
pgrep: Find processes that match conditions.
runlevel: View the current run level of the system.
service: Start, stop, restart, and shut down system services, and also display the current status of all system services.
Add Xiaotang Teacher’s WeChat to receive for free
[JMeter Course]
