1 Linux notes-basic file attributes

1 Linux notes-basic file attributes

1.1 File attributes

In Linux, everything is a file. The first character in Linux means that the file is a directory, file, or link file, etc.
For example: -rwxrwxrwx

When it is [d ], it is a directory.
When it is [-], it is a normal file;
if it is [l ], it is a link file;
if it is [b ], it is a storage interface device in the device file ( Random access device);
if it is [p], it means the pipe file;
if it is [c], it means the serial port device in the device file, such as keyboard and mouse (one-time reading device).

1.2 Linux file owner and group

Insert picture description here

1.2.1 Change file attributes

1. chgrp: change the file belonging group
Syntax:

chgrp [-R] 属组名文件名
参数选项
-R:递归更改文件属组,就是在更改某个目录文件的属组时,如果加上-R的参数,那么该目录下的所有文件的属组都会更改。

2. chown: change the owner of the file, and also change the group of the file at the same time.
Syntax:

chown [–R] 属主名 文件名
chown [-R] 属主名:属组名 文件名

3. chmod: change 9 attributes of a
file. There are two ways to set Linux file attributes, one is numbers and the other is symbols. There are nine basic permissions for Linux files, which are owner/group/others and each has its own read/write/execute permissions.

chmod [-R] xyz 文件或目录
选项与参数:
xyz : 就是刚刚提到的数字类型的权限属性,为 rwx 属性数值的相加。
-R : 进行递归(recursive)的持续变更,亦即连同此目录下的所有文件都会变更
-c : 若该文件权限确实已经更改,才显示其更改动作
-f : 若该文件权限无法被更改也不要显示错误讯息
-v : 显示权限变更的详细资料
--help : 显示辅助说明
--version : 显示版``

Insert picture description here

Guess you like

Origin blog.csdn.net/planetoid_a/article/details/109014939