In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
The purpose of this article is to share with you what file attributes such as crw brw lrw in linux refer to. The editor thinks it is very practical, so share it with you as a reference and follow the editor to have a look.
What is a file?
All files are actually a string of character streams, but when you use the appropriate parsing method, you can get effective information. In order to facilitate the operation of the file, people give different types of files according to the different parsing methods of the file. and mark it to people in the following way.
Today, when I was looking at the properties of the / dev/fuse file, I saw the crw_ permission bit, and I couldn't react to it for a while:
[root@localhost ~] # ll / dev/fusecrw-rw-rw-. 1 root root 10, 229 Sep 20 11:12 / dev/fuse
Make a note here, the relevant answer comes from the network.
In linux, c stands for character device files, b for block device files, l for symbolic link files, r for readable permissions, and w for writable permissions.
Interpretation of linux file attributes:
File type:
-: ordinary document (f)
D: catalog file
B: block device file (block)
C: character device file (character)
L: symbolic link file (symbolic link file)
P: command pipe file (pipe)
S: socket file (socket)
File permissions: 9 bits, each 3-bit group, each group: rwx (read, write, execute), when the group does not have a certain permission to use-instead.
The first group is the permissions of the owner of the file, which can be read and written, but not executable.
The second group is: permissions of the same group
The third group is: permissions of other non-local groups
Let's take a look at the file types in linux
(1) ordinary documents ('-', regluar file)
Divided into: binary files and text files
Binary files, which are for machines, such as .bin, .elf files
Text file: for people to see, generally ASCII encoding, need to use ASCII coding parsing, such as: .txt, .c file.
(2) folder files ('d', directory file)
A special file, especially in that it needs to be opened with its library function.
(3) linked file ('l', link file)
Here is the soft connection file.
Note: the difference between soft link files and hard link files
The soft link file itself is a separate file with its own inode
Hard-linked files, not independent files, share the same inode as the linked file.
(4) Pipeline file ('p', piple file)
Used for process communication.
(5) socket file ('s', socket file)
For the network.
(6) character device file ('c', character file)
Is a virtual file because it does not exist on the hard disk and is created by fs.
You can't read or write directly, use API.
(7) Block device file ('b', block file)
Also a virtual file, created for fd, using API to read and write.
3. How do I get the properties of a file?
(1) use stat command in shell
(2) use stat API in the program
4. Permissions for the file
(1) how to obtain file permissions?
Using stat API in the program, you can get the st_mode element. St_mode is a record of content in bits, so you only need to carry out the corresponding bits & linux provides the corresponding macros, you can use macros.
(2) how to judge whether the program has permission to the file?
First of all, the permission of the program to the file is determined by the user who executes the program, the user has the authority, the program has, the user does not have, the program does not, secondly, judge whether there is permission to use access API in the program, finally, the excellent program should first judge the authority to the operation of the file at the beginning of the execution, if there is no authority, it needs to remind the user.
(3) how to modify permissions?
There is a chmod command in shell, as well as chmod API, so you can use this API.
(4) how is the permission of the newly created file determined?
Linux has a umask-like variable, and the permissions of the new file are determined by umask. Umask can be changed in shell.
What is Linux system Linux is a free-to-use and free-spread UNIX-like operating system, is a POSIX-based multi-user, multi-task, multi-threaded and multi-CPU operating system, using Linux can run major Unix tools, applications and network protocols.
Thank you for reading! On the "linux crw brw lrw and other file attributes refer to what is" this article is shared here, I hope the above content can be of some help to you, so that you can learn more knowledge, if you think the article is good, you can share it out for more people to see it!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.