帮忙文档
man
:用于查看命令的帮忙文档
格局:man 须要查问的命令
例如:man ls
相干快捷键应用:
退出:q
下一页:空格键
高低挪动:高低方向键
--help
:也能够用于查看帮忙文档
格局:须要查问的命令 --help
文件治理命令
ls
:用于列出指定目录或者文件
罕用形式:
ls -l
=ll
ls -a
:显示所有文件,蕴含暗藏文件
cd
:用于切换用户所在的目录
罕用形式:
cd
:如果前面什么都不跟,间接进入以后用户的根目录下cd 门路
:能够是绝对路径,或者相对路径cd ..
:返回上一级目录
其余:
长于利用门路的主动补全性能,按 Tab 键
pwd
:显示当前目录的绝对路径
mkdir
:创立新目录
格局:mkdir [-mp] [目录名称]
罕用形式:
mkdir 目录名称
mkdir -p 目录名称
:可能递归创立文件夹
touch
:创立空文件
罕用形式:
touch 文件名
rm
:删除文件或者目录,审慎应用
罕用形式:
rm -r 文件或文件夹目录
:删除目录前会征询
[root@localhost test1]# rm -r rm_testrm:是否删除目录 "rm_test"?y
rm -f 文件或文件夹目录
:辨识强制删除,不会征询,而是间接删除rm -rf 文件或文件夹目录
留神:rm -rf
前面不能间接加 /
,否则会导致整个系统文件被全副删除,十分危险
cp
:复制
格局:cp [选项] [起源文件(要复制的文件)] [目标文件(复制后的文件名)]
罕用形式:
cp -r 起源文件 目标文件
:用于复制目录
[root@localhost test1]# mkdir 123[root@localhost test1]# cp 123 456cp: 略过目录"123"[root@localhost test1]# cp -r 123 456[root@localhost test1]# ll总用量 0drwxr-xr-x. 2 root root 6 12月 6 22:16 123drwxr-xr-x. 2 root root 6 12月 6 22:17 456
mv
:挪动或者重命名
格局:mv [选项] [源文件或目录] [指标文件或目录]
如果挪动到当前目录,则重命名
ln
:建设链接文件
格局:ln [-s] [起源文件] [目标文件]
对于软链接与硬链接:
- 创立软链接:
ln -s [起源文件] [目标文件]
,相当于快捷方式,如果源文件被删除,则软链接生效 - 创立硬链接:
ln [起源文件] [目标文件]
,即便源文件被删除,硬链接仍然无效,可用
对于 ln
较为实用的性能是,将利用的快捷方式配置到 /usr/bin
目录下
# 设置python3 软链接ln -s /root/python36/bin/python3.6(python3.6 所在的文件目录) /usr/bin/python3# 设置pip3 软链接ln -s /root/python36/bin/pip3(pip3 所在的文件目录) /usr/bin/pip3
find
:搜寻文件
格局:find [门路] [参数] 文件名
罕用形式:
find 门路 -name 文件名(反对通配符* 与 ?)
[root@localhost test1]# ll总用量 0drwxr-xr-x. 2 root root 6 12月 6 22:16 123drwxr-xr-x. 2 root root 6 12月 6 22:17 456-rw-r--r--. 1 root root 0 12月 6 22:07 rm_test1[root@localhost test1]# find . -name 123./123[root@localhost test1]# find . -name '1*'./123[root@localhost test1]# find . -name '*1*'./rm_test1./123
find 门路 -type 文件类型
[root@localhost test1]# ll总用量 0drwxr-xr-x. 2 root root 6 12月 6 22:16 123drwxr-xr-x. 2 root root 6 12月 6 22:17 456-rw-r--r--. 1 root root 0 12月 6 22:07 rm_test1[root@localhost test1]# find . -type d../123./456
cat
:用于查看一个文件的内容并将其显示在屏幕上
格局:cat [参数] 文件名
罕用形式:
cat 文件名
cat -n 文件名
:查看文件时,把行号页显示在屏幕上cat -A 文件名
:显示所有内容,包含特殊字符
more
:查看文件时,一页一页地查阅
格局:more 文件名
快捷键:
Ctrl+D
:向上翻页Ctrl+F 或者 空格
:向下翻页- 回车键:下一行
q
:退出/搜寻内容
:向下搜寻?搜寻内容
:向上搜寻
less
:与 more
命令相似
head
:前面间接跟文件名,默认显示文件的前10行
格局:head -n 行数 文件名
注:-n后有无空格均可,字母n也能够省略
head -行数 文件名
[root@localhost test1]# head -3 /etc/passwdroot:x:0:0:root:/root:/bin/bashbin:x:1:1:bin:/bin:/sbin/nologindaemon:x:2:2:daemon:/sbin:/sbin/nologin
tail
:与 head
相似,前面间接跟文件名,用于显示文件最初10行
格局:tail -n 行数 文件名
罕用形式:
tail -f 行数 文件名
:动态显示文件的最初 n 行,默认是10行;查看日志时十分有用
tar
:能够对文件目录进行打包压缩或者解压缩
格局:tar [参数] 压缩后文件名 须要压缩的文件/目录
罕用形式:
tar -zcvf 压缩后文件名 须要压缩的文件/目录
:打包同时进行压缩
[root@localhost test1]# ll总用量 0drwxr-xr-x. 2 root root 6 12月 6 22:16 123drwxr-xr-x. 2 root root 6 12月 6 22:17 456-rw-r--r--. 1 root root 0 12月 6 22:07 rm_test1[root@localhost test1]# tar -zcvf file.tar.gz 123 456 rm_test1123/456/rm_test1[root@localhost test1]# ll总用量 4drwxr-xr-x. 2 root root 6 12月 6 22:16 123drwxr-xr-x. 2 root root 6 12月 6 22:17 456-rw-r--r--. 1 root root 153 12月 7 11:56 file.tar.gz-rw-r--r--. 1 root root 0 12月 6 22:07 rm_test1
tar -zxvf 须要解压缩的文件
:解压缩
[root@localhost tar_test]# ll总用量 4-rw-r--r--. 1 root root 153 12月 7 11:56 file.tar.gz[root@localhost tar_test]# tar -zxvf file.tar.gz123/456/rm_test1[root@localhost tar_test]# ll总用量 4drwxr-xr-x. 2 root root 6 12月 6 22:16 123drwxr-xr-x. 2 root root 6 12月 6 22:17 456-rw-r--r--. 1 root root 153 12月 7 11:56 file.tar.gz-rw-r--r--. 1 root root 0 12月 6 22:07 rm_test1
tar -zxvf 须要解压缩的文件 -C 指定门路
:解压缩到指定门路
[root@localhost tar_test]# ll总用量 4-rw-r--r--. 1 root root 153 12月 7 11:56 file.tar.gzdrwxr-xr-x. 2 root root 6 12月 7 12:02 tar_dir[root@localhost tar_test]# tar -zxvf file.tar.gz -C tar_dir/123/456/rm_test1[root@localhost tar_test]# cd tar_dir/[root@localhost tar_dir]# ll总用量 0drwxr-xr-x. 2 root root 6 12月 6 22:16 123drwxr-xr-x. 2 root root 6 12月 6 22:17 456-rw-r--r--. 1 root root 0 12月 6 22:07 rm_test1
chmod
:批改文件权限
格局:chmod [-R] 权限数字xxx 文件
:-R
:示意递归批改整个目录
[root@localhost chmod_test]# ll总用量 0-rw-r--r--. 1 root root 0 12月 7 12:26 test[root@localhost chmod_test]# chmod 777 test # 777 代表最高权限[root@localhost chmod_test]# ll总用量 0-rwxrwxrwx. 1 root root 0 12月 7 12:26 test