Linux: Linux common operation commands

Linux Common Operation Commands

This blog will introduce the commands commonly used in the Linux operating system, and provide detailed descriptions and related script examples for each command.

system help command

man command

mancommand is used to view the detailed man page for the command.

# 查看ls命令的帮助手册
man ls

help command

helpcommand is used to get brief help information for shell built-in commands.

# 获取cd命令的帮助信息
help cd

system shutdown command

shutdown command

shutdowncommand to shut down the system and perform shutdown operations.

# 关闭系统并执行关机操作
sudo shutdown now

System restart command

reboot command

rebootcommand to reboot the system.

# 重新启动系统
sudo reboot

System Service Management Commands

systemctl command

systemctlCommands are used to manage system services.

# 启动Apache Web服务器
sudo systemctl start apache2

service command

serviceCommands are used to control system services.

# 停止MySQL服务
sudo service mysql stop

System directory related commands

mkdir command

mkdircommand is used to create a new directory.

# 创建名为mydir的目录
mkdir mydir

cd command

cdcommand is used to switch the current working directory.

# 进入名为mydir的目录
cd mydir

tree command

treeThe command displays the contents of a directory in a tree structure.

# 显示当前目录的树状结构
tree

rm command

rmcommand is used to delete a file or directory.

# 删除名为myfile.txt的文件
rm myfile.txt

pwd command

pwdcommand is used to display the path of the current working directory.

# 显示当前工作目录
pwd

ls command

lscommand to list directory contents.

# 列出当前目录的文件和子目录
ls

System file related commands

touch command

touchcommand to create an empty file or to update a file's access and modification times.

# 创建名为myfile.txt的空文件
touch myfile.txt

echo command

echoCommands are used to output text or the contents of variables.

# 输出文本"Hello, World!"到终端
echo "Hello, World!"

cat command

catcommand is used to concatenate files and output their contents to the terminal.

# 将file1.txt和file2.txt的内容输出到终端
cat file1.txt file2.txt


more, less, head, tail commands

moreThe , less, headand tailcommands are used to view the contents of a file.

# 使用more命令逐页查看文件的内容
more myfile.txt

# 使用less命令查看文件的内容,并提供更多功能
less myfile.txt

# 使用head命令显示文件的前几行
head myfile.txt

# 使用tail命令显示文件的后几行
tail myfile.txt

cp command

cpcommand to copy files or directories.

# 复制file1.txt到dir1目录中
cp file1.txt dir1/

mv command

mvCommands are used to move files or directories, or to rename files.

# 移动file1.txt到dir1目录中
mv file1.txt dir1/

# 将文件file1.txt重命名为file2.txt
mv file1.txt file2.txt

vim command

vimCommand is a text editor for editing file content.

# 使用vim编辑器编辑myfile.txt文件
vim myfile.txt

System compression related commands

dd command

ddcommands to copy and convert files.

# 从/dev/sda磁盘复制前1MB数据到myfile.img文件
dd if=/dev/sda of=myfile.img bs=1M count=1

zip command

zipcommand is used to create ZIP archives.

# 将dir1目录压缩为archive.zip文件
zip -r archive.zip dir1

tar command

tarcommands are used to create and extract tar archives.

# 将dir1目录打包为archive.tar文件
tar -cvf archive.tar dir1

# 提取archive.tar文件
tar -xvf archive.tar

System alias related commands

alias command

aliascommand is used to create command aliases.

# 为ls -l命令创建别名ll
alias ll='ls -l'

System search related commands

find command

findcommand is used to search for files and directories under the specified directory.

# 在当前目录下查找名为myfile.txt的文件
find . -name myfile.txt

System sort related commands

sort command

sortcommand to sort the lines of a text file.

# 按字母顺序对file.txt的行进行排序
sort file.txt

System deduplication related commands

uniq command

uniqcommand is used to remove duplicate lines from sorted text files.

# 从file.txt中删除重复的行
uniq file.txt

I hope this blog will help you understand the commonly used commands in the Linux operating system. Through detailed introduction and script examples, you can better grasp the usage and functions of these commands. Good luck with your Linux system!

Guess you like

Origin blog.csdn.net/run65536/article/details/131329887