标签:
1、文件权限
1.1 用户有一个称为setuid(S)的特殊权限,它出现在执行权限(x)的位置,setuid权限允许用户以拥有者的权限来执行可执行文件,即使这个可执行文件是由
其他用户运行的。
具有setuid权限的文件的权限序列如下:
-rwS------
setuid的使用不是无限制的,为了确保安全,只能使用在linux ELF 格式二进制文件上,而不能用于脚本文件。
1.2 目录拥有一个特殊的权限,叫做粘滞位(sticky bit)。如果目录设置了粘滞位,只有创建该目录的用户才能删除目录中的文件,即使用户组和其他用户也有写权限,也无能为力。粘滞位出现在其他用户权限的执行权限位(x),使用 t 或 T 来表示。如果没哟设置执行权限,但设置了粘滞位,就用 t 表示,如果同时设置了执行权限和粘滞位,就是用 T 。
例如:
d------rwt
d------rwT
设置目录粘滞位的一个典型例子就是/tmp
l例如:
drwxrwxrwt 17 root root 12288 12月 28 18:40 tmp
1.3 设置不可修改的文件
chattr +i filname
1.4 打印出当前目录下的符合链接
ls -l | grep "^l" 解释: ^ 是字符串的起始标记
readlink 打印出符合链接指向的目标路径
例如:
root@hbg:/etc/rc.d# readlink S11sysctl
../init.d/sysctl
1.5 打印文件类型
file filename
例如:
hbg@hbg:~/tarfiles$ file qsdk-qca-shortcut-fe-2.7.029.tar.bz2
qsdk-qca-shortcut-fe-2.7.029.tar.bz2: bzip2 compressed data, block size = 900k
hbg@root:~/dl$ file b.txt
b.txt: ASCII text
hbg@root:~/dl$ file base.sh
base.sh: Bourne-Again shell script, UTF-8 Unicode text executable
hbg@root:~/dl$ file *
111: setgid, directory
aaa: symbolic link to a.txt
add.sh: Bourne-Again shell script, ASCII text executable
apple.sh: Bourne-Again shell script, ASCII text executable
array.sh: Bourne-Again shell script, ASCII text executable
a.txt: ASCII text
base.sh: Bourne-Again shell script, UTF-8 Unicode text executable
bc.sh: POSIX shell script, ASCII text executable
b.txt: ASCII text
cecho.sh: ASCII text
checkword.sh: ASCII text
c.txt: ASCII text
duplicate_files: empty
duplicate_samples: empty
filestat.sh: UTF-8 Unicode text
getoopt.c: C source, ASCII text
interactive.sh: UTF-8 Unicode text
isroot.sh: POSIX shell script, ASCII text executable
junk.data: data
log.sh: Bourne-Again shell script, ASCII text executable
makemore.sh: ASCII text
printf.sh: POSIX shell script, UTF-8 Unicode text executable
remove_dup.sh: ASCII text
rename.sh: UTF-8 Unicode text
rmmore.sh: ASCII text
sleep.sh: Bourne-Again shell script, ASCII text executable
test: directory
test.sh: ASCII text
1.6 查找文件差异并进行修补
命令 : diff
非一体化(nonunified)形式的diff输出(不适用-u选项)如下:
hbg@root:~/dl$ diff version1.txt version2.txt
2,3c2
< line2
< line3
---
> lin2
5a5
> GNU is not UNIX
一体化形式的输出如下:
hbg@root:~/dl$ diff -u version1.txt version2.txt
--- version1.txt 2015-12-28 19:16:28.866869790 +0800
+++ version2.txt 2015-12-28 19:17:12.078872041 +0800
@@ -1,5 +1,5 @@
this is the original text
-line2
-line3
+lin2
line4
happy hacking !
+GNU is not UNIX
可以重定向从而生成patch文件:
hbg@root:~/dl$ diff -u version1.txt version2.txt > version.patch
hbg@root:~/dl$ cat version.patch
--- version1.txt 2015-12-28 19:16:28.866869790 +0800
+++ version2.txt 2015-12-28 19:17:12.078872041 +0800
@@ -1,5 +1,5 @@
this is the original text
-line2
-line3
+lin2
line4
happy hacking !
+GNU is not UNIX
用下列命令来进行修补:
hbg@root:~/dl$ patch -p1 version1.txt < version.patch
patching file version1.txt
hbg@root:~/dl$ cat version1.txt
this is the original text
lin2
line4
happy hacking !
GNU is not UNIX
hbg@root:~/dl$
hbg@root:~/dl$ diff -u version1.txt version2.txt
hbg@root:~/dl$
再重新输入一次这个命令 patch -p1 version1.txt < version.patch,就可以将补丁文件去掉
标签:
原文地址:http://www.cnblogs.com/rohens-hbg/p/5083503.html