Linux file permissions and directory configuration

Source: Internet
Author: User

First, file permissions:

Each file and directory in the Linux system has access permission, which is a data structure added to the file

Access rights stipulate three different types of users:

The owner of the file: the name of the file, known as the master.

Same set of users (group): the same group of users who belong to the file group

Other users who can access the system (others)

Access rights specify three ways to access files or directories:

Read (R): Allow reading of file contents or column directories

Write (W): Allows to modify file contents or create and delete files

Executable or find (x): Allows files to be executed or allowed to enter the directory using the CD command.

Ii. Special Privileges

Iii. types of files for Linux

A file is the basic structure used by the operating system to store information, identified by a file name.

There are three basic file types in the Linux system

L Ordinary files: including text files, data files, executable binaries, and so on.

L Directory files: The Linux system regards the directory as a special kind of file, which makes up the tree structure of the file system.

Device files: The Linux system sees every device as a file

Iv. Managing File Permissions

Text Setting method

The text format of the chmod command is:

Format 1:chmod[-r]{[ugoa][+-=][rwxst]} < file name or directory name >

Format 2:chmod[-r]{[ugoa][+-=][ugo]} < file name or directory name >

Description

-R: If the operand is a directory, the contents of the permission set {} are recursively applied to all subdirectories in that directory, and the content within {} is called a pattern, multiple modes can be specified, and the first option between multiple modes with a comma interval indicates the user to be given permission

U denotes owner (user)

G indicates the owning group user

o indicates other users (other)

A means all users (all)

The second option represents the action to be made

+ indicates increased permissions

-Indicates delete permission

= Assign permissions and delete old permissions

The third option is the permissions to assign

R = Allow Read

W indicates that write is allowed

X means allow execution

Chmodo+u Testfile1: Add owner-owned permissions to other people

V. The owner and genus of the document

1. Chown command

Changing the owner and group of the file can be used with the Chown command,

Command format is: Chown[-r] < user [: Group]> < file or directory >

Description

-R: If the operand is a directory, the settings are recursively implemented for all subdirectories in that directory

To change groups individually, you can use the following format:

Chown[-r] <: group > < file or directory > (note: Must have ":" Before the group)

Switch to Super User su–

Change the owner of the file Testfile3 to Jason:chown Jason/home/osmond/testfile3

Change the group of file Testfile3 to Users:chown:users/home/osmond/testfile3

Change the owner and group of the file Testfile3 to Osmond:chown Osmond:osmond/home/osmond/testfile3

Change the owner and group of all files or directories under the TestDir directory and its subdirectories to Apache

Chown-r Apache:apache/home/osmond/testdir

2. Umask command

The user can use the umask command to set the default generation mask for a file. The default build mask tells the system what permissions should not be given to a file or directory when it is created. If the user places the Umask command in an environment file (. bash_profile), you can control access to all newly created files or directories.

The format of the Umask command is: UMASK[U1U2U3]

Where: U1 represents a permission that is not allowed to be owned by the owner, U2 represents a permission that does not allow the same group of people, and U3 represents a permission that is not allowed by others.

The current file default build mask can be viewed using the umask command without any parameters or with the-s parameter:

$ umask Results: 0022

$ umask-s Results: U=rwx,g=rx,o=rx

Linux file permissions and directory configuration

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.