日期:2014-05-16 浏览次数:20746 次
chattr : 修改文件的隐藏属性 使用方法: chattr [+-=][ASacdistu] FileName + : Add one attribute - : Remove one attribute = : Set to be the only attributes that the files have 重要选项: "a":只能追加文件的内容,但不能修改或删除内容 "i":文件不能被删除、改名、不能创建指向它的链接,不能向文件写内容
drwxrwxrwt 12 root root 16384 Mar 6 09:04 tmp/
SUID 对于文件:以文件所有者的权限运行 对于目录:不能对目录设置SUID 设置SUID: chmod u+s FILE chmod 4755 FILE
对于文件:以文件所属组的权限运行 对于目录:目录里面的文件会继承目录的属性 设置SGID: chmod g+s FILE/DIR chmod 2771 FILE/DIR
对于文件:不能对文件设置Sticky位 对于目录:对于该目录下的文件,只有它们的所有者才能删除它们。 设置Sticky: chmod o+t DIR chmod 1777 DIR
u+s g+s o+t
4 for SUID 2 for SGID 1 for Sticky
/* author: JH Gao <gaopenghigh@gmail.com> # Create Date: 2012-06-05 # Function: transmit euid and egid to other scripts # since shell/python/... scripts can't get suid permission in Linux # ******************************************************************** */ #include <stdio.h> #include <stdlib.h> #include <unistd.h> #define BUFFSIZE 1024 /* * usually euid is the uid who run the program * but when stick is setted to the program * euid is the uid or the program's owner */ int main(int argc, char *argv[]) { char *cmd = "/home/jh/bin/myscript.sh"; char *pars[] = {"/home/jh/bin/myscript.sh", "par1", "par2"}; // set uid and gid to euid and egid setuid(geteuid()); setgid(getegid()); if (execvp(cmd, pars)) { printf("error"); free(cmd); exit(1); } free(cmd); }
$ gcc -t transeuid transeuid.c $ sudo chown root transeuid $ sudo chmod +s transeuid $ ./transeuid ......DO SOMETHING
find . iname "*.mp3" -execdir mid3iconv -e gbk --remove-v1 {} \;