Collection | Summary of 156 Common Linux Commands!

Collection | Summary of 156 Common Linux Commands!

Source: Machine Learning Algorithms and Python Learning

This article is approximately 2500 words long and is suggested to be read in 5 minutes. This article brings you 156 commonly used commands in the Linux system.

Linux commands are commands used to manage the Linux system. In the Linux system, whether it is the central processing unit, memory, disk drives, keyboard, mouse, or users, they are all files. The commands for managing the Linux system are core to its normal operation, similar to previous DOS commands. There are two types of Linux commands in the system: built-in shell commands and Linux commands.

Command

Function Description

Online Query and Help Commands (2)

man

View command help, a dictionary of commands; more complex ones include info, but are 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; its function is to list the contents of a directory and the attributes of its contents.

cd

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

cp

Full spelling copy; its function is to copy files or directories.

find

Means to find; used to search for directories and files under a directory.

mkdir

Full spelling make directories; its function is to create directories.

mv

Full spelling move; its function is to move or rename files.

pwd

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

rename

Used to rename files.

rm

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

rmdir

Full spelling remove empty directories; its function is to delete empty directories.

touch

Create a new empty file, 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 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; its function is to connect multiple files and print to screen output or redirect to a specified file.

tac

Tac is cat spelled backwards, thus the command’s function is to display file contents in reverse.

more

Paginate the display of file contents.

less

Paginate the display of file contents, the opposite usage of the more command.

head

Display the head of the file contents.

tail

Display the tail of the file contents.

cut

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

split

Split the file into different small segments.

paste

Merge file contents by line.

sort

Sort the text content of the 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 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

Output file content in reverse.

grep/egrep

Filter strings.

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

Packaging and compression.

unzip

Decompress files.

gzip

Gzip compression tool.

zip

Compression tool.

Information Display Commands (11)

uname

Command to display information related to the operating system.

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 disk space on the file system.

top

Real-time display of system resource usage.

free

View system memory.

date

Display and set system time.

cal

View calendar and time information.

File Search Commands (4)

which

Find binary commands, searching along the environment variable PATH.

find

Traverse the disk to find files or directories.

whereis

Find binary commands, searching along the environment variable 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 attributes of an existing user in the system.

userdel

Delete a user.

groupadd

Add a user group.

passwd

Change user password.

chage

Change the expiration date of the user password.

id

View the user’s uid, gid, and the groups to which they belong.

su

Switch user identity.

visudo

Edit the /etc/sudoers file with a dedicated command.

sudo

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

Basic Network Operation Commands (11)

telnet

Remote login using the TELNET protocol.

ssh

Remote login using the SSH encryption protocol.

scp

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

wget

Command-line file download.

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.

ss

View network status.

Advanced Network Operation Commands (9)

nmap

Network scanning command.

lsof

Full name list open files; it lists files that have been opened in the system.

mail

Send and receive mail.

mutt

Email management command.

nslookup

Interactive command to query internet DNS servers.

dig

Find DNS resolution processes.

host

Command to query DNS.

traceroute

Trace data transmission routing status.

tcpdump

Command-line packet capture tool.

Commands Related to Disks and File Systems (16)

mount

Mount the file system.

umount

Unmount the file system.

fsck

Check and repair the Linux file system.

dd

Convert or copy files.

dumpe2fs

Export ext2/ext3/ext4 file system information.

dump

Backup tool for ext2/3/4 file systems.

fdisk

Disk partition command, suitable for partitions below 2TB.

parted

Disk partition command, no disk size limit; commonly used for partitions below 2TB.

mkfs

Create and format a Linux file system.

partprobe

Update the kernel’s hard disk partition table information.

e2fsck

Check ext2/ext3/ext4 type file systems.

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 ext2/ext3/ext4 file systems.

System Permission and User Authorization Commands (4)

chmod

Change file or directory permissions.

chown

Change the owner and group of a file or directory.

chgrp

Change file user group.

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 the information of users currently logged into the system.

w

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

last

Display users who logged into the system.

lastlog

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

users

Display the 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 the output result to standard output.

rpm

Command to manage rpm packages.

yum

Command to automate the management of rpm packages.

watch

Periodically execute a given command and display the output of the command 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 disk drive.

time

Calculate command execution time.

nc

Powerful network tool.

xargs

Convert standard input into command-line arguments.

exec

Call and execute commands.

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 of system IO.

sar

Comprehensively acquire performance data for CPU, run queues, disk I/O, paging (swap), memory, CPU interrupts, and network.

ipcs

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 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 library function calls of processes, showing which library functions are called.

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

shutdown

Shutdown.

halt

Shutdown.

poweroff

Turn off the power.

logout

Exit the currently logged-in shell.

exit

Exit the currently logged-in shell.

Ctrl+d

Shortcut key to exit the currently logged-in shell.

Process Management Related Commands (15)

bg

Change a command that is paused in the background to continue executing (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 its name.

pkill

Terminate a process by its 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 certain conditions.

runlevel

View the current run level of the system.

init

Switch run levels.

service

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

Original link: www.cnblogs.com/bananaaa/p/7774467.html

Collection | Summary of 156 Common Linux Commands!

Leave a Comment