8. chmod chown umask lsattr chattr
来源:互联网 发布:淘宝注册帐号 编辑:程序博客网 时间:2024/06/11 21:21
2.14 更改文件或目录权限
chmod - change file mode bits
chmod [OPTION]... MODE[,MODE]... FILE...
-R, --recursive
change files and directories recursively
# ll test/ -d
drwxr-xr-x. 2 root root 28 12月 21 00:32 test/
# ll test/
总用量 0
-rw-r--r--. 1 root root 0 12月 21 00:28 123
-rw-r--r--. 1 root root 0 12月 21 00:32 456
# chmod -R 700 test/
# ll test/ -d
drwx------. 2 root root 28 12月 21 00:32 test/
# ll test/
总用量 0
-rwx------. 1 root root 0 12月 21 00:28 123
-rwx------. 1 root root 0 12月 21 00:32 456
-c, --changes
like verbose but report only when a change is made
# chmod -c 777 123
mode of "123" changed from 0644 (rw-r--r--) to 0777 (rwxrwxrwx)
# chmod -c 777 123
-v, --verbose
output a diagnostic for every file processed
# chmod -v 644 123
mode of "123" changed from 0777 (rwxrwxrwx) to 0644 (rw-r--r--)
# chmod -v 644 123
"123" 的权限模式保留为0644 (rw-r--r--)
永久更改SELinux配置(/etc/selinux/config),重启后生效。
2.15 更改所有者和所属组
chown - change file owner and group
chown [OPTION]... [OWNER][:[GROUP]] FILE...
-R, --recursive
operate on files and directories recursively
-v, --verbose
output a diagnostic for every file processed
# chown -Rv aming:user1 test/
changed ownership of "test/123" from root:root to aming:user1
changed ownership of "test/456" from root:root to aming:user1
changed ownership of "test/" from root:root to aming:user1
-c, --changes
like verbose but report only when a change is made
chgrp - change group ownership
chgrp [OPTION]... GROUP FILE...
-R, --recursive
operate on files and directories recursively
-v, --verbose
output a diagnostic for every file processed
# chgrp -Rv aming test/
changed group of "test/123" from user1 to aming
changed group of "test/456" from user1 to aming
changed group of "test/" from user1 to aming
-c, --changes
like verbose but report only when a change is made
2.16 umask
# help umask
umask: umask [-p] [-S] [模式]
显示或设定文件模式掩码。
设定用户文件创建掩码为 MODE 模式。如果省略了 MODE,则
打印当前掩码的值。
-S 以符号形式输出,否则以八进制数格式输出
# umask -S
u=rwx,g=rx,o=rx
$ umask -S
u=rwx,g=rwx,o=rx
/etc/bashrc
# By default, we want umask to get set. This sets it for non-login shell.
# Current threshold for system reserved uid/gids is 200
# You could check uidgid reservation validity in
# /usr/share/doc/setup-*/uidgid file
if [ $UID -gt 199 ] && [ "`/usr/bin/id -gn`" = "`/usr/bin/id -un`" ]; then
umask 002
else
umask 022
fi
2.17 隐藏权限lsattr chattr
lsattr - list file attributes on a Linux second extended file system
lsattr [ -RVadv ] [ files... ]
-R Recursively list attributes of directories and their contents.
-a List all files in directories, including files that start with `.'.
# lsattr -a
---------------- ./.
---------------- ./..
---------------- ./.bash_logout
-d List directories like other files, rather than listing their contents.
# lsattr /tmp/ -d
---------------- /tmp/
chattr - change file attributes on a Linux file system
chattr [ -RVf ] [ -v version ] [ mode ] files...
The format of a symbolic mode is +-=[aAcCdDeijsStTu].
-R Recursively change attributes of directories and their contents.
-V Be verbose with chattr's output and print the program version.
# chattr +i -V test/
chattr 1.42.9 (28-Dec-2013)
test/的标志被设为 ----i-----------
A file with the 'a' attribute set can only be open in append mode for writing.
When a file with the 'A' attribute set is accessed, its atime record is not modified.
A file with the 'c' attribute set is automatically compressed on the disk by the kernel.
A file with the 'd' attribute set is not candidate for backup when the dump is run.
When a directory with the 'D' attribute set is modified, the changes are written synchronously on the disk.
When a file with the 'S' attribute set is modified, the changes are written synchronously on the disk; this is equivalent to the 'sync' mount option applied to a subset of the files.
A file with the 'i' attribute cannot be modified: it cannot be deleted or renamed, no link can be created to this file and no data can be written to the file.
When a file with the 's' attribute set is deleted, its blocks are zeroed and written back to the disk.
When a file with the 'S' attribute set is modified, the changes are written synchronously on the disk; this is equivalent to the 'sync' mount option applied to a subset of the files.
When a directory with the 'D' attribute set is modified, the changes are written synchronously on the disk.
When a file with the 's' attribute set is deleted, its blocks are zeroed and written back to the disk.
When a file with the 'u' attribute set is deleted, its contents are saved.
# chattr +i -V test/
chattr 1.42.9 (28-Dec-2013)
test/的标志被设为 ----i-----------
[root@aminglinux-01 ~]# touch test/123
[root@aminglinux-01 ~]# touch test/456
[root@aminglinux-01 ~]# touch test/789
touch: 无法创建"test/789": 权限不够
阅读全文
0 0
- 8. chmod chown umask lsattr chattr
- chmod、chown、umask、隐藏权限lsattr/chattr
- chmod -chown-umask-隐藏权限lsattr/chattr
- 文件和目录权限chmod 、更改所有者和所属组chown 、 umask、 隐藏权限lsattr/chattr
- L8 文件和目录权限chmod,更改所有者和所属组chown,umask,隐藏权限lsattr/chattr
- 文件和目录权限chmod、更改所有者和所属组chown、umask与隐藏权限lsattr/chattr
- 10.25 文件和目录权限chmod,更改所有者和所属组chown,umask ,隐藏权限lsattr/chattr
- 二周第三次课 2017.10.25 文件和目录权限chmod、更改所有者和所属组chown、umask、隐藏权限lsattr/chattr
- 文件或目录权限chmod 、更改所有者和所属组chow、umask、隐藏权限lsattr/chattr
- Linux 常用命令——umask, chattr, lsattr
- 文件属性相关touch、umask、chattr、lsattr、file
- umask命令,隐藏权限chattr—lsattr
- ls+chmod+chown(chgrp)+umask
- 文件和目录权限chmod、更改所有者和所属组chown、umask、隐藏权限lsattr、chattr2.14-2.17
- chmod\chown\chgrp\umask\SUID \SGID 详解
- Linux之相关权限---chown chmod umask
- 学习笔记(五)——chown,chmod,chattr,lsattr,suid,sgid,stick_bit,Linux搜索文件/命令,软链接,硬链接
- 一天一linux命令(6) chown chgrp chmod umask 权限
- 文件和目录权限chmod 、更改所有者和所属组chown 、 umask、 隐藏权限lsattr/chattr
- Elasticsearch 5.x Head插件部署指南
- DNS协议详解
- centos nginx django+virtualenv部署
- idea Could not determine the class-path for interface org.jetbrains.kotlin.gradle.KotlinGradleModel.
- 8. chmod chown umask lsattr chattr
- 深入理解DNS报文格式
- 域名跳转
- IT 与风投
- KMP算法
- 【2】Java时间工具类
- SNMP协议详解
- Http协议相关知识
- JAVA基础(二)LinkedHashMap