关键字:linux文件属性和目录配置
1.命令 ls -al 表示列出所有文件的属性 包括隐藏文件(就是文件名前面第一个字符为.的文件) -rw-rw-r-- 1 wuxiaoxiao wuxiaoxiao 10758 06-17 01:05 command.txt 文件属性 连接数 所属用户 所属组 大小 最新修改时间 文件名 其中文件属性 - rw- rw- r-- 文件类型 所属用户的权限 所属组的权限 其他非本用户组的权限 文件类型: -:文件 d:目录 l:链接文件 b:设备文件中可供存储的接口设备 c:设备文件中的串行端口设备,如键盘,鼠标 2.更改所属用户组:chgrp [-R] 用户组名 文件 更改所属用户:chown [-R] 用户:用户组 文件 更改九个属性:a:表示all chmod [-R] u=rwx,go=rx 文件名 chmod a+w 文件名 chmod a-x 文件名 3.查看环境变量:echo $PATH 增加环境变量:PATH="$PATH":/sbin 4.通常用在shell脚本里面 [wuxiaoxiao@localhost ~]$ basename LINUX/command.txt :获取文件名 command.txt [wuxiaoxiao@localhost ~]$ dirname linux/command.txt :获取文件夹名 linux 5.查看文件: head -3 command.txt:查看文件前三行 tail -3 command.txt:查看文件后3行 cat -n command.txt:显示行号 cat -A command.txt:将特殊字符也显示出来(换行符是$,[tab]键是^I) cat >1.txt (ctrl+c退出):将文件值空 cat 1.txt 2.txt:同时显示俩个文件内容 cat 1.txt 2.txt >3.txt:将两个文件的内容添加到3.txt中并覆盖 cat 1.txt 2.txt >>3.txt:将两个文件的内容添加到3.txt中,追加在末尾 less -10(每页显示的行数) command.txt ([pageup],[pagedown]向上向下翻动页;/字符串:向下搜索字符串;?字符串:向上搜索字符串;n:重复前一个搜索;q:退出) 6.文件与目录的默认权限 r,w,x分别是4,2,1 文件的默认权限是- rw- rw- rw-(666) 目录的默认权限是- rwx rwx rwx(777) 命令umask:指的是默认值需要减掉的权限 例如: [wuxiaoxiao@localhost linux]$ umask 0002 [wuxiaoxiao@localhost linux]$ touch 1.txt [wuxiaoxiao@localhost linux]$ mkdir xiaoxiao [wuxiaoxiao@localhost linux]$ ls -l 总计 20 -rw-rw-r-- 1 wuxiaoxiao wuxiaoxiao 0 10-13 05:00 1.txt drwxrwxr-x 2 wuxiaoxiao w |
|