命令的一般格式
1 命令 选项 参数 2 比如说: 3 [root@rhel8 ~]# ls -l /etc/fstab 4 -rw-r--r--. 1 root root 579 Dec 17 22:22 /etc/fstab 5 6 前面九位解释: 7 -rw-r--r-- 8 -:代表的是文件 9 d:代表的是目录 10 l:代表的是链接文件 11 c:块设备文件 12 s:套接字文件 13 rw-:所有者的权限 14 r--:所属组的权限 15 r--:其他人的权限 16 17 选项: 18 又分长格式选项:如 --long 19 短格式选项:-l 20 复合选项:-ald
绝对路径和相对路径
#普通不带选项查看 [root@rhel8 ~]# ls /etc/fstab /etc/fstab #长格式显示 [root@rhel8 ~]# ls -l /etc/fstab -rw-r--r--. 1 root root 579 Dec 17 22:22 /etc/fstab #查看目录本身 [root@rhel8 ~]# ls -ld /etc drwxr-xr-x. 135 root root 8192 Dec 25 00:29 /etc #人性化显示查看内容大小 [root@rhel8 ~]# ls -ldh /etc/ drwxr-xr-x. 135 root root 8.0K Dec 25 00:29 /etc/ #递归查看内容 [root@rhel8 ~]# mkdir -p a/b/c/d [root@rhel8 ~]# ls -Rt a a: b a/b: c a/b/c: d a/b/c/d:
[root@rhel8 ~]# cd /etc/ [root@rhel8 etc]# pwd /etc
#切换到用户家目录 [root@rhel8 etc]# cd ~ [root@rhel8 ~]# cd #切换到上级目录 [root@rhel8 ~]# cd .. [root@rhel8 /]# pwd / #切换到当前目录 [root@rhel8 /]# cd . [root@rhel8 /]# pwd / #切换到上次所在的地方 [root@rhel8 /]# cd /etc/ [root@rhel8 etc]# cd - /
[root@rhel8 /]# cat /etc/issue \S Kernel \r on an \m [root@rhel8 /]# cat /etc/issue -n 1 \S 2 Kernel \r on an \m 3 [root@rhel8 /]# cat /etc/issue -v \S Kernel \r on an \m [root@rhel8 /]# cat /etc/issue -A \S$ Kernel \r on an \m$ $
[root@rhel8 ~]# mkdir /data [root@rhel8 ~]# mkdir /data/aa #递归创建 [root@rhel8 ~]# mkdir aa/bb/cc -p [root@rhel8 ~]# tree aa aa └── bb └── cc 2 directories, 0 files #直接指定权限 [root@rhel8 ~]# mkdir -m ug=rwx lala [root@rhel8 ~]# ll -d lala drwxrwxrwx. 2 root root 6 Dec 25 08:08 lala
[root@rhel8 tmp]# ll a.txt -rw-r--r--. 1 root root 0 Dec 25 08:10 a.txt #直接修改时间戳 [root@rhel8 tmp]# touch -t 201904262312 a.txt [root@rhel8 tmp]# ll a.txt -rw-r--r--. 1 root root 0 Apr 26 2019 a.txt
[root@rhel8 tmp]# head -3 /etc/passwd root:x:0:0:root:/root:/bin/bash bin:x:1:1:bin:/bin:/sbin/nologin daemon:x:2:2:daemon:/sbin:/sbin/nologin
#查看尾部后两行 [root@rhel8 tmp]# tail -n 2 /etc/passwd tcpdump:x:72:72::/:/sbin/nologin zhangsan:x:1000:1000:zhangsan:/home/zhangsan:/bin/bash #动态查看日志文件 [root@rhel8 tmp]# tail -f /var/log/messages
#查找/etc/passwd中不包含root的行 [root@rhel8 tmp]# grep -v "root" /etc/passwd #查找/etc/passwd中包含root的行 [root@rhel8 tmp]# grep "root" /etc/passwd root:x:0:0:root:/root:/bin/bash operator:x:11:0:operator:/root:/sbin/nologin
原文:https://www.cnblogs.com/LiangGaRy/p/14187248.html