Linux - Summary of common commands

pwd #显示当前目录的路径

cd / # 跳转到根目录
cd ~ # 跳转到家目录
cd .. # 跳转到上级目录
cd ./home # 跳转到当前目录的home目录下
cd /home/lion # 跳转到根目录下的home目录下的lion目录
cd # 不添加任何参数,也是回到家目录
# 注意:输入cd /ho + 单次 tab 键会自动补全路径 + 两次 tab 键会列出所有可能的目录列表。

ls
ls -a #显示所有文件和目录包括隐藏的
ls -l #显示详细列表
ls -h #适合人类阅读的
ls -t #按文件最近一次修改时间排序
ls -i #显示文件的 inode ( inode 是文件内容的标识)

cat myLog.log #一次性显示文件myLog.log所有内容,更适合查看小的文件。
cat -n myLog.log #显示行号。

touch new_file #创建一个文件

mkdir new_folder #创建一个目录(文件夹)
mkdir -p one/two/three #-p 递归的创建目录结构

cp file file_copy # file 是目标文件,file_copy 是拷贝出来的文件
cp file one # 把 file 文件拷贝到 one 目录下,并且文件名依然为 file
cp file one/file_copy # 把 file 文件拷贝到 one 目录下,文件名为file_copy
cp *.txt folder # 把当前目录下所有 txt 文件拷贝到 folder 目录下

mv file one # 将 file 文件移动到 one 目录下
mv new_folder one # 将 new_folder 文件夹移动到one目录下
mv *.txt folder # 把当前目录下所有 txt 文件移动到 folder 目录下
mv file new_file # file 文件重命名为 new_file

rm new_file  # 删除 new_file 文件
rm f1 f2 f3  # 同时删除 f1 f2 f3 3个文件
# -i 向用户确认是否删除;
# -f 文件强制删除;
# -r 递归删除文件夹,如 :著名的删除操作 rm -rf 。


head cloud-init.log  #显示文件的开头几行(默认是10行)
head cloud-init.log -n 2 #-n 指定行数

tail cloud-init.log #显示文件的结尾几行(默认是10行)
tail cloud-init.log -n 2 #-n 指定行数 
tail -f -s 4 xxx.log #-f 会每过1秒检查下文件是否有更新内容,也可以用 -s 参数指定间隔时间


less myLog.log #分页显示文件内容,更适合查看大的文件。
#【快捷操作】
# 空格键:前进一页(一个屏幕);
# b键:后退一页;
# 回车键:前进一行;
# y键:后退一行;
# 上下键:回退或前进一行;
# d 键:前进半页;
# u 键:后退半页;
# q 键:停止读取文件,中止 less 命令;
# = 键:显示当前页面的内容是文件中的第几行到第几行以及一些其它关于本页内容的详细信息;
# h 键:显示帮助文档;
# / 键:进入搜索模式后,按 n 键跳到一个符合项目,按 N 键跳到上一个符合项目,同时也可以输入正则表达式匹配。



##########文件压缩解压##########################################################################
#我们常常使用 tar 将多个文件归档为一个总的文件,称为 archive 。然后用 gzip 或 bzip2 命令将 archive 压缩为更小的文件。

#tar  打包/创建归档
tar -cvf sort.tar sort/ # 将sort文件夹归档(又称打包、压缩)为sort.tar
tar -cvf archive.tar file1 file2 file3 # 将 file1 file2 file3 归档为archive.tar
#常用参数
#-cvf 表示 create(创建)+ verbose(细节)+ file(文件),创建归档文件并显示操作细节;
#-tf 显示归档里的内容,并不解开归档;
tar -rvf archive.tar file.txt #-rvf 追加文件到归档
tar -xvf archive.tar#-xvf 解开归档


#gzip / gunzip  “压缩/解压”归档,默认用 gzip 命令,压缩后的文件后缀名为 .tar.gz 。
gzip archive.tar # 压缩
gunzip archive.tar.gz # 解压复

#tar 归档+压缩  可以用 tar 命令同时完成归档和压缩的操作,就是给 tar 命令多加一个选项参数,使之完成归档操作后,还是调用 gzip 或 bzip2 命令来完成压缩操作。
tar -zcvf archive.tar.gz archive/ # 将archive文件夹归档并压缩
tar -zxvf archive.tar.gz # 将archive.tar.gz归档压缩文件解压


#zcat、zless、zmore  查看压缩文件
#使用 cat less more 可以查看文件内容,但是压缩文件的内容是不能使用这些命令进行查看的,而要使用 zcat、zless、zmore 进行查看
zcat archive.tar.gz #查看压缩文件

#zip/unzip   “压缩/解压” zip 文件 “压缩/解压” zip 文件( zip 压缩文件一般来自 windows 操作系统)。
## Red Hat 一族中的安装方式  yum install zip yum install unzip 
unzip archive.zip # 解压 .zip 文件
unzip -l archive.zip # 不解开 .zip 文件,只看其中内容
zip -r sort.zip sort/ # 将sort文件夹压缩为 sort.zip,其中-r表示递归

##########进程管理#############################################################################
w #查看进程

ps #静态获取当前系统中的进程, ps 命令显示的进程列表不会随时间而更新,是静态的,是运行 ps 命令那个时刻的状态或者说是一个进程快照。
#常用参数
# -ef 列出所有进程;
# -efH 以乔木状列举出所有进程;
# -u 列出此用户运行的进程;
# -aux 通过 CPU 和内存使用来过滤进程 ps -aux | less ;
# -aux --sort -pcpu 按 CPU 使用降序排列, -aux --sort -pmem 表示按内存使用降序排列;
# -axjf 以树形结构显示进程, ps -axjf 它和 pstree 效果类似。

top #(动态获取)进程的动态列表,展示的这些进程是按照使用处理器 %CPU 的使用率来排序的。

#进程状态
#主要是切换进程的状态。我们先了解下 Linux 下进程的五种状态:
#状态码 R :表示正在运行的状态;
#状态码 S :表示中断(休眠中,受阻,当某个条件形成后或接受到信号时,则脱离该状态);
#状态码 D :表示不可中断(进程不响应系统异步信号,即使用kill命令也不能使其中断);
#状态码 Z :表示僵死(进程已终止,但进程描述符依然存在,直到父进程调用 wait4() 系统函数后将进程释放);
#状态码 T :表示停止(进程收到 SIGSTOP 、 SIGSTP 、 SIGTIN 、 SIGTOU 等停止信号后停止运行)。

#结束(杀死)一个进程, kill + PID 。
kill 956 # 结束进程号为956的进程
kill 956 957 # 结束多个进程
kill -9 7291 # 强制结束进程

#前台进程 与 后台进程
#默认情况下,用户创建的进程都是前台进程,前台进程从键盘读取数据,并把处理结果输出到显示器。
#例如运行 top 命令,这就是一个一直运行的前台进程。
#后台进程的优点是不必等待程序运行结束,就可以输入其它命令。在需要执行的命令后面添加 & 符号,就表示启动一个后台进程。
cp name.csv name-copy.csv & #后台启动进程,它的缺点是后台进程与终端相关联,一旦关闭终端,进程就自动结束了。


nohup cp name.csv name-copy.csv #nohup 不受挂断,使进程不受挂断(关闭终端等动作)的影响。
nohup cp name.csv name-copy.csv & #nohup 命令也可以和 & 结合使用。

#bg 使一个“后台暂停运行”的进程,状态改为“后台运行”。
bg %1 #不加任何参数的情况下,bg命令会默认作用于最近的一个后台进程,如果添加参数则会作用于指定标号的进程 
#使用案例1:
#1. 执行 grep -r "log" / > grep_log 2>&1 命令启动一个前台进程,并且忘记添加 & 符号
#2. ctrl + z 使进程状态转为后台暂停
#3. 执行 bg 将命令转为后台运行
#使用案例2:
#前端开发时我们经常会执行 yarn start 启动项目,此时我们执行 ctrl + z 先使其暂停,然后执行 bg 使其转为后台运行。
#这样当前终端就空闲出来可以干其它事情了,如果想要唤醒它就使用 fg 命令即可(后面会讲)

Linux software repository

  • Software under Linux exists in the form of packages. A software package is actually a compressed package of all files of the software in binary form, including all instructions for installing the software.

  • There is a warehouse for Linux packages, called software warehouse, which can use yum to manage software packages. (There are other similar package management software rpm, npm, etc.)

  • yum is the default package management tool in CentOS, suitable for the Red Hat family. It can be understood as npm of Node.js.

yum common commands

yum update | yum upgrade #更新软件包
yum search xxx #搜索相应的软件包
yum install xxx #安装软件包
yum remove xxx #删除/卸载软件包

Switch CentOS software source

The default yum source of CentOS is not necessarily a domestic mirror, which leads to unsatisfactory online installation and update speed of yum.

The yum source needs to be set as a domestic mirror site. The main open source mirror sites in China are Netease and Alibaba Cloud.

  1. First, back up the yum source configuration file that comes with the system

 mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup

2. Download the yum source configuration file of Alibaba Cloud to /etc/yum.repos.d/CentOS7

wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo

3. Generate cache

yum makecache

Operate on file content (text content)

grep performs a global search on the contents of the file

Globally search for a regular expression and print to the screen. To put it simply, find keywords in the file and display the line where the keyword is located.

grep text file # text代表要搜索的文本,file代表供搜索的文件# 

#常用参数
# -i 忽略大小写, grep -i path /etc/profile
# -n 显示行号,grep -n path /etc/profile
# -v 只显示搜索文本不在的那些行,grep -v path /etc/profile
# -r 递归查找, grep -r hello /etc ,Linux 中还有一个 rgrep 命令,作用相当于 grep -r

grep can be used with regular expressions (advanced usage)

grep -E path /etc/profile # 完全匹配path
grep -E ^path /etc/profile # 匹配path开头的字符串
grep -E [Pp]ath /etc/profile # 匹配path或Path复制代码

sort Sort the text content of the content in the file

sort name.txt # 对name.txt文件内容进行排序

# 常用参数
# -o 将排序后的文件写入新文件, sort -o name_sorted.txt name.txt ;
# -r 倒序排序, sort -r name.txt ;
# -R 随机排序, sort -R name.txt ;
# -n 对数字进行排序,默认是把数字识别成字符串的,因此 138 会排在 25 前面,如果添加了 -n 数字排序的话,则 25 会在 138 前面。
Example usage
For the convenience of demonstration, we first create a file name.txt and put the following content:
ChristopherShawnTedRockNoahZacharyBella
Execute the sort name.txt command to sort the text content.

wc counts the contents of the file

Abbreviation for word count, used for file statistics. It can count the number of words, lines, characters, bytes, etc.

wc name.txt # 统计name.txt
wc -l name.txt # -l 只统计行数,
wc -w name.txt # -w 只统计单词数,
wc -c name.txt # -c 只统计字节数,
wc -m name.txt # -m 只统计字符数,

#实例
wc name.txt 13 13 91 name.txt
#第一个13,表示行数;
#第二个13,表示单词数;
#第三个91,表示字节数。

uniq removes duplicate content in a file

uniq name.txt # 去除name.txt重复的行数,并打印到屏幕上
uniq name.txt uniq_name.txt # 把去除重复后的文件保存为 uniq_name.txt

#常用参数
uniq -c name.txt #-c 统计重复行数
uniq -d name.txt #-d 只显示重复的行数

【Note】It can only remove consecutive repeated rows.

cut cut part of the file

cut -c 2-4 name.txt # 剪切每一行第二到第四个字符

# 常用参数
cut -d , name.txt # -d 用于指定用什么分隔符(比如逗号、分号、双引号等等)
cut -d , -f 1 name.txt # -f 表示剪切下用分隔符分割的哪一块或哪几块区域

redirect

Linux redirection refers to modifying some of the original default things, and changing the default execution method of the original system command. For example, if I don’t want to see the output on the monitor but want to output it to a file, I can redirect it through Linux. to do this work.

> output redirection

Indicates to redirect to a new file, cut -d , -f 1 notes.csv > name.csv , it means to cut the notes.csv file by a comma (there are 3 parts after cutting) to get the first part, redirect to the name.csv file.

Suppose we have a file notes.csv with the following contents:

Mark1,951/100, very good1Mark2,952/100, very good2Mark3,953/100, very good3Mark4,954/100, very good4Mark5,955/100, very good5Mark6,956/100, very good6

Excuting an order:

cut -d , -f 1 notes.csv > name.csv

The final output is as follows:

Mark1Mark2Mark3Mark4Mark5Mark6

[Note] When using >, it should be noted that if the output file does not exist, it will create a new one, and if the output file already exists, it will be overwritten. So perform this operation very carefully so as not to overwrite other important files.

>> output redirection (append)

Indicates redirection to the end of the file, so it is not as dangerous as the > command, which is appended to the end of the file (of course, if the file does not exist, it will also be created).

execute the command again

 cut -d , -f 1 notes.csv >> name.csv 

The name will be appended to name.csv.

Mark1Mark2Mark3Mark4Mark5Mark6Mark1Mark2Mark3Mark4Mark5Mark6

The log files we usually read are actually output by this command.

2> standard error output redirection

cat not_exist_file.csv > res.txt 2> errors.log
  • When we cat a file, the content of the file will be printed to the screen, this is the standard output;

  • When > res.txt is used, it will not be printed to the screen, and the standard output will be written to the file res.txt;

  • 2> errors.log When an error occurs, it will be written into the errors.log file.

2>> Standard error output (appended to the end of the file) is similar to >>.

2>&1 both standard output and standard error output are redirected to one place

cat not_exist_file.csv > res.txt 2>&1  # 覆盖输出

cat not_exist_file.csv >> res.txt 2>&1 # 追加输出

So far, the input of the commands we have touched comes from the parameters of the command. In fact, the input of the command can also come from the input of the file or the keyboard.

< input redirection

Input for specifying commands.

cat < name.csv # 指定命令的输入为 name.csv

Although it works the same as cat name.csv, the principles are completely different.

cat name.csv #表示 cat 命令接收的输入是 notes.csv 文件名,那么要先打开这个文件,然后打印出文件内容。
cat < name.csv #表示 cat 命令接收的输入直接是 notes.csv 这个文件的内容, cat 命令只负责将其内容打印,打开文件并将文件内容传递给 cat 命令的工作则交给终端完成。

<< input redirection

Redirect keyboard input as input for a command.

sort -n << END # 输入这个命令之后,按下回车,终端就进入键盘输入模式,其中END为结束命令(这个可以自定义)wc -m << END # 统计输入的单词


| pipe ( for command connection )

Use two commands together, the output of one command is used as the input of the other command, the English is pipeline, you can imagine that the water pipes are connected, and the pipeline is a kind of redirection flow.

cut -d , -f 1 name.csv | sort > sorted_name.txt
 # 第一步获取到的 name 列表,通过管道符再进行排序,最后输出到sorted_name.txt
 
 du | sort -nr | head 
 # du 表示列举目录大小信息
 # sort 进行排序,-n 表示按数字排序,-r 表示倒序
 # head 前10行文件
 
 grep log -Ir /var/log | cut -d : -f 1 | sort | uniq
 grep log -Ir /var/log  #表示在log文件夹下搜索 /var/log 文本,-r 表示递归,-I 用于排除二进制文件
 cut -d : -f 1 #表示通过冒号进行剪切,获取剪切的第一部分
 # sort 进行排序
 # uniq 进行去重复制代码

flow

  • Stream is not a command. In computer science, the meaning of stream is difficult to understand.

  • Just remember one thing: stream is to read a little bit of data and process a little bit of data. The data is generally in binary format.

  • The redirection or pipeline mentioned above is to operate the data as a stream.

So far we have been exposed to advanced Linux concepts and instructions such as streams, redirection, and pipelines. In fact, you will find that streams and pipes are widely used in other languages. Pipelines are available in Angular's template syntax. Node.js also has the concept of stream flow.


locate, find find files

locate command

#需要先安装 locate命令包
yum -y install mlocate # 安装包
updatedb # 更新数据库
locate file.txtlocate fil*.txt

[Note] The locate command will search the command in the file database instead of the entire disk, so the newly created file will not be updated to the database, so it cannot be found, and you can execute the updatedb command to update the database .

find command

  • Used to find files, it will traverse your actual hard disk to find, and it allows us to perform follow-up operations on each found file, which is very powerful.

  • find <where> <what> <what to do>

  • Where: Specify which directory to search, and all subdirectories of this directory will also be searched.

  • What: what to search for, you can search by the name of the file, its size, or its latest access time.

  • What to do: After the file is found, subsequent processing can be performed, if this parameter is not specified

####find 根据文件名查找######  
find -name "file.txt" # 当前目录以及子目录下通过名称查找文件
find . -name "syslog" # 当前目录以及子目录下通过名称查找文件
find / -name "syslog" # 整个硬盘下查找syslog
find /var/log -name "syslog" # 在指定的目录/var/log下查找syslog文件
find /var/log -name "syslog*" # 查找syslog1、syslog2 ... 等文件,通配符表示所有
find /var/log -name "*syslog*" # 查找包含syslog的文件 
#[注意] find 命令只会查找完全符合 “何物” 字符串的文件,而 locate 会查找所有包含关键字的文件。


####find 根据文件大小查找######
find /var -size +10M # /var 目录下查找文件大小超过 10M 的文件
find /var -size -50k # /var 目录下查找文件大小小于 50k 的文件
find /var -size +1G # /var 目录下查找文件大小查过 1G 的文件
find /var -size 1M # /var 目录下查找文件大小等于 1M 的文件复制代码find 


####根据文件最近访问时间查找######
find -name "*.txt" -atime -7  # 近 7天内访问过的.txt结尾的文件find 仅查找目录或文件
find . -name "file" -type f  # 只查找当前目录下的file文件
find . -name "file" -type d  # 只查找当前目录下的file目录find 


####操作查找结果######
find -name "*.txt" -printf "%p - %u\n"# 找出所有后缀为txt的文件,并按照 %p - %u\n 格式打印,其中%p=文件名,%u=文件所有者
find -name "*.jpg" -delete# 删除当前目录以及子目录下所有.jpg为后缀的文件,不会有删除提示,因此要慎用
find -name "*.c" -exec chmod 600 {} \;# 对每个.c结尾的文件,都进行 -exec 参数指定的操作,{} 会被查找到的文件替代,\; 是必须的结尾
find -name "*.c" -ok chmod 600 {} \; # 和上面的功能一样,会多一个确认提示


network

ifconfig

ifconfig 查看 ip 网络相关信息,如果命令不存在的话, 执行命令 yum install net-tools 安装。

参数解析:

  • eth0 对应有线连接(对应你的有线网卡),就是用网线来连接的上网。eth 是 Ethernet 的缩写,表示“以太网”。有些电脑可能同时有好几条网线连着,例如服务器,那么除了 eht0 ,你还会看到 eth1 、 eth2 等。

  • lo 表示本地回环( Local Loopback 的缩写,对应一个虚拟网卡)可以看到它的 ip 地址是 127.0.0.1 。每台电脑都应该有这个接口,因为它对应着“连向自己的链接”。这也是被称之为“本地回环”的原因。所有经由这个接口发送的东西都会回到你自己的电脑。看起来好像并没有什么用,但有时为了某些缘故,我们需要连接自己。例如用来测试一个网络程序,但又不想让局域网或外网的用户查看,只能在此台主机上运行和查看所有的网络接口。例如在我们启动一个前端工程时,在浏览器输入 127.0.0.1:3000 启动项目就能查看到自己的 web 网站,并且它只有你能看到。

  • wlan0 表示无线局域网(上面案例并未展示)。


host

host 实现ip 地址和主机名的互相转换。

软件安装

yum install bind-utils

基础用法

host github.combaidu.com has address 13.229.188.59 
host 13.229.188.5959.188.229.13.in-addr.arpa domain name pointer ec2-13-229-188-59.ap-southeast-1.compute.amazonaws.com.

ssh 连接远程服务器

通过非对称加密以及对称加密的方式(同 HTTPS 安全连接原理相似)连接到远端服务器。

ssh 用户@ip:port1、ssh [email protected]:22
# 端口号可以省略不写,默认是22端口
#输入连接密码后就可以操作远端服务器了

配置 ssh

config 文件可以配置 ssh ,方便批量管理多个 ssh 连接。

配置文件分为以下几种:

  • 全局 ssh 服务端的配置:/etc/ssh/sshd_config ;

  • 全局 ssh 客户端的配置:/etc/ssh/ssh_config(很少修改);

  • 当前用户 ssh 客户端的配置:~/.ssh/config 。

【服务端 config 文件的常用配置参数】

服务端 config 参数

作用

Port

sshd 服务端口号(默认是22)

PermitRootLogin

是否允许以 root 用户身份登录(默认是可以)

PasswordAuthentication

是否允许密码验证登录(默认是可以)

PubkeyAuthentication

是否允许公钥验证登录(默认是可以)

PermitEmptyPasswords

是否允许空密码登录(不安全,默认不可以)

[注意] 修改完服务端配置文件需要重启服务 systemctl restart sshd

【客户端 config 文件的常用配置参数】

客户端 config 参数

作用

Host

别名

HostName

远程主机名(或 IP 地址)

Port

连接到远程主机的端口

User

用户名

配置当前用户的 config :

# 创建config
vim ~/.ssh/config

填写一下以下内容

Host lion # 别名 
HostName 172.x.x.x # ip 地址  
Port 22 # 端口  
User root # 用户

这样配置完成后,下次登录时,可以这样登录 ssh lion 会自动识别为 root 用户。

[注意] 这段配置不是在服务器上,而是你自己的机器上,它仅仅是设置了一个别名。


免密登录

ssh 登录分两种,一种是基于口令(账号密码),另外一种是基于密钥的方式。

基于口令,就是每次登录输入账号和密码,显然这样做是比较麻烦的,今天主要学习如何基于密钥实现免密登录。

基于密钥验证原理

客户机生成密钥对(公钥和私钥),把公钥上传到服务器,每次登录会与服务器的公钥进行比较,这种验证登录的方法更加安全,也被称为“公钥验证登录”。

具体实现步骤

1、在客户机中生成密钥对(公钥和私钥) ssh-keygen(默认使用 RSA 非对称加密算法)

运行完 ssh-keygen 会在 ~/.ssh/ 目录下,生成两个文件:

  • id_rsa.pub :公钥

  • id_rsa :私钥

2、把客户机的公钥传送到服务

执行 ssh-copy-id [email protected](ssh-copy-id 它会把客户机的公钥追加到服务器 ~/.ssh/authorized_keys 的文件中)。

执行完成后,运行 ssh [email protected] 就可以实现免密登录服务器了。

配合上面设置好的别名,直接执行 ssh lion 就可以登录,是不是非常方便。


wget 从终端控制台下载文件

可以使我们直接从终端控制台下载文件,只需要给出文件的HTTP或FTP地址。

命令格式:

wget [参数][URL地址]

如:

wget http://www.minjieren.com/wordpress-3.1-zh_CN.zip

wget 非常稳定,如果是由于网络原因下载失败, wget 会不断尝试,直到整个文件下载完毕。

常用参数

  • -c 继续中断的下载。


备份

scp 安全拷贝

它是 Secure Copy 的缩写,表示安全拷贝。scp 可以使我们通过网络,把文件从一台电脑拷贝到另一台电脑。

scp 是基于 ssh 的原理来运作的, ssh 会在两台通过网络连接的电脑之间创建一条安全通信的管道, scp 就利用这条管道安全地拷贝文件。

scp source_file destination_file 
# source_file 表示源文件,destination_file 表示目标文件

其中 source_file 和 destination_file 都可以这样表示:user@ip:file_name , user 是登录名, ip 是域名或 ip 地址。file_name 是文件路径。

scp file.txt [email protected]:/root 
# 表示把我的电脑中当前文件夹下的 file.txt 文件拷贝到远程电脑

scp [email protected]:/root/file.txt file.txt 
# 表示把远程电脑上的 file.txt 文件拷贝到本机

rsync 远程同步文件

rsync 命令主要用于远程同步文件。它可以同步两个目录,不管它们是否处于同一台电脑。它应该是最常用于“增量备份”的命令了。它就是智能版的 scp 命令。

软件安装

yum install rsync

基础用法

rsync -arv Images/ backups/ 
# 将Images 目录下的所有文件备份到 backups 目录下

rsync -arv Images/ [email protected]:backups/ 
# 同步到服务器的backups目录下

常用参数

  • -a 保留文件的所有信息,包括权限,修改日期等;

  • -r 递归调用,表示子目录的所有文件也都包括;

  • -v 冗余模式,输出详细操作信息。

默认地, rsync 在同步时并不会删除目标目录的文件,

例如你在源目录中删除一个文件,但是用 rsync 同步时,它并不会删除同步目录中的相同文件。

如果想删除也可以这么做:

rsync -arv --delete Images/ backups/ 。

系统关闭、重启、直接运行关机

halt #关闭系统,需要 root 身份。
reboot #重启系统,需要 root 身份
poweroff #直接运行即可关机,不需要 root 身份。

Guess you like

Origin blog.csdn.net/weixin_41606115/article/details/129035116