单纯提供一个相对的解答,并不是标准答案!
单纯就是个解答的参考,写完之后再来这边查查看答案跟你想的一样不一样!?
操作动作 | /dir1 | /dir1/file1 | /dir2 | 重点 |
读取 file1 内容 | x | r | - | 目录:因为你已经知道文件的文件名是 file1,所以不需要使用 ls 去查找文件名,因此目录只要具备 x 即可。若不知道文件名,才需要有目录的 r。 文件:需要知道内容才能读取,所以需要 r 的权限 |
修改 file1 内容 | x | rw | - | 目录:目录的权限如同上面。 文件:由于我们需要『修改』该文件内容,因此,file1 最好具备 r 的权限,否则会看不到之前的数据喔! |
运行 file1 内容 | x | rx (x) | - | 目录:你需要进入该目录才能够去运行在该目录内的文件啊!所以需要 x 即可。 文件:若要运行该文件至少需要有 x 权限。但是,如果该文件是脚本档 (shell script),那得要看到内容后才有办法运行。 因此答案可能是 x 也可能是 rx。 |
删除 file1 文件 | wx | - | - | 目录:因为你需要删除该文件名,因此至少得要能够进入以及更动文件名的权限,所以至少需要 wx 才行。不需要 r 的原因如第一点所示。 文件:如同前一小节最后一个练习,要删除文件名与该文件无关,与该文件所在的目录有关喔! |
将 file1 拷贝到 /dir2 | x | r | wx | 来源目录与文件:就跟第一点一样,要能够读到该文件的权限 目标目录:创建文件跟删除文件意义差不多,要能进入且修改文件名,所以需要 wx 。 |
将 file1 移动到 /dir2 | wx | -(r) | wx | 同一文件系统中:假设这两个目录在同一个文件系统上面,那么移动文件名就跟文件本身无关,因此只需要两者目录均有更改文件名的权限 (wx) 即可。 不同文件系统中:但是如果这两个目录是在不同的文件系统当中,那么文件就是『被拷贝后删除』,此时文件要加上 r 的权限才行! |
[student@station10-101 ~]$ su - 密码: [root@station10-101 ~]# cd /dev/shm [root@station10-101 shm]# mkdir unit05 [root@station10-101 shm]# chmod 775 unit05 [root@station10-101 shm]# cd unit05 [root@station10-101 unit05]# mkdir dir1 [root@station10-101 unit05]# chmod 754 dir1 [root@station10-101 unit05]# cp /etc/hosts dir1/file1 [root@station10-101 unit05]# chmod 644 dir1/file1 [root@station10-101 unit05]# mkdir dir2 [root@station10-101 unit05]# chmod 751 dir2 [root@station10-101 unit05]# cp /etc/hosts dir2/file2 [root@station10-101 unit05]# chmod 644 dir2/file2 [root@station10-101 unit05]# mkdir dir3 [root@station10-101 unit05]# chmod 755 dir3 [root@station10-101 unit05]# cp /etc/hosts dir3/file3 [root@station10-101 unit05]# chmod 666 dir3/file3 [root@station10-101 unit05]# mkdir dir4 [root@station10-101 unit05]# chmod 777 dir4 [root@station10-101 unit05]# cp /etc/hosts dir4/file4 [root@station10-101 unit05]# chmod 600 dir4/file4 [root@station10-101 unit05]# ll -d . dir* dir*/* drwxrwxr-x. 6 root root 120 Mar 21 21:53 . drwxr-xr--. 2 root root 60 Mar 21 21:52 dir1 -rw-r--r--. 1 root root 158 Mar 21 21:52 dir1/file1 drwxr-x--x. 2 root root 60 Mar 21 21:53 dir2 -rw-r--r--. 1 root root 158 Mar 21 21:53 dir2/file2 drwxr-xr-x. 2 root root 60 Mar 21 21:53 dir3 -rw-rw-rw-. 1 root root 158 Mar 21 21:53 dir3/file3 drwxrwxrwx. 2 root root 60 Mar 21 21:54 dir4 -rw-------. 1 root root 158 Mar 21 21:54 dir4/file4
a. 的部份 [student@station10-101 ~]$ cd /dev/shm/unit05/ [student@station10-101 unit05]$ ll dir1 ls: 无法访问 'dir1/file1': 拒绝不符权限的操作 总计 0 -????????? ? ? ? ? ? file1 # 因为有 dir1 的 r 权限,因此可以看到『文件名列表』没问题。 # 但是,因为没有 x 的权限,因此无法针对 file1 的详细属性进行查阅 # 所以,就像上面这样,权限与属性的部份会没权限!文件名是可以看到的! [student@station10-101 unit05]$ ll dir2 ls: cannot open directory 'dir2': 拒绝不符权限的操作 # 不用讲,因为没有 dir2 的 r 权限,所以看不到任何东西! [student@station10-101 unit05]$ ll dir3 总计 4 -rw-rw-rw-. 1 root root 158 3月 21 21:53 file3 [student@station10-101 unit05]$ ll dir4 总计 4 -rw-------. 1 root root 158 3月 21 21:54 file4 # 因为有 dir3, dir4 的 r 与 x 权限,所以可以看到『文件名列表』与权限!至于 c 的部份,请自行使用 vim 去编辑文件,然后进行强制保存 (:w!) ,会得到底下的结果:
b. 的部份 [student@station10-101 unit05]$ ll dir1/file1 ls: 无法访问 'dir1/file1': 拒绝不符权限的操作 # 查看文件名数据与目录的权限有关。因为 student 仅有 dir1 的 r 没有 x 的权限, # 所以不能将 file1 拿出来看,因此只能看到文件名,无法知道文件属性。 [student@station10-101 unit05]$ ll dir2/file2 -rw-r--r--. 1 root root 158 3月 21 21:53 dir2/file2 # 与上面不同,student 具有 dir2 的 x 权限,而且已经知道 file2 的文件名, # 所以不需要 dir2 的 r 也能得到 file2 的文件名数据,也能直接看到 file2 的权限属性! [student@station10-101 unit05]$ ll dir3/file3 -rw-rw-rw-. 1 root root 158 3月 21 21:53 dir3/file3 [student@station10-101 unit05]$ ll dir4/file4 -rw-------. 1 root root 158 3月 21 21:54 dir4/file4 # 因为具有 dir3, dir4 的 rx 权限,所以可以直接查看到 file3, file4 的文件名与权限
a. 部份 [student@station10-101 ~]$ pstree -p | grep '(1)' systemd(1)-+-ModemManager(973)-+-{ModemManager}(991) # 所以得到答案为 systemd 啰! [student@station10-101 ~]$ ps aux | grep ' 1 ' root 1 0.0 0.5 244840 10084 ? Ss 3月16 0:04 /usr/lib/systemd/systemd --switched-root --system --deserialize 18 student 16374 0.0 0.0 12108 1068 pts/0 S+ 15:58 0:00 grep --color=auto 1不论是 pstree 还是 ps aux ,要找 PID 为 1,可以通过找到 (1) 及 1 单独存在 (1 的两边有个空白),就可以找到了。所以答案就是 systemd 这个指令。 至于 b 要找到 crond 的 PID,同样可以通过这个方式来找到:
[student@station10-101 ~]$ pstree -p | grep crond |-crond(1523) [student@station10-101 ~]$ ps aux | grep crond root 1523 0.0 0.1 36088 3220 ? Ss 3月16 0:00 /usr/sbin/crond -n student 16406 0.0 0.0 12108 972 pts/0 S+ 16:01 0:00 grep --color=auto crond都可以找到 PID 为 1523。另外要注意,每个系统的 PID 都不一样,所以,在你的系统上面看到的数值不同,也是合理的!
[student@station10-101 ~]$ su - 密码: [root@station10-101 ~]# su - student [student@station10-101 ~]$ su - Password: [root@station10-101 ~]# ps -l F S UID PID PPID C PRI NI ADDR SZ WCHAN TTY TIME CMD 4 S 0 16424 14132 0 80 0 - 47473 - pts/0 00:00:00 su <==这里变成 root 4 S 0 16430 16424 0 80 0 - 6639 - pts/0 00:00:00 bash 4 S 0 16460 16430 0 80 0 - 47467 - pts/0 00:00:00 su <==这里变成 student 4 S 0 16487 16461 0 80 0 - 47470 - pts/0 00:00:00 su <==这里又变成 root 4 S 0 16491 16487 0 80 0 - 6639 - pts/0 00:00:00 bash 0 R 0 16515 16491 0 80 0 - 11191 - pts/0 00:00:00 ps你可以很轻松的查阅到,下一行的 PPID 就是前一行的 PID (几乎啦!),其实整笔输出应该还少了一个项目, 那就是 bash 这个进程!毕竟每运行一次 su 后,系统就会给予一个新的权限的 bash,但是上面只输出 2 个而已啊! 此外,也只有 root 权限才能往前追踪~也因为已经使用了 3 次 su 啊,所以当然要输入 3 次 exit 后, 才能回到原本的 bash 喔!
[root@station10-101 ~]# man ps ...... EXAMPLES To see every process on the system using standard syntax: ps -e ps -ef ps -eF ps -ely To see every process on the system using BSD syntax: ps ax ps axu To print a process tree: ps -ejH ps axjf To get info about threads: ps -eLf ps axms To get security info: ps -eo euser,ruser,suser,fuser,f,comm,label ps axZ ps -eM To see every process running as root (real & effective ID) in user format: ps -U root -u root u To see every process with a user-defined format: ps -eo pid,tid,class,rtprio,ni,pri,psr,pcpu,stat,wchan:14,comm ps axo stat,euid,ruid,tty,tpgid,sess,pgrp,ppid,pid,pcpu,comm ps -Ao pid,tt,user,fname,tmout,f,wchan ......题目说,我们只需要 pid, pri, ni 与指令 (可用 comm 或 args),因此,可以这样处理:
[root@station10-101 ~]# ps -eo pid,pri,ni,args
PID PRI NI COMMAND
1 19 0 /usr/lib/systemd/systemd --switched-root --system --deserialize 18
2 19 0 [kthreadd]
3 39 -20 [rcu_gp]
4 39 -20 [rcu_par_gp]
6 39 -20 [kworker/0:0H-kblockd]
......
16922 19 0 ps -eo pid,pri,ni,args
26698 19 0 [kworker/7:3-cgroup_destroy]
至于排序部份,当你 man ps ,并且搜索 --sort 之后,可以找到这一段:
[root@station10-101 ~]# man ps
--sort spec
Specify sorting order. Sorting syntax is [+|-]key[,[+|-]key[,...]]. Choose a multi-letter key from
the STANDARD FORMAT SPECIFIERS section. The "+" is optional since default direction is increasing
numerical or lexicographic order. Identical to k. For example: ps jax --sort=uid,-ppid,+pid
因此,要使用指令名称来排序,基本上可以这样做:
[student@station10-101 ~]$ ps -eo pid,pri,ni,comm --sort=comm
PID PRI NI COMMAND
2041 19 0 (sd-pam)
2425 19 0 (sd-pam)
14117 19 0 (sd-pam)
973 19 0 ModemManager
1104 19 0 NetworkManager
......
1002 19 0 avahi-daemon
2432 19 0 bash
14132 19 0 bash
15381 19 0 bash
15316 19 0 boltd
2304 19 0 colord
......
[student@station10-101 ~]$ man top TOP(1) User Commands TOP(1) NAME top - display Linux processes SYNOPSIS top -hv|-bcEHiOSs1 -d secs -n max -u|U user -p pid -o fld -w [cols] The traditional switches `-' and whitespace are optional. ......因此,只要『 top -d 2 』即可每两秒更新一次画面了。另外,如果需要查找 top 里面数据的排序,可以使用 man top 之后, 搜索 sorting 这个关键字,就能得到底下的画面:
[student@station10-101 ~]$ man top ...... SORTING of task window For compatibility, this top supports most of the former top sort keys. Since this is primarily a service to former top users, these commands do not appear on any help screen. command sorted-field supported A start time (non-display) No M %MEM Yes N PID Yes P %CPU Yes T TIME+ Yes ......所以,你只要输入『 top -d 2 』之后,在活动的窗口中,直接输入大写字符的『 M 』以及『 P 』以及『 T 』, 就可以知道排序的差异了!缺省是使用 P 这个 CPU 使用率排序的!
a. 使用 man ps 找到 exapmle 之后,知道如下的动作可以查找 ps 的输出: [roott@station10-101 ~]# ps -eo pid,pri,ni,comm PID PRI NI COMMAND 1 19 0 systemd 2 19 0 kthreadd ...... b. 搭配 grep 来抓关键字: [root@station10-101 ~]# ps -eo pid,pri,ni,comm | grep crond 1523 19 0 crond c. 将上面的 1523 PID 的 ni 值改掉: [root@station10-101 ~]# renice -n -15 -p 1523 1523 (process ID) old priority 0, new priority -15 [root@station10-101 ~]# ps -eo pid,pri,ni,comm | grep crond 1523 34 -15 crond最终的 NI 从 0 变成了 -15 了,至于 PRI 则从原本的 19 变成了 34 了!(19 - (-15) = 19+15 = 34)
[root@station10-101 ~]# man nice NICE(1) User Commands NICE(1) NAME nice - run a program with modified scheduling priority SYNOPSIS nice [OPTION] [COMMAND [ARG]...] DESCRIPTION Run COMMAND with an adjusted niceness, which affects process scheduling. With no COMMAND, print the current niceness. Niceness values range from -20 (most favorable to the process) to 19 (least favorable to the process). Mandatory arguments to long options are mandatory for short options too. -n, --adjustment=N add integer N to the niceness (default 10)知道指令下达的方式之后,就可以开始处理了:
[root@station10-101 ~]# nice -n 10 su - student [student@station10-101 ~]$ ps -l F S UID PID PPID C PRI NI ADDR SZ WCHAN TTY TIME CMD 0 S 1000 20131 20124 0 80 0 - 6859 - pts/0 00:00:00 bash 4 S 1000 20200 20199 0 90 10 - 6108 - pts/0 00:00:00 bash 0 R 1000 20226 20200 0 90 10 - 11191 - pts/0 00:00:00 ps可以很清楚的看到, nice 值是会向后继承的,因此,在上面的 20200 这个 PID 之后衍生出来的进程, 他的 Nice 都会缺省是 10 喔!这个部份也得注意!
[student@station10-101 ~]$ top -d 2 -p 20200 top - 22:11:30 up 6 days, 7:24, 3 users, load average: 0.00, 0.00, 0.00 Tasks: 1 total, 0 running, 1 sleeping, 0 stopped, 0 zombie %Cpu(s): 0.0 us, 0.0 sy, 0.0 ni, 99.9 id, 0.0 wa, 0.1 hi, 0.0 si, 0.0 st MiB Mem : 1828.4 total, 152.5 free, 1139.6 used, 536.3 buff/cache MiB Swap: 2048.0 total, 1999.7 free, 48.2 used. 507.9 avail Mem PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND 20200 student 30 10 24432 5116 3268 S 0.0 0.3 0:00.02 bash现在,当你 man top 然后搜索 renice 时,就会看到有个 r 的指令可以应用~此时,请在 top 的窗口内, 按下『 r 』,然后将 ni 值改为 0 与 15 看看。你会发现 0 不能改, 15 则可以更改成功!
[student@station10-101 ~]$ top -d 2 -p 20200 PID to renice [default pid = 20200] 20200 PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND 20200 student 30 10 24432 5116 3268 S 0.0 0.3 0:00.02 bash Renice PID 20200 to value 0 PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND 20200 student 30 10 24432 5116 3268 S 0.0 0.3 0:00.02 bash Failed renice of PID 20200 to 0: Permission denied PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND 20200 student 30 10 24432 5116 3268 S 0.0 0.3 0:00.02 bash # 上面依序输入 r, 20200, 0 的结果会是这样~如果依序输入 r, 20200, 15 的结果,会变这样: PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND 20200 student 35 15 24432 5116 3268 S 0.0 0.3 0:00.02 bash
[student@station10-101 ~]$ find / / /boot /boot/initramfs-4.18.0-147.el8.x86_64kdump.img ...... /proc/37/task/37/oom_score /proc/37/task/37/oom_adj /proc/37/task/37/oom_score_adj^Z <==按下 [ctrl]+z 喔! [1]+ Stopped find /如上所示,系统会告诉你,有一个编号 [1] 号的工作在系统内暂停 (stopped),指令内容为 find / 这样!相当清楚!
[student@station10-101 ~]$ jobs [1]+ Stopped find / [student@station10-101 ~]$ jobs -l [1]+ 20380 Stopped find /jobs -l 可以多出一个数字,那个数字就是 PID 啰!这样观察比较清楚!
[student@station10-101 ~]$ bg %1
......
[student@station10-101 ~]$ find / &> /tmp/findroot.txt & [1] 20850 [student@station10-101 ~]$ jobs -l [1]+ 20850 退出 1 find / &> /tmp/findroot.txt确实是可以看到 jobs 喔!不过因为运行过一次以后,Linux 会将搜索到的数据缓存在内存,因此再次使用 find 时, 速度会快的跟在飞一样!所以,如果第二个指令运行不够快速,你就看不到运行过程了。另外,使用数据流重导向,可以让输出消息导向到文件, 所以屏幕就不会被文件名搞乱了!
[student@station10-101 ~]$ sleep 60s ^Z <==其实这里是按下 [ctrl]+z 喔! [1]+ 已停止 sleep 60s [student@station10-101 ~]$ jobs -l [1]+ 20886 停止 sleep 60s所以,确认结果后, sleep 60s 现在正在『暂停』中没错!没有持续倒数喔!
[student@station10-101 ~]$ bg %1 [1]+ sleep 60s & [1]+ 20886 已完成 sleep 60s静待一段时间后,bash 画面会丢出 sleep 已经完成的消息给妳看喔!
[student@station10-101 ~]$ vim <==在 vim 当中按下 [ctrl]+z 的结果! [1]+ 已停止 vim [student@station10-101 ~]$ jobs -l [1]+ 20959 停止 vim确定 vim 在背景中暂停喔!
[student@station10-101 ~]$ bg %1 [1]+ vim & [1]+ 已停止 vim [student@station10-101 ~]$ jobs -l [1]+ 20959 停止 (tty 输出) vimvim 依旧是暂停的状态,这是因为 vim 一定要与人交互 (输入) 才能运行,不能自己乱动。因此,vim 在背景底下无法变成 run 的模式! 所以在背景下, vim 将永远是暂停的噜!
[student@station10-101 ~]$ passwd 更改用户 student 的密码。 Current password: <==这里先输入原本的密码,就是 mystdgo 新 密码: <==这里输入 123456 不良的密码:密码短于 8 个字符 passwd: 验证记号处理错误因为密码短之外,又太烂,所以无法通过系统的密码强度验证,就直接给妳丢出来,因此密码没有更改喔!
[student@station10-101 ~]$ openssl rand -base64 8 nGGpkK4Kjkk= [student@station10-101 ~]$ openssl rand -base64 8 4Rmi5usNDJg=相同的指令,但是每次都会产生不同的密码!我们将第二个密码拿出来,并且不要输入 = 号,亦即以『 4Rmi5usNDJg 』 作为我们的新密码看看。
[student@station10-101 ~]$ passwd 更改用户 student 的密码。 Current password: <==这里先输入原本的密码,就是 mystdgo 新 密码: <==输入新密码 4Rmi5usNDJg 再次输入新的 密码: <==再输入一次! passwd:所有核对代符都已成功更新。
[student@station10-101 ~]$ date 日 3月 22 23:19:16 CST 2020 [student@station10-101 ~]$ ll /etc/shadow ----------. 1 root root 1996 3月 22 23:17 /etc/shadow文件确实在几分钟前被更新过!所以,用户确实可以更改自己的密码喔!
[student@station10-101 ~]$ su - 密码: [root@station10-101 ~]# echo mystdgo | passwd --stdin student Changing password for user student. passwd: all authentication tokens updated successfully. [root@station10-101 ~]# exit logout
[student@station10-101 ~]$ passwd
更改用户 student 的密码。
Current password:
Current password:
[1]+ 已停止 passwd
[student@station10-101 ~]$ jobs -l
[1]+ 21350 停止 passwd
[student@station10-101 ~]$ pstree -pu | grep -A1 -B1 passwd |-gnome-terminal-(15372)-+-bash(15381)-+-grep(21446) | | |-passwd(21423,root) | | `-pstree(21445)所以 passwd 运行期间,确实就是 root 的身份啊!
[student@station10-101 ~]$ locate passwd locate: 无法运行 stat()「/var/lib/mlocate/mlocate.db」: 没有此一文件或目录 [student@station10-101 ~]$ su - 密码: [root@station10-101 ~]# updatedb [root@station10-101 ~]# exit logout [student@station10-101 ~]$ locate passwd /etc/passwd /etc/passwd- /etc/pam.d/passwd ......这个指令可以通过数据库环境,直接找到文件名列表!速度很快喔!
[student@station10-101 ~]$ ll -d /var/lib/mlocate/ drwxr-x---. 2 root slocate 24 3月 23 08:57 /var/lib/mlocate/
[student@station10-101 ~]$ which locate /usr/bin/locate [student@station10-101 ~]$ type -a locate locate 是 /usr/bin/locate基本上有两个指令可以查找『指令的绝对路径文件名』,那就是 which 以及 type -a 这两个!
[student@station10-101 ~]$ ll /usr/bin/locate -rwx--s--x. 1 root slocate 48552 5月 11 2019 /usr/bin/locate搭配前几点来看, locate 具有 SGID,亦即 student 运行 locate 时,其所属的『有效群组』将会暂时切换成为 locate 这个指令的群组, 亦即 student 的有效群组将会转成 slocate 这个群组名称。然后, /var/lib/mlocate 是属于 slocate 群组的, 而群组具有 r-x 的群线,因此,就在 student 操作 locate 时,就能够取得 r-x 的权限来读取 /var/lib/mlocate 的数据了!
[root@station10-101 ~]# ll -d /run/log/journal/ drwxr-sr-x. 3 root systemd-journal 60 3月 16 14:46 /run/log/journal/属于 systemd-journal 这个群组之外,权限设置为 SGID 喔!
[root@station10-101 ~]# touch /tmp/fromroot [root@station10-101 ~]# ll /tmp/fromroot -rw-r--r--. 1 root root 0 Mar 23 13:31 /tmp/fromroot既然是 root 处理的,当然帐号与群组都是属于 root 的!大致上就是这样!
[root@station10-101 ~]# touch /run/log/journal/fromroot [root@station10-101 ~]# ll /run/log/journal/fromroot -rw-r--r--. 1 root systemd-journal 0 Mar 23 13:33 /run/log/journal/fromroot群组会变这样!这就是 SGID 的能力!
[student@station10-101 ~]$ ll -d /tmp drwxrwxrwt. 12 root root 4096 3月 23 13:31 /tmp可以看到其他人 (others) 在 x 权限的位置上,变成了 t 这个旗标了!
[student@station10-101 ~]$ su - 密码: [root@station10-101 ~]# cd /tmp
[root@station10-101 tmp]# cp /etc/hosts myhosts [root@station10-101 tmp]# chmod 777 myhosts [root@station10-101 tmp]# ll myhosts -rwxrwxrwx. 1 root root 158 Mar 23 13:51 myhosts所以变成任何人都可以对这个文件进行变更的情况喔!
[student@station10-101 ~]$ cd /tmp [student@station10-101 tmp]$ ll myhosts -rwxrwxrwx. 1 root root 158 3月 23 13:51 myhosts
[student@station10-101 tmp]$ vim myhosts
编辑完可以按下 :w 保存没问题!
[student@station10-101 tmp]$ rm myhosts
rm: 无法移除 'myhosts': 此项操作并不被允许
因为虽然 /tmp 权限有包含 777 在内,但是因为有 SBIT 的功能,因此 myhost 仅有 root 及文件拥有者 (也恰巧是 root) 才能删除。
所以 student 是没有权限可以删除的喔![student@station10-101 tmp]$ su - 密码: [root@station10-101 ~]# cd /usr/local/bin [root@station10-101 bin]# cp /usr/bin/cat mycat2 [root@station10-101 bin]# chmod u+s mycat2 [root@station10-101 bin]# ll mycat2 -rwsr-xr-x. 1 root root 51856 Mar 23 14:22 mycat2 [root@station10-101 bin]# exit logout [student@station10-101 tmp]$ cat /etc/shadow cat: /etc/shadow: 拒绝不符权限的操作 [student@station10-101 tmp]$ mycat2 /etc/shadow root:$6$1sR2WQzGzLtoqnKA$gJXeZEYh5tOwZyhhzQgWPbhXvtCQhibDdlUbEo8nQEdaf5CZJ1b44OZpVPE1b7ZVTuynIT303BxNKi.XcEinW.::0:99999:7::: ......所以,一般帐号运行两个相同功能的指令, cat 与 mycat2 时,其产生的效果就有显著的不一样啊!
[student@station10-101 ~]$ su - 密码: [root@station10-101 ~]# cd /srv [root@station10-101 srv]# ll -d project1/ drwxrwx---. 2 root progroup 6 Mar 16 00:38 project1 [root@station10-101 srv]# chmod g+s project1/ [root@station10-101 srv]# ll -d project1/ drwxrws---. 2 root progroup 6 Mar 16 00:38 project1/ [root@station10-101 srv]# su - prouser1 [prouser1@station10-101 ~]$ cd /srv/project1/ [prouser1@station10-101 project1]$ touch fromme [prouser1@station10-101 project1]$ ll fromme -rw-rw-r--. 1 prouser1 progroup 0 Mar 23 14:27 fromme [prouser1@station10-101 project1]$ exit logout这样,任何『新建』的数据,其群组会与该目录的群组相同!
[root@station10-101 ~]# cd ~prouser1 [root@station10-101 prouser1]# mkdir for_student [root@station10-101 prouser1]# chown prouser1:student for_student/ [root@station10-101 prouser1]# chmod 770 for_student/ [root@station10-101 prouser1]# chmod o+x ~prouser1 [root@station10-101 prouser1]# ll -d ~prouser1 ~prouser1/for_student/ drwx-----x. 4 prouser1 prouser1 118 Mar 23 14:48 /home/prouser1 drwxrwx---. 2 prouser1 student 6 Mar 23 14:48 /home/prouser1/for_student/ [student@station10-101 ~]$ ll /home/prouser1 ls: cannot open directory '/home/prouser1': 拒绝不符权限的操作 <==只有 x 权限,不能浏览也是正常的 [student@station10-101 ~]$ cd /home/prouser1/for_student <==没有 r ,所以不能用 [tab] 补齐! [student@station10-101 for_student]$ pwd /home/prouser1/for_student [student@station10-101 for_student]$ touch abcd [student@station10-101 for_student]$ ll 总计 0 -rw-rw-r--. 1 student student 0 3月 23 14:52 abcd
[root@station10-101 ~]# cd ~prouser1 [root@station10-101 prouser1]# mkdir for_read [root@station10-101 prouser1]# chown prouser1 for_read [root@station10-101 prouser1]# chmod 755 for_read/ [root@station10-101 prouser1]# ll -d ~prouser1 ~prouser1/for_read/ drwx-----x. 5 prouser1 prouser1 134 Mar 23 14:55 /home/prouser1 drwxr-xr-x. 2 prouser1 root 6 Mar 23 14:55 /home/prouser1/for_read/
[student@station10-101 ~]$ nice -n 15 sh -c "sleep 60s; head -n 1 /etc/passwd"
[root@station10-101 ~]# ps -eo pid,pri,ni,comm | grep gdm 1520 19 0 gdm 2032 19 0 gdm-session-wor 2048 19 0 gdm-x-session 14712 19 0 gdm-session-wor 14743 19 0 gdm-x-session [root@station10-101 ~]# renice -n -20 -p 1520 1520 (process ID) old priority 0, new priority -20 [root@station10-101 ~]# ps -eo pid,pri,ni,comm | grep gdm 1520 39 -20 gdm 2032 19 0 gdm-session-wor 2048 19 0 gdm-x-session 14712 19 0 gdm-session-wor 14743 19 0 gdm-x-session