1.root是系统管理员
root是系统管理员,拥有最高的权限
sudo 可以给普通用户提权
2.tab键补齐命令功能
这个就是当我们命令唯一,可以补全命令,路径
参数一部分可以补齐
3.history 调用历史记录
histroy 历史记录
history N
[root@localhost ~]# history #查看历史记录
[root@localhost ~]#!14 #调用历史记录中的第14条
[root@localhost ~]# history
[root@localhost ~]#!ls #调用历史几率中ls开头的命令
[root@localhost ~]# history
[root@localhost ~]# ctrl+r #搜索历史记录
[root@localhost ~]# history -c #清除历史记录
[root@localhost ~]#
按esc+. #调用上一条命令的最后一个参数
按alt+. #调用上一条命令的最后一个参数,再按是上上条
上下键翻看历史记录
4.关机命令
命令 | 作用 |
---|---|
shutdown | 关机 |
poweroff | 关闭电源(关机) |
init 0 | 关机 |
shutdown | -r 时间 |
init 6 | 重启 |
5.cd :change directory 改变目录
绝对路径
-
从根开始的路径是绝对路径
-
与当前位置无关,在任何地方都可以引用
相对路径
-
不以根开始的路劲
-
以当前所在的路径开始,pwd打印当前工作目录
[root@localhost ~]# cd /home #进入/home路径
[root@localhost home]# cd .. #返回上一层目录
[root@localhost /]# cd .. #返回当前路径的上一层目录
[root@localhost /]# cd - #返回上一次的工作目录
[root@localhost /]# cd #返回当前用户的家目录
[root@localhost /]# cd ~ #返回当前用户的家目录
[root@localhost /]# cd ~username #返回某个用户的家目录
6.ls 查看目录内容
[root@localhost ~]#ls #查看文件内容
[root@localhost ~]#ll #列出文件的详细信息
[root@localhost ~]#ls -a #列出隐藏文件
[root@localhost ~]#ls -R #递归显示目录
[root@localhost ~]#ls -d #查看目录本身
[root@localhost user1]# ll
total 0
-rw-r--r--. 1 root root 0 Jun 22 02:09 a.txt
drwxr-xr-x. 2 root root 6 Jun 22 02:09 Desktop
-rw-r--r--. 1 root root 0 May 9 21:44 a.txt
drwxr-xr-x. 2 root root 6 Apr 19 13:07 Desktop
类 型:红色
- - : 文件
- d :目录
- I :链接文件
- b :块设备(比如磁盘)
- c :字符设备
权 限:橙色 这个后期会详细的讲解
链接数:绿色 对于文件时连接数,对于目录是目录里有多少字
拥有人拥有组:蓝色 (这个是两个概念,我这里都用蓝色了)
文件大小:紫色 文件大小(-h 以人类可读方式显示,这个自己试试哦)
创建时间:黄色 创建时间
名字:黑色 文件或目录的名字
7.cp命令
cp source(源) dest(目的)
[root@localhost tmp]#cp -r /etc /tmp #复制目录
[root@localhost tmp]#cp -i /etc /tmp #遇到同名文件会提示覆盖
[root@localhost tmp]#cp -p /etc /tmp #保留文件属性(权限,拥有人拥有组,时间戳)
DEST的几种情况:
-
如果DEST是目录,则直接复制到目录下面
-
如果DEST是一个不存在的文件,则复制过来后改名 cp -r /etc /tmp/test
-
如果DEST是一个已存在的文件,则复制过来后会覆盖这个文件
mv用法同cp
-
8.touch 创建文件
-
当文件不存在时则直接创建,
-
当文件存在,则更新文件的时间戳信息。
[root@localhost user1]# touch 123.txt #创建一个文件为123.txt [root@localhost user1]# ll total 0 -rw-r--r--. 1 root root 0 Jun 22 02:14 123.txt drwxr-xr-x. 2 root root 6 Jun 22 02:09 mulu [root@localhost user1]# touch 123.txt #更新时间戳 [root@localhost user1]# ll total 0 -rw-r--r--. 1 root root 0 Jun 22 02:17 123.txt drwxr-xr-x. 2 root root 6 Jun 22 02:09 mulu [root@localhost user1]# [root@localhost user1]# stat 123.txt File: a.xtx Size: 0 Blocks: 0 IO Block: 4096 regular empty file Device: fd00h/64768d Inode: 102616592 Links: 1 Access: (0644/-rw-r--r--) Uid: ( 0/ root) Gid: ( 0/ root) Context: unconfined_u:object_r:user_home_t:s0 Access: 2021-06-22 22:37:23.093172153 -0400 Modify: 2021-06-22 22:37:23.093172153 -0400 Change: 2021-06-22 22:37:23.093172153 -0400 Birth: - [root@localhost user1]#
时间戳:
-
Access: a time 文件最后一次被访问时间
-
Modify : m time文件内容最后一次被修改时间 VIM的时候不要轻易w 这样会改变m time的时间。
-
Change:C time文件状态最后一次被修改时间
9.mkdir 创建目录
[root@localhost tmp]# mkdir mulu #创建目录
[root@localhost tmp]# ll
total 0
drwxr-xr-x. 2 root root 6 Jun 10 04:07 mulu
[root@localhost tmp]# mkdir /tmp/123/456 #在/tmp/123/创建了456文件-但没有相关目录所以报错
mkdir: cannot create directory ‘/tmp/123/456’: No such file or directory #没有相关目录所以报错
[root@localhost tmp]# mkdir -p /tmp/123/456 #在/tmp/123/创建了456文件 无目录直接创建
[root@localhost tmp]# ll
total 0
drwxr-xr-x. 3 root root 17 Jun 10 04:07 123
drwxr-xr-x. 2 root root 6 Jun 10 04:07 mulu
[root@localhost tmp]# cd 123
[root@localhost 123]# ll
total 0
drwxr-xr-x. 2 root root 6 Jun 10 04:07 456
10.Rm 移除删除
可以删除文件, 目录
[root@localhost user1]# rm 123.txt
rm: remove regular empty file '123.txt'? y
[root@localhost user1]# rm -r mulu -r:删除目录
rm: descend into directory 'mulu'? y
rm: remove directory 'mulu/123'? ^C
[root@localhost user1]# rm -rf mulu #删除目录,强制且不提示
[root@localhost user1]# ll
total 0
#-i:interactive 交互 提示
#-f:强制删除,不提示
#-r:删除目录