linux学习命令总结⑩⑤

#文件的特殊权限

SetUID权限

s,当s这个标志出现在文件所有者的x权限的时候,此时就被称为SetUID权限,简称为SUID权限。

SUID要求的条件和它的主要功能:

1、SUID权限仅对二进制程序(binary program)有效

2、执行者对于改程序必须有x权限

3、这个权限只有在运行的时候才会有效(run-time)

4、执行者将会拥有该程序所有者(owner)的权限

[[email protected]_168_102_centos etc]# ls -l /etc/gs*-
-rw------- 1 root root 479 Aug 25 15:27 /etc/gshadow-
[[email protected]_168_102_centos etc]# su wanghan
[[email protected]_168_102_centos etc]$ cat /etc/gshadow-
cat: /etc/gshadow-: Permission denied
[[email protected]_168_102_centos etc]$ exit
exit
[[email protected]_168_102_centos etc]# ls -ld /bin/cat
-rwxr-xr-x 1 root root 48568 Jun 22  2012 /bin/cat
[[email protected]_168_102_centos etc]# chmod u+s /bin/cat 设定suid权限
[[email protected]_168_102_centos etc]# ls -ld /bin/cat
-rwsr-xr-x 1 root root 48568 Jun 22  2012 /bin/cat
[[email protected]_168_102_centos etc]# su wanghan
[[email protected]_168_102_centos etc]$ cat /etc/gshadow-
root:::
bin:::bin,daemon
daemon:::bin,daemon
sys:::bin,adm
adm:::adm,daemon

SetGID权限

当s项目出现在用户组的x位置上时被称为Set GID权限,也称作SGID。

SGID可以针对文件和目录来设置,如果对于文件来讲,SGID有如下的功能:

1、SGID对二进制程序有用

2、程序的执行者对于改程序来讲,必须具有x权限

3、执行者在执行的过程中将会获得该程序所属用户组的支持

当用在目录上面的时候:

1、若用户对此目录具有r和x权限时改用户能够进入该目录

2、用户在此目录下的有效用户组(effective group)将会变成该目录的用户组

3、若用户在此目录具有w(可以新建文件)权限,则用户所创建的新文件的用户组和此目录的用户组相同

[[email protected]_168_102_centos ~]# chmod g+s /tmp/sgid #设定sgid权限
[[email protected]_168_102_centos ~]# ls -ld /tmp/sgid
drwxrwsr-x 2 openstack openstack 4096 Aug 26 11:30 /tmp/sgid
[[email protected]_168_102_centos ~]# chmod o+w /tmp/sgid/
[[email protected]_168_102_centos ~]# su wanghan
[[email protected]_168_102_centos rott]$ mkdir /tmp/sgid/wanghan
[[email protected]_168_102_centos rott]$ ls -ld /tmp/sgid/wanghan
drwxrwsr-x 2 wanghan openstack 4096 Aug 26 11:34 /tmp/sgid/wanghan

SetBit权限

这个Sticky Bit(SBIT)权限只针对目录有效,对于文件已经没有效果了。

作用和前提条件:

1、当用户对于此目录具有w、x权限,即具有写入权限时

2、当用户在该目录下创建文件或目录时,仅有自己和root用户才有权利删除该文件

[[email protected]_168_102_centos ~]# ls -l /tmp/sgid/
total 8
drwxrwsr-x 2 openstack openstack 4096 Aug 26 11:38 openstack
drwxrwsr-x 2 wanghan   openstack 4096 Aug 26 11:39 wanghan
[[email protected]_168_102_centos ~]# chmod o+t /tmp/sgid/
[[email protected]_168_102_centos ~]# ls -ld /tmp/sgid
drwxrwsrwt 4 openstack openstack 4096 Aug 26 11:39 /tmp/sgid
[[email protected]_168_102_centos ~]# su wanghan
[[email protected]_168_102_centos rott]$ rm -rf /tmp/sgid/openstack
rm: cannot remove `/tmp/sgid/openstack 
[[email protected]_168_102_centos rott]$ rm -rf /tmp/sgid/wanghan

#at命令:在一个指定的时间执行一个指定任务,只能执行一次

at Time

[[email protected]_168_102_centos ~]# at 14:58
at> cat /etc/passwd
at> <EOT> #ctrl+d 提交任务
job 879 at 2014-08-26 14:58
[[email protected]_168_102_centos ~]# at 3pm
at> tail /etc/passwd
at> <EOT>
job 880 at 2014-08-26 15:00

CTRL+d:提交任务

at -l:查看作业,也可使用atq

[[email protected]_168_102_centos ~]# at -l
879    2014-08-26 14:58 a root
880    2014-08-26 15:00 a root
[[email protected]_168_102_centos ~]# atq
879    2014-08-26 14:58 a root
880    2014-08-26 15:00 a root

at -d:删除一个尚未执行的作业

[[email protected]_168_102_centos ~]# atq
879    2014-08-26 14:58 a root
880    2014-08-26 15:00 a root
[[email protected]_168_102_centos ~]# at -d 880
[[email protected]_168_102_centos ~]# atq
879    2014-08-26 14:58 a root

at -f:从指定文件读入任务而不是从标准输入读入

[[email protected]_168_102_centos ~]# cat at.sh
useradd at_test

[[email protected]_168_102_centos ~]# at -f at.sh now
job 882 at 2014-08-26 15:00
[[email protected]_168_102_centos ~]# tail -n 1 /etc/passwd
at_test:x:502:502::/home/at_test:/bin/bash
时间: 2024-08-28 14:41:13

linux学习命令总结⑩⑤的相关文章

linux学习命令总结②

#shutdown命令:系统关机.重启等 shutdown [options]- Time Time : now(马上) +#(多少分钟后) hh:mm(几点几分) 系统五分钟后关机: [[email protected]_168_102_centos ~]# shutdown 5//系统5分钟后重启 Broadcast message from [email protected]_168_102_centos (/dev/pts/0) at 16:19 ... The system is go

linux学习命令总结⑧

#chown命令:通过chown改变文件的属主和属组.在更改文件的属主或所属组时,可以使用用户名称和用户识别码设置.普通用户不能将自己的文件改变成其他的属主.其操作权限一般为管理员. 修改文件属主和属组: [[email protected]_168_102_centos ~]# ls -l total 8 drwxr-xr-x 2 wanghan hx 4096 Aug 12 10:32 abe drwxr-xr-x 2 root wanghan 4096 Aug 12 10:32 xab [

linux学习命令总结⑨

#重定向 输出重定向: 1>覆盖输出(1可省略) [[email protected]_168_102_centos tmp]# ls functions >shuchu [[email protected]_168_102_centos tmp]# cat shuchu functions [[email protected]_168_102_centos tmp]# ls fstab >shuchu [[email protected]_168_102_centos tmp]# ca

linux学习命令总结⑤

#stat命令:查看文件信息 [[email protected]_168_102_centos ~]# stat test.log File: `test.log' Size: 0 Blocks: 0 IO Block: 4096 regular empty file Device: ca01h/51713d Inode: 483339 Links: 1 Access: (0644/-rw-r--r--) Uid: ( 0/ root) Gid: ( 500/ wanghan) Access:

linux学习命令总结③

#cd ~ 回到当前用户的家目录 [[email protected]_168_102_centos etc]# pwd /etc //当前所在目录 [[email protected]_168_102_centos etc]# cd ~ //回到当前用户家木里 [[email protected]_168_102_centos ~]# pwd /root //当前用户家目录 [[email protected]_168_102_centos ~]# su wanghan [[email pro

linux学习命令总结④

#ls命令:通过ls 命令不仅可以查看linux文件夹包含的文件,而且可以查看文件权限(包括目录.文件夹.文件权限),查看目录信息等等 [[email protected]_168_102_centos /]# ls bin data etc lib lost+found mnt proc sbin srv tmp var boot dev home lib64 media opt root selinux sys usr ls –a:显示所有文件,包含.开头的隐藏文件 [[email prot

linux学习命令总结⑦

#useradd命令:建立用户帐号和创建用户的起始目录,使用权限是超级用户 [[email protected]_168_102_centos ~]# useradd test [[email protected]_168_102_centos ~]# id test uid=502(test) gid=502(test) groups=502(test) [[email protected]_168_102_centos ~]# tail -n 1 /etc/passwd test:x:502

linux学习命令总结⑩②

#fdisk命令:磁盘分区工具 fdisk –l:查看机器所挂硬盘个数及分区情况 [[email protected]_168_102_centos ~]# fdisk -l Disk /dev/xvda: 8589 MB, 8589934592 bytes 255 heads, 63 sectors/track, 1044 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Sector size (logical/physic

linux学习命令总结⑥

#文件名通配 通配符: *:匹配任意长度的任意字符(0到多个) [[email protected]_168_102_centos ~]# ls * 0812080808 2014-05-16: test.log ceshi_1: test: [[email protected]_168_102_centos ~]# ls -ld t* drwxr-xr-x 2 root wanghan 4096 Aug 11 15:46 test ?:匹配任意单个字符 [[email protected]_1

Linux 学习命令之修改日期时间

Linux 学习命令之修改日期时间 一.日期时间修改 1. 查看时间和日期 [[email protected] ~]# date 2017年 11月 03日 星期五 11:39:49 CST 或 [[email protected] ~]# clock 2017年11月03日 星期五 11时42分52秒  -1.563496 seconds 显示日历 [[email protected] ~]# cal 十一月 2017 日 一 二 三 四 五 六 1  2  3  4 5  6  7  8