修改时间
date -s 月/日/年 例如:date -s 07/31/2019
date -s 时:分:秒 例如:date -s 23:56:50
hwclock -w 将时间写到bois,防止重启机器时间配置失效
帮助命令
man 获得帮助信息
man 命令或配置文件
例如:man date 或 man ls 或 man systemctl
help 获得shell内置命令的帮助信息
命令 --help
例如:ls --help
[root@localhost112 ~]# ls --help Usage: ls [OPTION]... [FILE]... List information about the FILEs (the current directory by default). Sort entries alphabetically if none of -cftuvSUX nor --sort is specified. Mandatory arguments to long options are mandatory for short options too. -a, --all do not ignore entries starting with . -A, --almost-all do not list implied . and .. --author with -l, print the author of each file -b, --escape print C-style escapes for nongraphic characters --block-size=SIZE scale sizes by SIZE before printing them; e.g., '--block-size=M' prints sizes in units of 1,048,576 bytes; see SIZE format below -B, --ignore-backups do not list implied entries ending with ~ -c with -lt: sort by, and show, ctime (time of last modification of file status information); with -l: show ctime and sort by name; otherwise: sort by ctime, newest first -C list entries by columns --color[=WHEN] colorize the output; WHEN can be 'never', 'auto', or 'always' (the default); more info below -d, --directory list directories themselves, not their contents -D, --dired generate output designed for Emacs' dired mode -f do not sort, enable -aU, disable -ls --color -F, --classify append indicator (one of */=>@|) to entries --file-type likewise, except do not append '*' --format=WORD across -x, commas -m, horizontal -x, long -l, single-column -1, verbose -l, vertical -C --full-time like -l --time-style=full-iso -g like -l, but do not list owner --group-directories-first group directories before files; can be augmented with a --sort option, but any use of --sort=none (-U) disables grouping
文件目录类
ls 查看文件或者目录
[root@localhost112 ~]# ls aaa anaconda-ks.cfg openscap_data [root@localhost112 ~]# ls -l 总用量 4 -rw-r--r--. 1 root root 0 7月 31 02:23 aaa -rw-------. 1 root root 1436 8月 1 07:16 anaconda-ks.cfg drwxr-xr-x. 2 root root 39 8月 1 07:16 openscap_data [root@localhost112 ~]# ls -a . .. aaa anaconda-ks.cfg .bash_history .bash_logout .bash_profile .bashrc .bbbb .cshrc .lesshst openscap_data .tcshrc [root@localhost112 ~]# ls -lhi 总用量 4.0K 68977613 -rw-r--r--. 1 root root 0 7月 31 02:23 aaa 68972994 -rw-------. 1 root root 1.5K 8月 1 07:16 anaconda-ks.cfg 34706362 drwxr-xr-x. 2 root root 39 8月 1 07:16 openscap_data [root@localhost112 ~]# ls -la 总用量 44 dr-xr-x---. 3 root root 4096 7月 31 02:23 . dr-xr-xr-x. 17 root root 4096 8月 2 12:57 .. -rw-r--r--. 1 root root 0 7月 31 02:23 aaa -rw-------. 1 root root 1436 8月 1 07:16 anaconda-ks.cfg -rw-------. 1 root root 5593 7月 31 02:17 .bash_history -rw-r--r--. 1 root root 18 12月 29 2013 .bash_logout -rw-r--r--. 1 root root 176 12月 29 2013 .bash_profile -rw-r--r--. 1 root root 176 12月 29 2013 .bashrc -rw-r--r--. 1 root root 0 8月 1 09:16 .bbbb -rw-r--r--. 1 root root 100 12月 29 2013 .cshrc -rw-------. 1 root root 35 7月 31 23:54 .lesshst drwxr-xr-x. 2 root root 39 8月 1 07:16 openscap_data -rw-r--r--. 1 root root 129 12月 29 2013 .tcshrc
cd 切换目录
cd .. 返回上级目录
cd ~ 返回家目录
cd /root/ 切换到指定目录
[root@localhost112 ~]# cd .. [root@localhost112 /]# cd /root [root@localhost112 ~]# cd ~
cp 复制文件和目录
cp 文件名 新路径地址 例如:cp test /root/testdir
cp -r source targetfile 递归复制文件到新地址
[root@localhost112 ~]# cp testdir / cp: 略过目录"testdir" [root@localhost112 ~]# cp aaa / [root@localhost112 ~]# cp -r testdir / [root@localhost112 ~]# ll 总用量 8 -rw-r--r--. 1 root root 14 8月 2 15:59 aaa -rw-------. 1 root root 1436 8月 1 07:16 anaconda-ks.cfg drwxr-xr-x. 2 root root 39 8月 1 07:16 openscap_data drwxr-xr-x. 2 root root 21 8月 2 15:44 testdir lrwxrwxrwx. 1 root root 7 8月 2 15:54 testdir1 -> testdir [root@localhost112 ~]# cd / [root@localhost112 /]# ll 总用量 36 -rw-r--r--. 1 root root 14 8月 2 16:03 aaa lrwxrwxrwx. 1 root root 7 8月 1 07:13 bin -> usr/bin dr-xr-xr-x. 4 root root 4096 8月 1 07:17 boot drwxr-xr-x. 20 root root 3160 8月 2 12:45 dev drwxr-xr-x. 80 root root 8192 7月 31 03:12 etc drwxr-xr-x. 5 root root 38 7月 31 02:50 home lrwxrwxrwx. 1 root root 7 8月 1 07:13 lib -> usr/lib lrwxrwxrwx. 1 root root 9 8月 1 07:13 lib64 -> usr/lib64 drwxr-xr-x. 2 root root 6 8月 12 2015 media drwxr-xr-x. 2 root root 6 8月 12 2015 mnt drwxr-xr-x. 2 root root 6 8月 12 2015 opt dr-xr-xr-x. 354 root root 0 8月 2 12:45 proc dr-xr-x---. 4 root root 4096 8月 2 15:54 root drwxr-xr-x. 22 root root 620 8月 2 12:45 run lrwxrwxrwx. 1 root root 8 8月 1 07:13 sbin -> usr/sbin drwxr-xr-x. 2 root root 6 8月 12 2015 srv dr-xr-xr-x. 13 root root 0 8月 2 12:45 sys drwxr-xr-x. 2 root root 21 8月 2 16:03 testdir drwxrwxrwt. 7 root root 4096 7月 31 02:24 tmp drwxr-xr-x. 13 root root 4096 8月 1 07:13 usr drwxr-xr-x. 19 root root 4096 8月 2 12:45 var
cat 从前到后查看文件内容
[root@localhost112 ~]# cat aaa this is aaaa file1 this is aaaa file2 this is aaaa file3 this is aaaa file4 this is aaaa file5 this is aaaa file6 this is aaaa file7 this is aaaa file8 this is aaaa file9 this is aaaa file10 this is aaaa file11 this is aaaa file12
tac 从后到前查看文件内容
[root@localhost112 ~]# tac aaa this is aaaa file12 this is aaaa file11 this is aaaa file10 this is aaaa file9 this is aaaa file8 this is aaaa file7 this is aaaa file6 this is aaaa file5 this is aaaa file4 this is aaaa file3 this is aaaa file2 this is aaaa file1
rm 删除文件或目录
rm -f 文件或目录名 删除文件或目录
rm -rf 文件或目录名 递归删除文件和目录
[root@localhost112 ~]# rm -f aaa [root@localhost112 ~]# ll 总用量 4 -rw-------. 1 root root 1436 8月 1 07:16 anaconda-ks.cfg drwxr-xr-x. 2 root root 39 8月 1 07:16 openscap_data
mkdir 新建目录
mkdir 目录名
[root@localhost112 ~]# mkdir testdir [root@localhost112 ~]# ll 总用量 4 -rw-------. 1 root root 1436 8月 1 07:16 anaconda-ks.cfg drwxr-xr-x. 2 root root 39 8月 1 07:16 openscap_data drwxr-xr-x. 2 root root 6 8月 2 15:39 testdir
rmdir 删除空目录
rmdir 空目录名 不能删除非空目录;
[root@localhost112 ~]# cd testdir [root@localhost112 testdir]# ll 总用量 0 -rw-r--r--. 1 root root 0 8月 2 15:44 testfile [root@localhost112 testdir]# cd .. [root@localhost112 ~]# rmdir testdir rmdir: 删除 "testdir" 失败: 目录非空
touch 新建空文件
touch 文件名
[root@localhost112 ~]# ll 总用量 4 -rw-------. 1 root root 1436 8月 1 07:16 anaconda-ks.cfg drwxr-xr-x. 2 root root 39 8月 1 07:16 openscap_data drwxr-xr-x. 2 root root 6 8月 2 15:39 testdir [root@localhost112 ~]# cd testdir [root@localhost112 testdir]# touch testfile [root@localhost112 testdir]# ll 总用量 0 -rw-r--r--. 1 root root 0 8月 2 15:44 testfile
pwd 查看当前工作目录
[root@localhost112 testdir]# pwd /root/testdir
more 查看文件内容
more +num 文件名 例如:more +5 aaa 从第五行开始显示内容
Enter:代表向下翻『一行』;
q:代表立刻离开 more ,不再显示该文件内容。
Ctrl+F 向下滚动一屏
Ctrl+B 返回上一屏
= 输出当前行的行号
:f 输出文件名和当前行的行号
[root@localhost112 ~]# more +5 aaa this is aaaa file5 this is aaaa file6 this is aaaa file7 this is aaaa file8 this is aaaa file9 this is aaaa file10 this is aaaa file11 this is aaaa file12
less 查看文件内容
less 与 more 类似,都查看文件, 不打印在窗口上。
空白键 :向下翻动一页;
[pagedown]:向下翻动一页;
[pageup] :向上翻动一页;
/字串 :向下搜寻『字串』的功能;n:向下查找;N:向上查找;
?字串 :向上搜寻『字串』的功能;n:向上查找;N:向下查找;
q :离开这个程序;
[root@localhost112 ~]# less aaa
head 查看头部几行
head -n num 文件名 例如:head -n 4 aaa
[root@localhost112 ~]# head -n 5 aaa hello bigdata1 hello bigdata2 hello bigdata3 hello bigdata4 hello bigdata5
mv 移动文件或重命名文件
mv oldname newname 重命名文件
mv oldfile /root/targetfile 移动文件或目录
[root@localhost112 ~]# ll 总用量 8 -rw-r--r--. 1 root root 14 8月 2 15:59 aaa1 -rw-------. 1 root root 1436 8月 1 07:16 anaconda-ks.cfg drwxr-xr-x. 2 root root 39 8月 1 07:16 openscap_data drwxr-xr-x. 2 root root 21 8月 2 15:44 testdir1 [root@localhost112 ~]# mv aaa1 aaa [root@localhost112 ~]# ll 总用量 8 -rw-r--r--. 1 root root 14 8月 2 15:59 aaa -rw-------. 1 root root 1436 8月 1 07:16 anaconda-ks.cfg drwxr-xr-x. 2 root root 39 8月 1 07:16 openscap_data drwxr-xr-x. 2 root root 21 8月 2 15:44 testdir1 [root@localhost112 ~]# mv testdir1 / [root@localhost112 ~]# ll 总用量 8 -rw-r--r--. 1 root root 14 8月 2 15:59 aaa -rw-------. 1 root root 1436 8月 1 07:16 anaconda-ks.cfg drwxr-xr-x. 2 root root 39 8月 1 07:16 openscap_data [root@localhost112 ~]# cd / [root@localhost112 /]# ll 总用量 32 lrwxrwxrwx. 1 root root 7 8月 1 07:13 bin -> usr/bin dr-xr-xr-x. 4 root root 4096 8月 1 07:17 boot drwxr-xr-x. 20 root root 3160 8月 2 12:45 dev drwxr-xr-x. 80 root root 8192 7月 31 03:12 etc drwxr-xr-x. 5 root root 38 7月 31 02:50 home lrwxrwxrwx. 1 root root 7 8月 1 07:13 lib -> usr/lib lrwxrwxrwx. 1 root root 9 8月 1 07:13 lib64 -> usr/lib64 drwxr-xr-x. 2 root root 6 8月 12 2015 media drwxr-xr-x. 2 root root 6 8月 12 2015 mnt drwxr-xr-x. 2 root root 6 8月 12 2015 opt dr-xr-xr-x. 352 root root 0 8月 2 12:45 proc dr-xr-x---. 3 root root 4096 8月 2 16:08 root drwxr-xr-x. 22 root root 620 8月 2 12:45 run lrwxrwxrwx. 1 root root 8 8月 1 07:13 sbin -> usr/sbin drwxr-xr-x. 2 root root 6 8月 12 2015 srv dr-xr-xr-x. 13 root root 0 8月 2 12:45 sys drwxr-xr-x. 2 root root 21 8月 2 15:44 testdir1 drwxrwxrwt. 7 root root 4096 8月 2 16:08 tmp drwxr-xr-x. 13 root root 4096 8月 1 07:13 usr drwxr-xr-x. 19 root root 4096 8月 2 12:45 var
tail 查看文件内容
tail -F 文件名 实时监控文件内容
tail -n num 文件名 查看文件尾部num行
[root@localhost112 ~]# tail -n 6 aaa hello bigdata16 hello bigdata17 hello bigdata18 hello bigdata19 hello bigdatai20 [root@localhost112 ~]# tail -F aaa hello bigdata12 hello bigdata13 hello bigdata14 hello bigdata15 hello bigdata16 hello bigdata17 hello bigdata18 hello bigdata19 hello bigdatai20
echo 输出或者追加到某文件
echo 内容字符串 >> 目标文件 输出内容追加到目标文件 例如:echo 'test' >> /root/aaa
echo 内容字符串 > 目标文件 内容覆盖掉目标文件 例如: echo 'test' > /root/aaa
[root@localhost112 ~]# echo "hello world" >> aaa [root@localhost112 ~]# cat aaa this is aaaa file1 this is aaaa file2 this is aaaa file3 this is aaaa file4 this is aaaa file5 this is aaaa file6 this is aaaa file7 this is aaaa file8 this is aaaa file9 this is aaaa file10 this is aaaa file11 this is aaaa file12 hello world [root@localhost112 ~]# echo "hello bigdata" > aaa [root@localhost112 ~]# cat aaa hello bigdata
history 查看输入的历史命令
[root@localhost112 ~]# history 1 netstat 2 netstat -help 3 cd /etc/sysconfig/network-scripts/ 4 ls 5 vi ifcfg-eno16777736 6 cat ifcfg-eno16777736 7 service network restart 8 ping 192.168.1.1 9 ping 192.168.1.111 10 ping 192.168.1.113 11 date
重定向命令
ln 软链接
ln -s 源文件名 新链接名字 例如:ln -s test test1
[root@localhost112 ~]# ln -s testdir testdir1 [root@localhost112 ~]# ll 总用量 8 -rw-r--r--. 1 root root 231 8月 2 15:46 aaa -rw-------. 1 root root 1436 8月 1 07:16 anaconda-ks.cfg drwxr-xr-x. 2 root root 39 8月 1 07:16 openscap_data drwxr-xr-x. 2 root root 21 8月 2 15:44 testdir lrwxrwxrwx. 1 root root 7 8月 2 15:54 testdir1 -> testdir
日期类
date [option] [format]
date 查看当前日期
date -s '2019-08-02 16:28:00' 设置系统时间
date -R 查看系统时区
date "+%Y-%m-%d %H:%M:%S" 查看格式化后的日期和时间
date -d "1 days ago" 1天前的日期
date -d "next day" 1天后的日期
date -d "next monday" 下个星期一的日期
[root@localhost112 ~]# date 2019年 08月 02日 星期五 16:27:06 CST [root@localhost112 ~]# date -R Fri, 02 Aug 2019 16:27:10 +0800 [root@localhost112 ~]# date "+%Y-%m-%d %H:%M:%S" 2019-08-02 16:27:37 [root@localhost112 ~]# date -d "2 days ago" 2019年 07月 31日 星期三 16:27:51 CST [root@localhost112 ~]# date -d "next day" 2019年 08月 03日 星期六 16:28:11 CST [root@localhost112 ~]# date -d "next monday" 2019年 08月 05日 星期一 00:00:00 CST
cal 查看日历
cal 查看当月日历
cal -3 查看前后三个月
cal 年份 显示某年的全年日历
[root@localhost112 ~]# cal 八月 2019 日 一 二 三 四 五 六 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 [root@localhost112 ~]# cal -3 七月 2019 八月 2019 九月 2019 日 一 二 三 四 五 六 日 一 二 三 四 五 六 日 一 二 三 四 五 六 1 2 3 4 5 6 1 2 3 1 2 3 4 5 6 7 7 8 9 10 11 12 13 4 5 6 7 8 9 10 8 9 10 11 12 13 14 14 15 16 17 18 19 20 11 12 13 14 15 16 17 15 16 17 18 19 20 21 21 22 23 24 25 26 27 18 19 20 21 22 23 24 22 23 24 25 26 27 28 28 29 30 31 25 26 27 28 29 30 31 29 30 [root@localhost112 ~]# cal 2019 2019 一月 二月 三月 日 一 二 三 四 五 六 日 一 二 三 四 五 六 日 一 二 三 四 五 六 1 2 3 4 5 1 2 1 2 6 7 8 9 10 11 12 3 4 5 6 7 8 9 3 4 5 6 7 8 9 13 14 15 16 17 18 19 10 11 12 13 14 15 16 10 11 12 13 14 15 16 20 21 22 23 24 25 26 17 18 19 20 21 22 23 17 18 19 20 21 22 23 27 28 29 30 31 24 25 26 27 28 24 25 26 27 28 29 30 31 四月 五月 六月 日 一 二 三 四 五 六 日 一 二 三 四 五 六 日 一 二 三 四 五 六 1 2 3 4 5 6 1 2 3 4 1 7 8 9 10 11 12 13 5 6 7 8 9 10 11 2 3 4 5 6 7 8 14 15 16 17 18 19 20 12 13 14 15 16 17 18 9 10 11 12 13 14 15 21 22 23 24 25 26 27 19 20 21 22 23 24 25 16 17 18 19 20 21 22 28 29 30 26 27 28 29 30 31 23 24 25 26 27 28 29 30 七月 八月 九月 日 一 二 三 四 五 六 日 一 二 三 四 五 六 日 一 二 三 四 五 六 1 2 3 4 5 6 1 2 3 1 2 3 4 5 6 7 7 8 9 10 11 12 13 4 5 6 7 8 9 10 8 9 10 11 12 13 14 14 15 16 17 18 19 20 11 12 13 14 15 16 17 15 16 17 18 19 20 21 21 22 23 24 25 26 27 18 19 20 21 22 23 24 22 23 24 25 26 27 28 28 29 30 31 25 26 27 28 29 30 31 29 30 十月 十一月 十二月 日 一 二 三 四 五 六 日 一 二 三 四 五 六 日 一 二 三 四 五 六 1 2 3 4 5 1 2 1 2 3 4 5 6 7 6 7 8 9 10 11 12 3 4 5 6 7 8 9 8 9 10 11 12 13 14 13 14 15 16 17 18 19 10 11 12 13 14 15 16 15 16 17 18 19 20 21 20 21 22 23 24 25 26 17 18 19 20 21 22 23 22 23 24 25 26 27 28 27 28 29 30 31 24 25 26 27 28 29 30 29 30 31
用户管理命令
useradd 添加用户
useradd 用户名 例如:useradd test
userdel 删除用户
userdel -r 用户名 例如 : userdel -r test
passwd 给用户设置密码
passwd 用户名 例如 : passwd test
usermod 修改用户
usermod -g root test 将test加入到root组
id 查看用户是否存在
id 用户名 例如:id test
whoami 查看当前登录用户
whoami
su 切换用户
su 用户名 例如:su test
exit 退出当前用户
exit
/etc/passwd 查看有哪些用户
cat /etc/passwd
[root@localhost112 ~]# id test uid=1001(test) gid=1001(test) 组=1001(test) [root@localhost112 ~]# userdel -r test [root@localhost112 ~]# id test id: test: no such user [root@localhost112 ~]# cat /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 adm:x:3:4:adm:/var/adm:/sbin/nologin lp:x:4:7:lp:/var/spool/lpd:/sbin/nologin sync:x:5:0:sync:/sbin:/bin/sync shutdown:x:6:0:shutdown:/sbin:/sbin/shutdown halt:x:7:0:halt:/sbin:/sbin/halt mail:x:8:12:mail:/var/spool/mail:/sbin/nologin operator:x:11:0:operator:/root:/sbin/nologin games:x:12:100:games:/usr/games:/sbin/nologin ftp:x:14:50:FTP User:/var/ftp:/sbin/nologin nobody:x:99:99:Nobody:/:/sbin/nologin avahi-autoipd:x:170:170:Avahi IPv4LL Stack:/var/lib/avahi-autoipd:/sbin/nologin systemd-bus-proxy:x:999:997:systemd Bus Proxy:/:/sbin/nologin systemd-network:x:998:996:systemd Network Management:/:/sbin/nologin dbus:x:81:81:System message bus:/:/sbin/nologin polkitd:x:997:995:User for polkitd:/:/sbin/nologin tss:x:59:59:Account used by the trousers package to sandbox the tcsd daemon:/dev/null:/sbin/nologin postfix:x:89:89::/var/spool/postfix:/sbin/nologin sshd:x:74:74:Privilege-separated SSH:/var/empty/sshd:/sbin/nologin ssrs:x:1000:1000:ssrs:/home/ssrs:/bin/bash [root@localhost112 ~]# useradd testuser [root@localhost112 ~]# passwd testuser 更改用户 testuser 的密码 。 新的 密码: 无效的密码: 密码包含用户名在某些地方 重新输入新的 密码: 抱歉,密码不匹配。 新的 密码: 无效的密码: 密码包含用户名在某些地方 重新输入新的 密码: passwd:所有的身份验证令牌已经成功更新。 [root@localhost112 ~]# su testuser [testuser@localhost112 root]$ ll ls: 无法打开目录.: 权限不够 [testuser@localhost112 root]$ exit exit [root@localhost112 ~]# id testuser uid=1001(testuser) gid=1001(testuser) 组=1001(testuser) [root@localhost112 ~]# whoami root [root@localhost112 ~]# who am i root pts/0 2019-07-31 02:22 (192.168.1.1) [root@localhost112 ~]# usermod -g root testuser [root@localhost112 ~]# id testuser uid=1001(testuser) gid=0(root) 组=0(root)
用户组管理命令
groupadd 增加组
groupadd 组名
groupdel 删除组
groupdel 组名
groupmod 修改组
group -n 新组名 旧组名
/etc/group 查看创建了那些组
cat /etc/group
[root@localhost112 ~]# groupadd test [root@localhost112 ~]# groupmod -n test1 test [root@localhost112 ~]# cat /etc/group root:x:0: ... postdrop:x:90: postfix:x:89: sshd:x:74: ssrs:x:1000:ssrs testuser:x:1001: test1:x:1002: [root@localhost112 ~]# groupdel testuser [root@localhost112 ~]# cat /etc/group ... dip:x:40: postdrop:x:90: postfix:x:89: sshd:x:74: ssrs:x:1000:ssrs test1:x:1002:
文件权限类
文件属性
Linux系统是一种典型的多用户系统,不同的用户处于不同的地位,拥有不同的权限。为了保护系统的安全性,Linux系统对不同的用户访问同一文件(包括目录文件)的权限做了不同的规定。
在Linux中我们可以使用ll或者ls –l命令来显示一个文件的属性以及文件所属的用户和组。
1 2 3 4 5 6 7 8 9 10
1)从左到右的10个字符表示:
如果没有权限,就会出现减号[ - ]而已。从左至右用0-9这些数字来表示:
(1)0首位表示类型
在Linux中第一个字符代表这个文件是目录、文件或链接文件等等
- 代表文件
d 代表目录
c 字符流,装置文件里面的串行端口设备,例如键盘、鼠标(一次性读取装置)
s socket
p 管道
l 链接文档(link file);
b 设备文件,装置文件里面的可供储存的接口设备(可随机存取装置)
(2)第1-3位确定属主(该文件的所有者)拥有该文件的权限。---User
(3)第4-6位确定属组(所有者的同组用户)拥有该文件的权限,---Group
(4)第7-9位 ---Other用户
文件类型 | 属主权限 | 属组权限 | 其他用户权限 |
---|---|---|---|
- | 1 2 3 | 4 5 6 | 7 8 9 |
d | R(4) w(2) x(1) | R - x | R - x |
目录文件 | 读 写 执行 | 读 写 执行 | 读 写 执行 |
chmod 改变权限
基本语法
chmod [{ugo}{+-=}{rwx}] [文件或目录] [mode=421 ] [文件或目录]
功能描述
改变文件或者目录权限
文件: r-查看;w-修改;x-执行文件
目录: r-列出目录内容;w-在目录中创建和删除;x-进入目录
删除一个文件的前提条件: 该文件所在的目录有写权限,你才能删除该文件
[root@localhost112 ~]# ll 总用量 8 -r--rw-rw-. 1 root root 313 8月 2 16:12 aaa -rw-------. 1 root root 1436 8月 1 07:16 anaconda-ks.cfg drwxr-xr-x. 2 root root 39 8月 1 07:16 openscap_data [root@localhost112 ~]# chmod g+rwx aaa [root@localhost112 ~]# ll 总用量 8 -r--rwxrw-. 1 root root 313 8月 2 16:12 aaa -rw-------. 1 root root 1436 8月 1 07:16 anaconda-ks.cfg drwxr-xr-x. 2 root root 39 8月 1 07:16 openscap_data [root@localhost112 ~]# chmod u+rwx aaa [root@localhost112 ~]# ll 总用量 8 -rwxrwxrw-. 1 root root 313 8月 2 16:12 aaa -rw-------. 1 root root 1436 8月 1 07:16 anaconda-ks.cfg drwxr-xr-x. 2 root root 39 8月 1 07:16 openscap_data [root@localhost112 ~]# chmod o= aaa [root@localhost112 ~]# ll 总用量 8 -rwxrwx---. 1 root root 313 8月 2 16:12 aaa -rw-------. 1 root root 1436 8月 1 07:16 anaconda-ks.cfg drwxr-xr-x. 2 root root 39 8月 1 07:16 openscap_data [root@localhost112 ~]# chmod u+rw aaa [root@localhost112 ~]# ll 总用量 8 -rwxrwx---. 1 root root 313 8月 2 16:12 aaa -rw-------. 1 root root 1436 8月 1 07:16 anaconda-ks.cfg drwxr-xr-x. 2 root root 39 8月 1 07:16 openscap_data [root@localhost112 ~]# chmod u+rw- aaa [root@localhost112 ~]# ll 总用量 8 -rwxrwx---. 1 root root 313 8月 2 16:12 aaa -rw-------. 1 root root 1436 8月 1 07:16 anaconda-ks.cfg drwxr-xr-x. 2 root root 39 8月 1 07:16 openscap_data [root@localhost112 ~]# chmod u= aaa [root@localhost112 ~]# ll 总用量 8 ----rwx---. 1 root root 313 8月 2 16:12 aaa -rw-------. 1 root root 1436 8月 1 07:16 anaconda-ks.cfg drwxr-xr-x. 2 root root 39 8月 1 07:16 openscap_data