File permissions and directory configuration for Linux (iii)

Source: Internet
Author: User

the meaning of directories and file permissions in Linux

I. The significance of file permissions

R: Can read the specific contents of this file;

W: You can edit the contents of this file, including adding the specific contents of the deleted file;

X: The file has executable permissions-------Note: This is not the same as window, in win, the executable permissions of the file are displayed through the extension, such as EXE, BAT, etc., but the executable permission of the files in Linux is determined by this x, and the file name is not related.

* When you have W permission on a file, you can edit the contents of the file, but you do not have permission to delete the file.

Ii. Significance of directory permissions

R: You can view the full file list information in this directory ( you can see the name when you have R permission but no x permission, but the other information will be Instead, when there is no r permission, the completion will not be displayed ).

W: You can make related changes to all files and directories in this directory, that is, you can change the list of structures under this directory (this should pay attention to) the following specific rights:

(1) You can create a new file or directory under this directory;

(2) You can delete the existing file or directory under this directory (regardless of the permissions of the file, this point to pay extra attention!!!!) )

(3) You can rename and change the location of the file or directory.

X: The directory does not have executable permissions, so the function of x in the directory is to allow other users to enter this directory

Three, example

[Email protected]:~$ sudo su
[sudo] password for Fanfan:
[Email protected]:/home/fanfan# cd/tmp
[Email protected]rio-cq41-notebook-pc:/tmp# mkdir Testing
[Email protected]:/tmp# chmod 744 Testing
[Email protected]:/tmp# Touch testing/testing
[Email protected]:/tmp# chmod testing/testing
[Email protected]:/tmp# Ls-ald Testing testing/testing
drwxr--r--2 root root 4096 January 19:09 testing
-RW-------1 root root 0 January 19:09 testing/testing
[Email protected]:/tmp# su Fanfan
[Email protected]:/tmp$ ls-l Testing
LS: Unable to access testing/testing: Insufficient permissions
Total dosage 0
-?????????             ? ? ? ? ? Testing
[Email protected]:/tmp$ CD Testing
Bash:cd:testing: Insufficient Authority
[Email protected]:/tmp$ sudo su
[Email protected]:/tmp# chown Fanfan Testing
[Email protected]:/tmp# su Fanfan
[Email protected]:/tmp$ cd/temp/testing
BASH:CD:/temp/testing: No file or directory
[Email protected]:/tmp$ CD Testing
[Email protected]:/tmp/testing$ ls-l
Total dosage 0
-RW-------1 root root 0 January 19:09 Testing
[Email protected]:/tmp/testing$ RM Testing
RM: Do you want to delete the plain empty file "testing" with write protection? Y
[Email protected]:/tmp/testing$

Four considerations

<1> Here's the problem is that sometimes we want to share a file with others (the same group, or other), you change the permissions of the file, the other side can not see, because others can not enter your user home directory, the default does not have X permissions. If at this point you open the X permission to allow him to see the file, someone else will go to this directory to view the file or modify the file. If this person thinks the file is very good, wants the CP one, then he does not have the authority, thought that the directory default also does not have the W permission, here we must pay special attention: the best not to open the W permission directly, because so others can change this directory the list under the discretion (including deletes, deletes is very dangerous). So we can put this CP file into a third-party directory with W permissions, and the other side also from here CP, so that our home directory will not be affected any more.

<2> Here is a funny example, a system administrator has built an important. txt file, in order to prevent others against this file, so the administrator set the permissions for-rex------, the administrator thinks foolproof, put this file casually put a directory, Thought that even if others see this file can not do anything, but if this directory has W permissions, then others can not do anything to this file, but he has the deletion of this file permissions, this is fatal.

Five file types and extensions

(1) File name

General file-Plain text file binary file data format file

Directory d (directory) directory

Connection file L (link) is similar to Windows shortcut

Block Device file B (block) stores data to provide system random access to the interface device

Interface device for character device file C (character) serial port

Socket s (sockets) socket

Piping pipe P (pipe)

(2) Extension

Whether a Linux file can be executed is related to the 10 properties of its first column, not to the file name at all, but we still want the extension to know what the file is.

. sh script or batch file

*z *.tar *.tar.gz *.zip *.tgz Compressed file

(3) Under Linux, when using the Ext2/ext3 file system by default, the file file name length is limited to:

Maximum allowable file name of a single file or directory is 255 characters

Full file name with full pathname and directory 4,096 characters

We want the file name of Linux to look at it and know what it is, and all the filenames are usually very long

File permissions and directory configuration for Linux (iii)

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.