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
man
command is used to view the detailed man page for the command.
# 查看ls命令的帮助手册
man ls
help command
help
command is used to get brief help information for shell built-in commands.
# 获取cd命令的帮助信息
help cd
system shutdown command
shutdown command
shutdown
command to shut down the system and perform shutdown operations.
# 关闭系统并执行关机操作
sudo shutdown now
System restart command
reboot command
reboot
command to reboot the system.
# 重新启动系统
sudo reboot
System Service Management Commands
systemctl command
systemctl
Commands are used to manage system services.
# 启动Apache Web服务器
sudo systemctl start apache2
service command
service
Commands are used to control system services.
# 停止MySQL服务
sudo service mysql stop
System directory related commands
mkdir command
mkdir
command is used to create a new directory.
# 创建名为mydir的目录
mkdir mydir
cd command
cd
command is used to switch the current working directory.
# 进入名为mydir的目录
cd mydir
tree command
tree
The command displays the contents of a directory in a tree structure.
# 显示当前目录的树状结构
tree
rm command
rm
command is used to delete a file or directory.
# 删除名为myfile.txt的文件
rm myfile.txt
pwd command
pwd
command is used to display the path of the current working directory.
# 显示当前工作目录
pwd
ls command
ls
command to list directory contents.
# 列出当前目录的文件和子目录
ls
System file related commands
touch command
touch
command to create an empty file or to update a file's access and modification times.
# 创建名为myfile.txt的空文件
touch myfile.txt
echo command
echo
Commands are used to output text or the contents of variables.
# 输出文本"Hello, World!"到终端
echo "Hello, World!"
cat command
cat
command 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
more
The , less
, head
and tail
commands 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
cp
command to copy files or directories.
# 复制file1.txt到dir1目录中
cp file1.txt dir1/
mv command
mv
Commands 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
vim
Command is a text editor for editing file content.
# 使用vim编辑器编辑myfile.txt文件
vim myfile.txt
System compression related commands
dd command
dd
commands to copy and convert files.
# 从/dev/sda磁盘复制前1MB数据到myfile.img文件
dd if=/dev/sda of=myfile.img bs=1M count=1
zip command
zip
command is used to create ZIP archives.
# 将dir1目录压缩为archive.zip文件
zip -r archive.zip dir1
tar command
tar
commands 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
alias
command is used to create command aliases.
# 为ls -l命令创建别名ll
alias ll='ls -l'
System search related commands
find command
find
command is used to search for files and directories under the specified directory.
# 在当前目录下查找名为myfile.txt的文件
find . -name myfile.txt
System sort related commands
sort command
sort
command to sort the lines of a text file.
# 按字母顺序对file.txt的行进行排序
sort file.txt
System deduplication related commands
uniq command
uniq
command 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!