Linux Shell Basics

Source: Internet
Author: User
Tags readable

I. File systems and Security

chmod command

The chmod command has two modes, one is the symbol mode, executes the user with the Ugo, executes the permission with the RWX, the other is the absolute mode, uses the different value of the octal different position to represent different user's different permission.

    • Symbol mode

The format of the chmod command is chmod [who] operator [permission] filename

Where [who] values can be considered

1 u: File owner's permission 2 g: Permissions for the group that the user resides in 3 o: Other user rights 4 A: All user rights 5 if the [who] parameter is omitted, the permissions are set for both u and G, i.e. set permissions for both the owner and the group

Operator value is

1 +: Increase permissions 2 -: Cancel Permissions 3 =: Set permissions

Permission

1 r: Read 2 W: Write 3 x: Execute 4 and s,t,l,u,g,o are not used.

command example,

1 chmod // Add execute permissions for the group that the owner and the host use 2 chmod A-w// recover Write permission for all users (of course, the owner will have the W permission)

Absolute mode

In absolute mode, the format of the chmod command is chmod [mode] File

[mode] is an octal number, and the octal number corresponds to the user's relationship as follows,

1 0 4 0 0document is Master readable2 0 2 0 0The document belongs to the master writable3 0 1 0 0File owner executable4 5 0 0 4 0Group User readable6 0 0 2 0group users can write7 0 0 1 0Group user can execute8 9 0 0 0 4other users can readTen 0 0 0 2other users can write One 0 0 0 1Other users can perform

The addition of weights owned by the same type of user is the ultimate permission for such users,

For example

If the owner can read and write and can execute, then the weight value is 4+2+1=7

Group readable non-writable executable, the weight value is 4+0+1=5

Other user readable non-writable non-executable, the weight value is 4+0+0=4

The final command to set permissions is chmod 754 filename.

The expression in the following way is more intuitive,

1 w x:4212w x:4213 w x:421

Hard connections and soft connections

File node

At the bottom of Linux, a file is not uniquely identified by its file name, but is identified by its node (inode).

Hard Connect

Hard link is to create several different file names, but the same file node files (that is, the same address space at the bottom), with the command ln F1 f2

Soft connection

Also called Symbolic links (symbolic link) is to create a meta-file of a text file, save the original file location information, access to the soft connection file is also equivalent to access to the original file, similar to Windows shortcuts.

The difference between a soft connection and a hard connection is that you delete a file, and if you delete a file, it does not affect its hard-connect file (which is equivalent to a hard-connect file replacing the original file), but its soft-connect file is no longer a valid file.

The following example shows that

Create a new file by yourself echo agfgfgfdg3fsfsdf > F1

New Hard Connect LN F1 f2

New Soft connection Ln-s F1 F3

If you modify F3 echo 23423423 >> f3

You'll find that F1 and F2 have been modified.

1 Cat f3 2 AGFGFGFDG3FSFSDF 3 23423423
1 Cat F2 2 Cat f3 3 AGFGFGFDG3FSFSDF 4 23423423
1 Cat F1 2 AGFGFGFDG3FSFSDF 3 23423423

If you delete F1, you will find that its hard connection F2 is already accessible, but the soft connection F3 is invalid.

1 Cat f3 2 Cat file or directory

Linux Shell Basics

Related Article

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.