100字范文,内容丰富有趣,生活中的好帮手!
100字范文 > 特殊权限位set_uid set_gid   stick_bit 软链接硬链接

特殊权限位set_uid set_gid   stick_bit 软链接硬链接

时间:2018-12-12 11:37:21

相关推荐

特殊权限位set_uid  set_gid   stick_bit  软链接硬链接

特殊权限位set_uid set_gid stick_bit 软链接硬链接

[root@alex ~]# ls -l /etc/shadow存放密码文件

----------. 1 root root 760 Oct 21 01:30 /etc/shadow

[root@alex ~]# ls -l /usr/bin/passwd

-rwsr-xr-x. 1 root root 27832 Jun 10 /usr/bin/passwd

[root@alex ~]# chmod u+s /usr/bin/ls临时拥有root权限的写法

[root@alex ~]# ls -l /usr/bin/ls

-rwsr-xr-x. 1 root root 117656 Nov6 /usr/bin/ls

如下示例:

[root@alex ~]# su - user

Last failed login: Thu Oct 26 22:22:13 CST from 183.206.173.194 on ssh:notty

There were 315 failed login attempts since the last successful login.

[user@alex ~]$ ls -l /root/ 可以使用root的权限

total 20

-rw-r--r--. 1 root root0 Oct 26 09:22 2.txt

drw-r--r--. 2 root root 4096 Oct 25 08:49 3.txt

drwxr-xr-x. 2 root root 4096 Oct 16 14:01 c

drwxr-xr-x. 2 root root 4096 Oct 18 08:46 m

drwxr-xr-x. 2 root root 4096 Oct 24 09:36 p

drwxr-xr-x. 2 root root 4096 Oct 24 09:34 zx

[user@alex ~]$ ls /root/

2.txt3.txtcmpzx

[root@alex ~]# chmod u-s /usr/bin/ls 更改原来的配置

[root@alex ~]# ls -l /usr/bin/ls

-rwxr-xr-x. 1 root root 117656 Nov6 /usr/bin/ls

[root@alex ~]# chmod u=rws/usr/bin/ls另外一种写法

[root@alex ~]# ls -l /usr/bin/ls

-rwSr-xr-x. 1 root root 117656 Nov6 /usr/bin/ls

变成大S 因为没有x权限 大写的S也不受影响 也能执行

加上x权限就会变成小s

[root@alex ~]# chmod u+x /usr/bin/ls

[root@alex ~]# ls -l /usr/bin/ls

-rwsr-xr-x. 1 root root 117656 Nov6 /usr/bin/ls

[root@alex ~]# chmod u-s /usr/bin/ls 清楚的权限的写法

[root@alex ~]# ls -l /usr/bin/ls

-rwxr-xr-x. 1 root root 117656 Nov6 /usr/bin/ls

set gid 可以作用在目录上也可以作用在子文件上,可以让普通用户临时拥有所属组的权限

[root@alex ~]# chmod g+sp

[root@alex ~]# mkdir p/2.txt

[root@alex ~]# ls -l p

total 8

-rw-r--r--. 1 root root0 Oct 26 22:49 1.txt

drwxr-sr-x. 2 root user 4096 Oct 26 22:51 2.txt

drwxr-xr-x. 2 root root 4096 Oct 26 22:50 nb

当set _gid 拥有组的权限 在他所在的组下面,创建的目录和文件用户所属组都是以该组名字定义

stick_bit 防删除位

防止别人删除自己的文件

加上防删除位

[root@alex ~]# su - user

Last login: Thu Oct 26 22:22:47 CST on pts/1

[user@alex ~]$ cd /tmp/

[user@alex tmp]$ cd

[user@alex ~]$ mkdir 1

[user@alex ~]$ chmod 777 1

[user@alex ~]$ ls -l

total 4

drwxrwxrwx. 2 user user 4096 Oct 26 23:09 1

[user@alex ~]$ cd 1

[user@alex 1]$ mkdir 2

[user@alex 1]$ touch 1.txt

[user@alex 1]$ ls -l

total 4

-rw-rw-r--. 1 user user0 Oct 26 23:10 1.txt

drwxrwxr-x. 2 user user 4096 Oct 26 23:10 2

[user@alex 1]$ rm -r 2 这里体现可以删除 就是没有加防删除位

[user@alex 1]$ ls -l

total 0

-rw-rw-r--. 1 user user 0 Oct 26 23:10 1.txt

[user@alex ~]$ chmod o+t 1 加上防删除位的用法

[user@alex ~]$ ls -l

total 4

drwxrwxrwt. 2 user user 4096 Oct 26 23:10 1

[root@alex ~]# ln -s /tmp/alex//root/p 软链接的写法

[root@alex ~]# ls -l /root/p

total 8

-rw-r--r--. 1 root root0 Oct 26 22:49 1.txt

drwxr-sr-x. 2 root user 4096 Oct 26 22:51 2.txt

lrwxrwxrwx. 1 root user10 Oct 26 23:25 alex -> /tmp/alex/ 做成软链接

drwxr-xr-x. 2 root root 4096 Oct 26 22:50 nb

软链接 左边是你的源文件 右边才是软链接文件

[root@alex ~]# ls -l x 相对路径还有绝对路径

total 0

lrwxrwxrwx. 1 root root 2 Oct 26 23:30 nb -> nb

做软链接尽量使用绝对路径

硬链接不支持对目录做硬链接

硬链接相当于备份 ,即使删除一份 还有一份存在 。

硬链接有一个特性不能对目录做硬链接

硬链接的实质就是通过文件的inode节点进行连接。我们都知道,Linux下每个文件都对应一个inode结点,都有一个单独的inode编号。而硬链接不同,每一个硬链接的inode都与源文件相同。假设我对文件A建立了一个硬链接文件B,此时B的inode编号与A相同。

每个文件可以建立一个或多个硬链接,这样可以达到“防误删”的功能,当删除了源文件时,还可以通过硬链接文件来访问文件数据。

文件可以做硬链接 前提不能跨分区

ln 硬链接的写法

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。