08-linux Basics (vi)-file types, file extensions, and file permissions basics for files and directory properties and permissions

Source: Internet
Author: User
Tags file permissions

I. Types of files in Linux
In a Linux system, it can be said that everything (including directories, ordinary files, device files, etc.) are files. The file type contains common files, directories, character device files, device files, symbolic link files, pipe files, and so on, and all files and folders under the current directory can be displayed when the ls-l or Ls-al command is executed:

    [[email protected] ~]# ls -l    总用量 40    -rw-------. 1 root root  1140 2月   5 04:28 anaconda-ks.cfg    -rw-r--r--. 1 root root 21736 2月   5 04:28 install.log    -rw-r--r--. 1 root root  5890 2月   5 04:25 install.log.syslog

Where the first character of the first column is used to differentiate between file types, the common file types are shown in the following table:

d(directory)    表示这是一个目录,在ext2fs中,目录是一个特殊文件。-(regular file) 表示这是一个普通的文件。l(link) 表示这是一个符号链接文件,实际上它指向另一个文件。b(bock) 表示块设备和其他的外围设备,是特殊类型的文件。c(character)    表示字符设备文件。s(socket)   表示socket文件。p(name pipe)    表示管道文件。

Second, the file types are described separately
1. Common documents (regular file)
In Linux, files that begin with a-start represent ordinary files. These files are typically created with related application or system commands, such as touch, CP, TAR, Echo, cat, and so on. The RM command can be used to delete normal files.
General documents can also be divided into:
① Plain text file (ASCLL): The contents of the file can be read directly to the data, for example: Letters, numbers, special symbols and so on. You can read files with cat commands, such as configuration files, almost all of which are of this type.
② binary (binary): The command file in Linux belongs to this format. For example, a cat command is a binary file.
③ data Format file: Some programs read files in certain formats while they are running, and those files in a particular format can be called data files. For example, when a user logs on, Linux logs the logged-in data to the/VAR/LOG/WTMP (the database file of the last command), which is a data file at the time of the file. Read through the last command, the Cat command will read garbled, because he book order a special format file. Lastlog (/var/log/lastlog)
Add: You can view file types by using the files command
[Email protected] ~]# File/bin/cat
/bin/cat:elf 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked (uses shared libs), for Gnu/linux 2.6.18 , stripped
2. Catalog files (directory)
In Linux, a file that begins with a D character represents a directory. The command to create a directory can be used with the mkdir command or the CP command (with the-R or-a parameter), and CP can copy one directory to another directory. Delete directory with rm-r or rmdir (delete empty directory only) command.
3. Character device or block device file
If the first character is C, it represents a character device file, such as a serial device such as a cat; if the first character is B, a block device, such as a hard disk, an optical drive, and so on, belongs to a block device. We can view the block device with Find/dev-type b |xargs ls-l, and view the character device with Find/dev-type C |xargs ls-l.
4. Socket (socket) file
In Linux, a file with a. Socket suffix represents a socket file, which is typically used for network communication.
5. Symbolic Link File
The symbolic link file is also referred to as a soft-link file, which can be understood as a shortcut in Windows.
6. Pipeline Document (Fifo.pipe)
In Linux, the first character, p, represents a pipeline file. FIFO (fifo-first-in first-out) is a special file type, mainly to solve the errors caused by multiple programs accessing one file at the same time.

Third, the role of the common extension of Linux
In general, Linux is not distinguished by extension. But the extension also represents a certain meaning, for example:
①.tar (. tar.gz,. tgz,. zip,. tar.bz) represent compressed files, which are typically tar, gzip, unzip, and so on.
②.sh represents a shell script file, a program developed through the shell language.
③.pl represents a Perl language file that is developed through the Perl language program.
④.py represents a Python language file that is developed through the Python language program.
⑤.html (. htm),. php,. JSP,. Do represent Web language files.
⑥.conf represents the configuration file for the system.
⑦.RPM represents the RPM installation package file.

Iv. the basis of file permissions

In the Linux file permissions, there are 10 bits in total, the No. 0 bit represents the file type, and the latter 9 bits represent the file permissions.
1, about the interpretation of each part of the authority:
The first part (第1-3位): A sovereign limit (user permission bit) for the owner (own) to use.
Part II (第4-6位): A group of permission bits (groups permission bits) for use by the group (the person you are close to).
Part III (第7-9位): Other user privilege bits for other people to use.

2, the interpretation of the permission mask:

r(read) 读   4w(write)    写   2x (execute) 执行  1-   没有权限    0

3, about the permission mask calculation:
Add three parts of the permissions, if the full permission is 4+2+1=7, if only the read and write permission is 4+2+0=6, if only need to read and execute the permission is 4+0+1=5.
Has a permission of 755, the decomposition is calculated as shown in the following equation:
7 (=4+2+1) 5 (=4+0+1) 5 (=4+0+1)

Welcome attention
Sina Weibo: https://weibo.com/yougazhang0506
Public platform: Zhang Yujia

My site: http://www.zhangyujia.cn
51CTO Blog: http://blog.51cto.com/11099293
CSDN Blog: http://blog.csdn.net/u013260195
github:https://github.com/zhangyujia0506/

08-linux Basics (vi)-file types, file extensions, and file permissions basics for files and directory properties and permissions

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.