day 02
1 命令帮助
命令 --help
eg:su -help
[root@localhost ~]# su -help
Usage:
su [options] [-] [<user> [<argument>...]]
Change the effective user ID and group ID to that of <user>.
A mere - implies -l. If <user> is not given, root is assumed.
Options:
-m, -p, --preserve-environment do not reset environment variables
-g, --group <group> specify the primary group
-G, --supp-group <group> specify a supplemental group
-, -l, --login make the shell a login shell
-c, --command <command> pass a single command to the shell with -c
--session-command <command> pass a single command to the shell with -c
and do not create a new session
-f, --fast pass -f to the shell (for csh or tcsh)
-s, --shell <shell> run <shell> if /etc/shells allows it
-P, --pty create a new pseudo-terminal
-h, --help display this help
-V, --version display version
man 命令(更详细)
1所有用户可以执行命令的帮助信息
5配置文件的帮助信息
8管理员可以执行的帮助信息
eg:man su
2 ls list 列出对应目录下的所有数据文件
1 eg:ls 列出当前对应目录下的文件
ls 目录名,如ls /root(此为绝对路径,不用考虑前边的当前路径)
ls /root
[root@localhost ~]# ls /root
anaconda-ks.cfg Downloads Music Templates
Desktop initial-setup-ks.cfg Pictures Videos
Documents 'man su' Public
ls / /root
[root@localhost ~]# ls / /root
/:
bin dev home lib64 mnt proc run srv tmp var
boot etc lib media opt root sbin sys usr
/root:
anaconda-ks.cfg Downloads Music Templates
Desktop initial-setup-ks.cfg Pictures Videos
Documents 'man su' Public
2 ls -l或ll 以长格式展示文件信息
[root@localhost ~]# ll
total 12
-rw-------. 1 root root 1296 Nov 20 16:30 anaconda-ks.cfg
drwxr-xr-x. 2 root root 6 Nov 20 16:32 Desktop
1296 6后无单位,即默认为最小单位,为字节
3 ll -h 文件大小的单位转换
[root@localhost ~]# ll -h
total 12K
-rw-------. 1 root root 1.3K Nov 20 16:30 anaconda-ks.cfg
drwxr-xr-x. 2 root root 6 Nov 20 16:32 Desktop
若文件过于小则不会转换
4 ll -d或ls -l -d或ls -ld显式指定目录(当前)的属性(相当于单击右键)
[root@localhost ~]# ll -d
dr-xr-x---. 16 root root 4096 Nov 24 00:05 .
. 表示当前目录
[root@localhost ~]# ls -ldh
dr-xr-x---. 16 root root 4.0K Nov 24 00:05 .
5 ll -a(可以显示当前和上一级目录的属性)/ll -A (只能显示当前目录下所有文件的属性)
[root@localhost ~]# ll -a
total 48
dr-xr-x---. 16 root root 4096 Nov 24 00:05 .
dr-xr-xr-x. 17 root root 224 Nov 20 16:22 ..
-rw-------. 1 root root 1296 Nov 20 16:30 anaconda-ks.cfg
[root@localhost ~]# ll -A
total 44
-rw-------. 1 root root 1296 Nov 20 16:30 anaconda-ks.cfg
6 ll -i 查看文件节点号
[root@localhost ~]# ll -i
total 12
33575045 -rw-------. 1 root root 1296 Nov 20 16:30 anaconda-ks.cfg
1545245 drwxr-xr-x. 2 root root 6 Nov 20 16:32 Desktop
会出现两个文件节点号一样的情况,这两个文件就是同一个文件
-rw-------. 1 root root 1296 Nov 20 16:30 anaconda-ks.cfg
第一列
第一个字符:标记文件类型
Linux中有七大文件类型:- 普通文本文件(.txt) d 目录文件(文件夹)
l 软连接,符号链接文件(快捷方式) b 设备文件 c 字符设备文件
p 管道符文件 s socket套接字文件,套主机连接
第二到十一列:文件权限标识符
第二列:硬链接次数
第三列:文件的所属用户
第四列:文件的所属组
第五列:文件大小
第六到八列:文件的创建或修改时间
第九列:文件名
3 重点
软链接
概念:也是一个单独的文件,数据存储区记录的是源文件的位置信息,类似于Window的快捷方式。
作用:通过指定路径快速便捷匹配其他路径下的数据文件
应用:可以对文本文件创建,也可以对目录文件创建,支持快文件系统
表示:有箭头,通过l标记文件类型
创建方式:ln -s
硬链接
(用户可以创建,但不建议)
概念:多个文件名指向同一个inode节点
作用:防止误删,对文件名备份
应用:可以对文本文件,默认不可以对目录文件,不支持跨文件系统
表示:多个硬链接文件有相同的节点号
创建方式:
eg: #ln [OPTION] TARGET LINK-NAME
#touth FILENAME 创建文件(普通文本文件)
#mkdir DIRNAME 创建目录文件
#rm FILENAME 删除文本文件
#rm -r DIRNAME 删除目录文件
一般大写为用户自定义参数