2.17 隐藏权限lsattr/chattr


i权限不可修改权限

chattr +i 设置隐藏权限

lsattr 文件 查看隐藏权限

[root@arslinux-01 ~]# chattr +i 1.txt 
[root@arslinux-01 ~]# mv 1.txt 11.txt
mv: 无法将"1.txt" 移动至"11.txt": 不允许的操作
[root@arslinux-01 ~]# lsattr 1.txt 
----i----------- 1.txt


·在vi时会自动创建缓存文件,当保存退出后,会把缓存写入的内容覆盖源文件,然后缓存文件才会被删除,如果加了特殊权限,那么久无法保存,因此保存一个以 ~ 结尾的缓存文件。


chattr -i 删除特殊权限

[root@arslinux-01 ~]# lsattr 1.txt 
----i----------- 1.txt
[root@arslinux-01 ~]# chattr -i 1.txt 
[root@arslinux-01 ~]# !lsattr
lsattr 1.txt 
---------------- 1.txt
[root@arslinux-01 ~]# ll 1.txt


·给目录增加i权限(不能删除、不能改名,不能在目录下增加子目录和文件,但可以更改目录下文件内容)

[root@arslinux-01 ~]# ls 111
222
[root@arslinux-01 ~]# chattr +i 111
[root@arslinux-01 ~]# lsattr -d 111
----i----------- 111
[root@arslinux-01 ~]# rm -r 111
rm:是否进入目录"111"? y
rm:是否删除目录 "111/222"?y
rm: 无法删除"111/222": 权限不够
[root@arslinux-01 ~]# mv 111 1212
mv: 无法将"111" 移动至"1212": 不允许的操作
[root@arslinux-01 ~]# touch 111/12.txt
touch: 无法创建"111/12.txt": 权限不够


目录有 i 权限,依然可以更改目录下文件的内容

[root@arslinux-01 ~]# chattr -i 111
[root@arslinux-01 ~]# lsattr 111
---------------- 111/222
[root@arslinux-01 ~]# touch 111/11.txt
[root@arslinux-01 ~]# chattr +i 111
[root@arslinux-01 ~]# lsattr -d 111/
----i----------- 111/
[root@arslinux-01 ~]# head -2 /etc/passwd > 111/11.txt 
[root@arslinux-01 ~]# cat !$
cat 111/11.txt
root:x:0:0:root:/root:/bin/bash
bin:x:1:1:bin:/bin:/sbin/nologin


a权限只可追加权限

chattr +a 设置追加权限

[root@arslinux-01 ~]# chattr +a 1.txt 
[root@arslinux-01 ~]# rm 1.txt 
rm:是否删除普通文件 "1.txt"?y
rm: 无法删除"1.txt": 不允许的操作
[root@arslinux-01 ~]# head -2 /etc/passwd > 1.txt 
-bash: 1.txt: 不允许的操作
[root@arslinux-01 ~]# head -2 /etc/passwd >> 1.txt 
[root@arslinux-01 ~]# cat 1.txt 
root:x:0:0:root:/root:/bin/bash
bin:x:1:1:bin:/bin:/sbin/nologin
[root@arslinux-01 ~]# touch 1.txt 
[root@arslinux-01 ~]# ll 1.txt 
-rw-r--r--. 1 root root 4735 3月  17 17:22 1.txt


·a权限可以追加、可以更改时间信息(touch);不能更改文件内容、不能删除、不能改名


·给目录增加a权限,可以在目录下增加子目录和子文件


lsattr 查看目录下面子目录和子文件

lsattr -d 查看目录本身权限

[root@arslinux-01 ~]# lsattr -d 111/
----i----------- 111/


lsattr -R 查看目录下子目录和子目录下的文件权限

[root@arslinux-01 ~]# lsattr -R 111/
---------------- 111/222
111/222:
---------------- 111/11.txt


lsattr -a 查看全部文件权限,包括隐藏文件

[root@arslinux-01 ~]# lsattr /root/
---------------- /root/anaconda-ks.cfg
---------------- /root/123.txt
---------------- /root/11111.txt
-----a---------- /root/1.txt
---------------- /root/222.txt
---------------- /root/2.txt
---------------- /root/234
----i----------- /root/111
[root@arslinux-01 ~]# lsattr -a /root/
---------------- /root/.
---------------- /root/..
---------------- /root/.bash_logout
---------------- /root/.bash_profile
---------------- /root/.bashrc
---------------- /root/.cshrc
---------------- /root/.tcshrc
---------------- /root/anaconda-ks.cfg
---------------- /root/.bash_history
---------------- /root/.ssh
---------------- /root/.viminfo
---------------- /root/123.txt
---------------- /root/11111.txt
-----a---------- /root/1.txt
---------------- /root/.lesshst
---------------- /root/222.txt
---------------- /root/2.txt
---------------- /root/234
----i----------- /root/111




2.18 特殊权限set_uid


·set_uid权限可以让普通用户在执行有set_uid权限的命令时,执行瞬间给普通用户赋予命令的所有者身份


前提是文件必须是二进制的,可执行的文件(普通用户执行命令时拥有该命令所有者身份)

这类文件并不多,系统中只有passwd命令

[root@arslinux-01 ~]# ll /usr/bin/passwd 
-rwsr-xr-x. 1 root root 27832 6月  10 2014 /usr/bin/passwd


chmod u+s 增加 set_uid 权限

[root@arslinux-01 ~]# su user1
[user1@arslinux-01 root]$ ls
ls: 无法打开目录.: 权限不够
[user1@arslinux-01 root]$ su
密码:
[root@arslinux-01 ~]# chmod u+s /usr/bin/ls
[root@arslinux-01 ~]# ll /usr/bin/ls
-rwsr-xr-x. 1 root root 117680 10月 31 03:16 /usr/bin/ls
[root@arslinux-01 ~]# su user1
[user1@arslinux-01 root]$ ls
111  11111.txt  123.txt  1.txt  222.txt  234  2.txt  anaconda-ks.cfg
[user1@arslinux-01 root]$ ll /usr/bin/ls
-rwsr-xr-x. 1 root root 117680 10月 31 03:16 /usr/bin/ls

·增加 set_uid 权限后,user1 用户就临时拥有了 root 用户的身份,从而可以使用 ls 命令


chmod u-s 去除 set_uid 权限

[root@arslinux-01 ~]# chmod u-s /usr/bin/ls
[root@arslinux-01 ~]# ll /usr/bin/ls
-rwxr-xr-x. 1 root root 117680 10月 31 03:16 /usr/bin/ls


chmod u+s  ——>  chmod u=rws,chmod u+x

·命令所有者权限显示S不是s,说明所有者没有执行权限,需再加上x权限

[root@arslinux-01 ~]# chmod u=rws /usr/bin/ls
[root@arslinux-01 ~]# ll !$
ll /usr/bin/ls
-rwSr-xr-x. 1 root root 117680 10月 31 03:16 /usr/bin/ls
[root@arslinux-01 ~]# chmod u+x !$
chmod u+x /usr/bin/ls
[root@arslinux-01 ~]# ll /usr/bin/ls
-rwsr-xr-x. 1 root root 117680 10月 31 03:16 /usr/bin/ls

·其实,哪怕是S权限,其他用户使用ls也不会受到影响

·普通用户可否执行root命令,看命令的其他用户权限中是否有可执行的x权限


目录虽然也可以设置set_uid命令,但是无意义。




2.19 特殊权限set_gid


set_gid set_uid 类似,只不过是普通用户临时拥有所属组的身份


·普通用户被赋予了某命令的sgid权限,那么在作用在文件时,让执行该文件的普通用户临时用户拥有所属组的身份(是否可以被普通用户执行取决于命令执行的文件的所属组权限是否有x权限)

被增加 s 权限的命令是否可以被其他用户使用,则看命令权限其他用户是否有x权限


chmod g+s 命令 
[root@arslinux-01 ~]# chmod g+s /usr/bin/ls
[root@arslinux-01 ~]# ll !$
ll /usr/bin/ls
-rwsr-sr-x. 1 root root 117680 10月 31 03:16 /usr/bin/ls


·set_gid 作用于目录

给目录设置 set_gid 后,在目录下创建子文件和子目录时,那么这些子文件和子目录所属组会根据父级目录的所属组保持一致

[root@arslinux-01 ~]# chmod g+s 234
[root@arslinux-01 ~]# ll -d 234/
drwxrwsr-x. 2 root root 6 3月  17 14:16 234/
[root@arslinux-01 ~]# chown :user1 234/
[root@arslinux-01 ~]# ll -d 234/
drwxrwsr-x. 2 root user1 6 3月  17 14:16 234/
[root@arslinux-01 ~]# touch 234/arslinux
[root@arslinux-01 ~]# mkdir 234/ars
[root@arslinux-01 ~]# ll 234/
总用量 0
drwxr-sr-x. 2 root user1 6 3月  17 21:33 ars
-rw-r--r--. 1 root user1 0 3月  17 21:33 arslinux
[root@arslinux-01 ~]# chmod g-s 234/
[root@arslinux-01 ~]# touch 234/arslinux1
[root@arslinux-01 ~]# mkdir 234/ars1
[root@arslinux-01 ~]# ll 234/
总用量 0
drwxr-sr-x. 2 root user1 6 3月  17 21:33 ars
drwxr-xr-x. 2 root root  6 3月  17 21:34 ars1
-rw-r--r--. 1 root user1 0 3月  17 21:33 arslinux
-rw-r--r--. 1 root root  0 3月  17 21:34 arslinux1


·set_gid 权限作用在文件上,和set_uid类似,可以让执行这个文件的普通用户临时拥有所属组的身份

·set_gid 权限作用在目录上,在创建子目录和子文件时,创建的子目录和子文件所属组和该目录的所属组保持一致


难理解的知识点梳理:

·普通用户能否执行root用户权限的命令,看该命令是否有 set_uid 和 set_gid 权限,有set_uid 权限时,普通用户执行命令时,瞬间获取root用户权限,执行命令,能否成功执行,需要看root用户是否有x权限;而有 set_gid 权限时,普通用户执行命令时,瞬间获取root用户组权限,执行命令,能否成功执行,要看root用户组是否有x权限。

·有 set_uid 权限,当命令执行于目录时,普通用户作为root执行命令,而能否打开目录,是要看这时root用户对目录是否有x权限

·有 set_gid 权限,当命令执行于目录时,普通用户作为root组执行命令,能否×××目录,是要看这时root组是否对目录是否有x权限

举个例子:

[user1@arslinux-01 root]$ ll -d /root/
dr-xr-x---. 5 root root 274 3月  17 17:27 /root/
[user1@arslinux-01 root]$ ll /usr/bin/ls
-rwxr-sr-x. 1 root root 117680 10月 31 03:16 /usr/bin/ls
[user1@arslinux-01 root]$ ll -d /root/
dr-xr-x---. 5 root root 274 3月  17 17:27 /root/

·ls 命令的所有者 root 拥有 set_gid 权限,普通用户 user1 执行 ls 命令时,瞬间以 root 组的身份执行了 ls 命令,而执行命令 ls 打开 /root/ 目录时,user1 就是在 root 组内,因此能否打开 /root/ 目录,完全取决于 /root/ 目录对 root 用组是否有x权限,这里是有x权限的,因此可以打开




2.20 特殊权限stick_bit


·stick_bit 防删除位(其他用户无法删除)防止别人删除自己的文件,root 除外


·系统中只有/tmp/目录防删除位

[root@arslinux-01 ~]# ll -d /tmp/
drwxrwxrwt. 21 root root 4096 3月  18 20:25 /tmp/


·某用户创建的有777权限的文件,其他用户可以查看,可以修改,但是无法删除

[root@arslinux-01 ~]# ll -d /tmp/
drwxrwxrwt. 21 root root 4096 3月  18 20:25 /tmp/
[root@arslinux-01 ~]# su arslinux
[arslinux@arslinux-01 root]$ vi /tmp/stick
[arslinux@arslinux-01 root]$ chmod 777 !$
chmod 777 /tmp/stick
[arslinux@arslinux-01 root]$ ll /tmp/stick 
-rwxrwxrwx. 1 arslinux arslinux 6 3月  18 20:33 /tmp/stick
[arslinux@arslinux-01 root]$ su
密码:
[root@arslinux-01 ~]# su user1
[user1@arslinux-01 root]$ vi /tmp/stick 
[user1@arslinux-01 root]$ rm -rf /tmp/stick 
rm: 无法删除"/tmp/stick": 不允许的操作


·只有 root 可以删除,其他用户没有权限(当然root可以删,因为 stick 在其他用户可执行上限制)


·普通用户要删除一个文件,需要看文件所在的父目录有无写权限,而不是看删除的文件本身的权限

(如果加上防删除位,那么只能更改,不能删除)




2.21 软链接文件


[root@arslinux-01 ~]# ll /bin
lrwxrwxrwx. 1 root root 7 3月  14 05:51 /bin -> usr/bin

/bin/就是/usr/bin/


·软链接文件本身存了一个文件或目录的路径,链接文件大小和路径长短有关

·软链接可以节省空间

·源文件更改后,软链接无需更改


ln -s 创建软链接:ln -s 源文件 软链接目标文件

[root@arslinux-01 tmp]# ln -s /tmp/yum.log /root/111/yum.log
[root@arslinux-01 tmp]# ll /root/111
总用量 4
-rw-rw-r--. 1 root root 65 3月  17 17:37 11.txt
drwxrwxr-x. 2 root root  6 3月  17 17:27 222
lrwxrwxrwx. 1 root root 12 3月  18 21:08 yum.log -> /tmp/yum.log


·软链接不仅可以链接文件,也可以链接目录

[root@arslinux-01 tmp]# ln -s /tmp/ars2 /root/111/ars3
[root@arslinux-01 tmp]# ll /root/111
总用量 4
-rw-rw-r--. 1 root root 65 3月  17 17:37 11.txt
drwxrwxr-x. 2 root root  6 3月  17 17:27 222
lrwxrwxrwx. 1 root root 10 3月  18 21:10 ars3 -> /tmp/ars2/
lrwxrwxrwx. 1 root root 12 3月  18 21:08 yum.log -> /tmp/yum.log


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

做相对路径的软链接,如果把软链接拷贝到其他目录,那么会导致软链接出现问题


工作中实际情况:

假设磁盘分区中,boot分区中有一个不断写入的日志,快讲boot分区占满了

那么可以把该文件移动到更大的分区中,然后做一个软链接到boot分区中

[root@arslinux-01 ~]# df -h
文件系统        容量  已用  可用 已用% 挂载点
/dev/sda3        28G  1.2G   27G    5% /
devtmpfs        476M     0  476M    0% /dev
tmpfs           487M     0  487M    0% /dev/shm
tmpfs           487M  7.7M  479M    2% /run
tmpfs           487M     0  487M    0% /sys/fs/cgroup
/dev/sda1       197M  105M   93M   54% /boot
tmpfs            98M     0   98M    0% /run/user/0
[root@arslinux-01 ~]# touch /boot/arslinux.log
[root@arslinux-01 ~]# cp /boot/arslinux.log /arslinux.log
[root@arslinux-01 ~]# rm /boot/arslinux.log 
rm:是否删除普通空文件 "/boot/arslinux.log"?y
[root@arslinux-01 ~]# ln -s /arslinux.log /boot/arslinux.log
[root@arslinux-01 ~]# ll /boot/
总用量 88060
lrwxrwxrwx. 1 root root       13 3月  18 21:30 arslinux.log -> /arslinux.log
-rw-r--r--. 1 root root   151918 11月  9 07:43 config-3.10.0-957.el7.x86_64
drwxr-xr-x. 3 root root       17 3月  14 05:51 efi
drwxr-xr-x. 2 root root       27 3月  14 05:51 grub
drwx------. 5 root root       97 3月  14 05:58 grub2
-rw-------. 1 root root 53612300 3月  14 05:56 initramfs-0-rescue-0b3b2aee4c754c669d6ca09336428b22.img
-rw-------. 1 root root 19252882 3月  14 05:58 initramfs-3.10.0-957.el7.x86_64.img
-rw-r--r--. 1 root root   314036 11月  9 07:43 symvers-3.10.0-957.el7.x86_64.gz
-rw-------. 1 root root  3543471 11月  9 07:43 System.map-3.10.0-957.el7.x86_64
-rwxr-xr-x. 1 root root  6639904 3月  14 05:56 vmlinuz-0-rescue-0b3b2aee4c754c669d6ca09336428b22
-rwxr-xr-x. 1 root root  6639904 11月  9 07:43 vmlinuz-3.10.0-957.el7.x86_64


·软链接实际上就是个快捷方式,既可以给文件做软链接,也可以给目录做软链接,还可以跨分区做软链接




2.22 硬链接文件


·硬链接只支持对文件做硬链接,不支持对目录做硬链接


[root@arslinux-01 ~]# ln 1.txt 1_hard.txt
[root@arslinux-01 ~]# ln -s 1.txt 1_soft.txt
[root@arslinux-01 ~]# ll
总用量 36
drwxrwxr-x. 3 root root    43 3月  18 21:18 111
-rwx------. 1 root root     0 3月  17 09:22 11111.txt
drwxr-xr-x. 2 root root    21 3月  18 21:18 123
-rw-r--r--. 1 root root     0 3月  17 12:04 123.txt
-rw-r--r--. 2 root root  4735 3月  17 17:22 1_hard.txt
lrwxrwxrwx. 1 root root     5 3月  18 21:39 1_soft.txt -> 1.txt
-rw-r--r--. 2 root root  4735 3月  17 17:22 1.txt
-rw-r--r--. 1 root root     0 3月  17 13:15 222.txt
drwxrwxr-x. 4 root user1   62 3月  17 21:34 234
-rw-rw-r--. 1 root root     0 3月  17 14:16 2.txt
-rw-------. 1 root root  1418 3月  14 05:58 anaconda-ks.cfg
[root@arslinux-01 ~]# ls -i
33599017 111        33583098 123.txt     33599013 1.txt    17098153 234
17098139 11111.txt  33599013 1_hard.txt  33599015 222.txt   33599016 2.txt
50803365 123        33583110 1_soft.txt    33583074 anaconda-ks.cfg


·创建一个文件和另外一个文件由相同的inode号,那么这两个文件相互为硬链接。


·删除源文件的话,软链接会失效,但是硬链接不受影响


·硬链接的文件实际文件在inode里,不同名称文件可理解为同一个inode的不同的表皮,硬链接不占双份空间,inode必须要有至少一张皮


·硬链接不会占据双份的空间,因为实际只占用了一个inode


·可以对文件做硬链接,但是不可以跨分区(不同分区在格式化时已经有各自的inode体系,不同分区可能有同一个inode号但是不相同的文件)




2.23/2.24/2.25 find命令


·可用于搜索的命令

which 可以用于搜索文件的命令 (从环境变量PATH里面去找命令)

whereis (可以搜索文件再哪里,不常用,需要更新库)

locate (可以yum安装,装完无法使用,则执行updatedb命令即可)


常用快捷键:

ctrl + L 清屏

ctrl + D 删除光标所在的字符

ctrl + C 取消当前行输入的命令,相当于Ctrl + Break取消

ctrl + U 删除光标之前到行尾的字符

ctrl + K 删除光标之后的

ctrl + E 光标移动到行尾

ctrl + A 光标移动到行首

扩展:https://www.cnblogs.com/wqsbk/p/5649037.html


·find命令:

d 目录;f 文件;l 软连接文件;s socket文件;c 字符串文件;b 块文件

-type 类型;-name 名称;-mtime 修改时间(modify);-ctime 最近更改时间(change);atime 最近访问时间(access)


更改权限会更改 ctime

更改文件内容 ctime 一定会变

访问的时间 atime,cat 一下文件内容,ctime和mtime不变


·找一个创建或更改文件内容的时间在一天以内的文件

[root@arslinux-01 ~]# find /etc/ -type f -mtime -1
/etc/resolv.conf
/etc/tuned/active_profile
/etc/tuned/profile_mode
-1小于1天,+1大于1天,不能等于1


·条件之间默认是并且的关系

-o 表示或者关系

[root@arslinux-01 ~]# find /etc/ -type f -o -mtime -1 -o -name "*.conf"


-inum 根据 inode 号查询(用于找文件的硬链接)

[root@arslinux-01 ~]# ll 1_hard.txt 
-rw-r--r--. 2 root root 4735 3月  19 21:31 1_hard.txt
[root@arslinux-01 ~]# ll -i 1_hard.txt 
33599013 -rw-r--r--. 2 root root 4735 3月  19 21:31 1_hard.txt
[root@arslinux-01 ~]# find / -inum 33599013
/root/1.txt
/root/1_hard.txt


-mmin 多少分钟以内

[root@arslinux-01 ~]# find /root/ -type f -mmin -60
/root/.lesshst
[root@arslinux-01 ~]# find /root/ -type f -mmin -120
/root/1.txt
/root/.lesshst
/root/1_hard.txt
/root/.viminfo
/root/2222.txt


-exec 在 find 的同时,做其他操作

·比如find同时,列出详细信息

[root@arslinux-01 ~]# find /root/ -type f -mmin -120 -exec ls -l {} \;
-rw-r--r--. 2 root root 4735 3月  19 21:31 /root/1.txt
-rw-------. 1 root root 48 3月  19 22:09 /root/.lesshst
-rw-r--r--. 2 root root 4735 3月  19 21:31 /root/1_hard.txt
-rw-------. 1 root root 6163 3月  19 21:51 /root/.viminfo
-rwx------. 1 root root 0 3月  19 21:59 /root/2222.txt

·find同时,改名

[root@arslinux-01 ~]# find /root/ -type f -mmin -80 -exec mv {} {}.bak \;
[root@arslinux-01 ~]# find /root/ -type f -mmin -80
/root/.lesshst.bak
/root/.viminfo.bak
/root/2222.txt.bak


-size 用find大小限定的文件(必须要有单位)

· 10k 小于10k,+10k 大于10k
[root@arslinux-01 ~]# find /root/ -type f -size -10k -exec ls -l {} \;
-rw-r--r--. 1 root root 18 12月 29 2013 /root/.bash_logout
-rw-r--r--. 1 root root 176 12月 29 2013 /root/.bash_profile
-rw-r--r--. 1 root root 176 12月 29 2013 /root/.bashrc
-rw-r--r--. 1 root root 100 12月 29 2013 /root/.cshrc
-rw-r--r--. 1 root root 129 12月 29 2013 /root/.tcshrc
-rw-------. 1 root root 1418 3月  14 05:58 /root/anaconda-ks.cfg
-rw-------. 1 root root 7362 3月  18 22:23 /root/.bash_history
-rw-r--r--. 1 root root 793 3月  16 12:13 /root/.ssh/authorized_keys
-rw-r--r--. 1 root root 0 3月  17 12:04 /root/123.txt
-rwx------. 1 root root 0 3月  17 09:22 /root/11111.txt
-rw-r--r--. 2 root root 4735 3月  19 21:31 /root/1.txt
-rwx------. 1 root root 0 3月  17 13:15 /root/222.txt
-rw-rw-r--. 1 root root 0 3月  17 14:16 /root/2.txt
-rw-r--r--. 1 root user1 0 3月  17 21:33 /root/234/arslinux
-rw-r--r--. 1 root root 0 3月  17 21:34 /root/234/arslinux1
-rw-rw-r--. 1 root root 65 3月  17 17:37 /root/111/11.txt
-rw-r--r--. 1 root root 4735 3月  18 21:36 /root/1.txz~
-rw-r--r--. 2 root root 4735 3月  19 21:31 /root/1_hard.txt
-rw-------. 1 root root 48 3月  19 22:09 /root/.lesshst.bak
-rw-------. 1 root root 6163 3月  19 21:51 /root/.viminfo.bak
-rwx------. 1 root root 0 3月  19 21:59 /root/2222.txt.bak
[root@arslinux-01 ~]# find /root/ -type f -size +10k -exec ls -l {} \;
-rw-r--r--. 1 root root 53877 2月  11 2018 /root/gakki.jpg


·大于10兆(M要大写)

[root@arslinux-01 ~]# find /root/ -type f -size +10M -exec ls -l {} \;




2.26 文件名后缀


Linux下文件是有后缀名的,但是后缀名并不能不代表文件的类型(只是习惯上会把文本文档写为.txt,这点不同于windows)


定义相同类型的文件同样的后缀名,方便管理


.txt 文本文件

.conf 配置文件

.gz 压缩文件


[root@arslinux-01 ~]#LANG=en
[root@arslinux-01 ~]# stat 2.txt
 File: '2.txt'  Size: 0          Blocks: 0          IO Block: 4096   regular empty file
Device: 803h/2051d Inode: 33599016    Links: 1
Access: (0664/-rw-rw-r--)  Uid: (    0/    root)   Gid: (    0/    root)
Context: unconfined_u:object_r:admin_home_t:s0
Access: 2019-03-17 14:16:34.917467019 +0800
Modify: 2019-03-17 14:16:34.917467019 +0800
Change: 2019-03-17 14:16:34.917467019 +0800


·区别时间:

atime 访问时间

mtime 更改文件内容时间

ctime 更改inode时间




2.27linux和windows互传文件


xshell securecrt 支持,putty 不支持


·下载安装 lrzsz 包

[root@arslinux-01 ~]# yum install -y lrzsz

过程略,等待安装完成即可。


·linux 里的文件传到 windows 上 可以用 sz 命令

就会弹出对话框,把文件保存到任意位置即可

[root@arslinux-01 ~]# sz 1.txt

【0319】权限、链接、查找、后缀名、文件互传_sgid


·windows 上的文件传到 linux 里可以用 rz 命令

在弹出的对话框中,在windows中选择要传到 linux 的文件,确定即可

[root@arslinux-01 ~]# rz

【0319】权限、链接、查找、后缀名、文件互传_sgid_02

[root@arslinux-01 ~]# ls
111        123      1_hard.txt  1.txt   222.txt  2.txt            gakki.jpg
11111.txt  123.txt  1_soft.txt  1.txz~  234      anaconda-ks.cfg




0319直播笔记


难点:inode

http://www.ruanyifeng.com/blog/2011/12/inode.html


inode包含文件的元信息,具体来说有以下内容:

* 文件的字节数

* 文件拥有者的User ID

* 文件的Group ID

* 文件的读、写、执行权限

* 文件的时间戳,共有三个:ctime指inode上一次变动的时间,mtime指文件内容上一次变动的时间,atime指文件上一次打开的时间。

* 链接数,即有多少文件名指向这个inode

* 文件数据block的位置


inode改了,ctime会变


文件名存在于目录里


特殊点:改文件名,ctime会变

https://blog.steamedfish.org/blog/post/steamedfish/why-ctime-will-change-when-rename-a-file


跨分区后,inode就不一样了


删除乱码文件:用inode号找到文件后删除

fine ./ inum 号码 | xargs rm


常用2.17,2.21,2.23~2.25