Summary of the 150 Most Common Commands for Linux System Administrators

Click ▲ to follow “IT168 Enterprise” and pin the public account

More exciting content delivered to you first

Command

Function Description

Online Query and Help Commands (2)

man

View command help, a dictionary of commands; more complex is info, but it’s not commonly used.

help

View help for built-in Linux commands, such as the cd command.

File and Directory Operation Commands (18)

ls

Full spelling list, function is to list the contents of a directory and its attribute information.

cd

Full spelling change directory, function is to switch from the current working directory to a specified working directory.

cp

Full spelling copy, function is to copy files or directories.

find

Means to find, used to search for directories and files within directories.

mkdir

Full spelling make directories, function is to create directories.

mv

Full spelling move, function is to move or rename files.

pwd

Full spelling print working directory, function is to display the absolute path of the current working directory.

rename

Used to rename files.

rm

Full spelling remove, function is to delete one or more files or directories.

rmdir

Full spelling remove empty directories, function is to delete empty directories.

touch

Create a new empty file or change the timestamp attributes of an existing file.

tree

Function is to display the contents of a directory in a tree structure.

basename

Display the file name or directory name.

dirname

Display the file or directory path.

chattr

Change the extended attributes of a file.

lsattr

View the extended attributes of a file.

file

Display the type of a file.

md5sum

Calculate and verify the MD5 value of a file.

File and Content Processing Commands (21)

cat

Full spelling concatenate, function is to connect multiple files and print to screen output or redirect to a specified file.

tac

tac is the reverse spelling of cat, thus the command’s function is to display file content in reverse.

more

Page display of file content.

less

Page display of file content, more command’s opposite usage.

head

Display the head of file content.

tail

Display the tail of file content.

cut

Split each line of a file by a specified delimiter and output.

split

Split a file into different small segments.

paste

Merge file content by line.

sort

Sort the text content of a file.

uniq

Remove duplicate lines. oldboy

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 spelling difference, compare the differences between files, commonly used for text files.

vimdiff

Command-line visual file comparison tool, commonly used for text files.

rev

Reverse output of file content.

grep/egrep

Filter strings, the three musketeers’ old third.

join

Merge by matching fields from two files.

tr

Replace or delete characters.

vi/vim

Command-line text editor.

File Compression and Decompression Commands (4)

tar

Package and compress. oldboy

unzip

Decompress files.

gzip

gzip compression tool.

zip

Compression tool.

Information Display Commands (11)

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 faults.

uptime

Display system uptime and load.

stat

Display the status of a file or file system.

du

Calculate disk space usage.

df

Report the usage of file system 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.

File Search Commands (4)

which

Find binary commands, searching according to the environment variable PATH path.

find

Traverse the disk to find files or directories.

whereis

Find binary commands, searching according to the environment variable PATH path.

locate

Find commands from the database (/var/lib/mlocate/mlocate.db) using updatedb to update the database.

User Management Commands (10)

useradd

Add a user.

usermod

Modify the properties of an existing user in the system.

userdel

Delete a user.

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

Edit/etc/sudoers file with a dedicated command.

sudo

Execute commands allowed in the sudoers file as another user (default is the root user).

Basic Network Operation Commands (11)

telnet

Use TELNET protocol for remote login.

ssh

Use SSH encrypted protocol for remote login.

scp

Full spelling secure copy, used to copy files between different hosts.

wget

Command-line file download.

ping

Test network connectivity between hosts.

route

Display and set linux system’s routing table.

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.

ss

View network status.

In-depth Network Operation Commands (9)

nmap

Network scanning command.

lsof

Full name list open files, which lists files that are already opened in the system.

mail

Send and receive emails.

mutt

Email management command.

nslookup

Interactive query command for internet DNS servers.

dig

Find DNS resolution process.

host

Query DNS command.

traceroute

Trace the routing status of data transmission.

tcpdump

Command-line packet capture tool.

Commands Related to Disks and File Systems (16)

mount

Mount file systems.

umount

Unmount file systems.

fsck

Check and repair Linux file systems.

dd

Convert or copy files.

dumpe2fs

Export ext2/ext3/ext4 file system information.

dump

ext2/3/4 file system backup tool.

fdisk

Disk partition command, suitable for 2TB or smaller disk partitions.

parted

Disk partition command, no disk size limit, commonly used for 2TB or smaller disk partitions.

mkfs

Format and create Linux file systems.

partprobe

Update the kernel’s hard disk partition table information.

e2fsck

Check ext2/ext3/ext4 type file systems.

mkswap

Create Linux swap partitions.

swapon

Enable swap partitions.

swapoff

Disable swap partitions.

sync

Write data from memory buffers to disk.

resize2fs

Adjust ext2/ext3/ext4 file system size.

System Permissions and User Authorization Related Commands (4)

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.

Commands to View System User Login Information (7)

whoami

Display the current effective user name, equivalent to executing id -un command.

who

Display information about users currently logged into the system.

w

Display a list of users logged into the system and the commands they are executing.

last

Display users who have logged into the system.

lastlog

Display the last login information for all users in the system.

users

Display a list of all users currently logged into the system.

finger

Find and display user information.

Built-in Commands and Others (19)

echo

Print variables or directly output specified strings.

printf

Format output results to standard output.

rpm

Manage rpm packages.

yum

Automate and simplify management of rpm packages.

watch

Periodically execute a given command and display the command’s 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 optical drive.

time

Calculate the execution time of a command.

nc

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.

System Management and Performance Monitoring Commands (9)

chkconfig

Manage Linux system startup items.

vmstat

Virtual memory statistics.

mpstat

Display status statistics for each available CPU.

iostat

Statistics for system IO.

sar

Comprehensively obtain system CPU, run queue, disk I/O, paging (swap), memory, CPU interrupts, and network performance data.

ipcs

Used to report the status of inter-process communication facilities in Linux, displaying information including message lists, shared memory, and semaphore information.

ipcrm

Used to delete one or more message queues, semaphore sets, or shared memory identifiers.

strace

Used for diagnosing and debugging Linux user space tracing. We use it to monitor interactions between user space processes and the kernel, such as system calls, signal delivery, process state changes, etc.

ltrace

The command traces library function calls of a process, showing which library functions are called.

Shutdown/Reboot/Logout and View System Information Commands (6)

shutdown

Shut down.

halt

Shut down.

poweroff

Turn off the 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.

Process Management Related Commands (15)

bg

Resume a command that is paused in the background (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 a process by process name.

pkill

Terminate a process 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 hangup signals.

pgrep

Find processes that match conditions.

runlevel

View the current run level of the system.

init

Switch run levels.

service

Start, stop, restart, and shut down system services, and display the current status of all system services.

Edited by ∑GeminiSource:http://oldboy.blog.51cto.com/2561410/1951107 oldboy

Leave a Comment