特殊权限
passwd:s
SUID: 运行某程序时,相应进程的属主是程序文件自身的属主,而不是启动者;
chmod u+s FILE
chmod u-s FILE
如果FILE本身原来就有执行权限,则SUID显示为s;否则显示S;
SGID: 运行某程序时,相应进程的属组是程序文件自身的属组,而不是启动者所属的基本组;
chmod g+s FILE
chmod g-s FILE
develop team, hadoop, hbase, hive
/tmp/project/
develop
Sticky: 在一个公共目录,每个都可以创建文件,删除自己的文件,但不能删除别人的文件;
chmod o+t DIR
chmod o-t DIR
000:
001:
...
110:
111:
chmod 5755 /backup/test
umask 0022
umask
find:
find DIRICTORY Cretiria ACTION
匹配条件:
-type
f, d, c, b, l, s, p
-atime [+|-]
-amin
-size [+|-] 11M
10M<
-user
-uid
-nouser
-nogroup
-name
-iname
-regex
组合条件:
-a
-o
-not
\( \)
ACTION
-ls
-ok
-exec
文件特殊权限
SUID: s
SGID: s
Sticky: t
chmod u+s
g+s
o+t
练习:写一个脚本
写一个脚本,显示当前系统上shell为-s指定类型的用户,并统计其用户总数。-s选项后面跟的参数必须是/etc/shells文件中存在的shell类型,否则不执行此脚本。另外,此脚本还可以接受--help选项,以显示帮助信息。脚本执行形如:
./showshells.sh -s bash
显示结果形如:
BASH,3users,they are:
root,redhat,gentoo
#!/bin/bash
#
if [ $1 == '-s' ]; then
! grep "${2}$" /etc/shells &> /dev/null && echo "Invalid shell." && exit 7
elif [ $1 == '--help' ];then
echo "Usage: showshells.sh -s SHELL | --help"
exit 0
else
echo "Unknown Options."
exit 8
fi
NUMOFUSER=`grep "${2}$" /etc/passwd | wc -l`
SHELLUSERS=`grep "${2}$" /etc/passwd | cut -d: -f1`
SHELLUSERS=`echo $SHELLUSERS | sed 's@[[:space:]]@,@g'`
echo -e "$2, $NUMOFUSER users, they are: \n$SHELLUSERS"
${变量名}
转载于:https://blog.51cto.com/ricewang/1741386