Linux Summary (12) set_uid set_gid stic_bit Soft link Hard link

Source: Internet
Author: User
Tags file permissions

A set_uid

Before we modify the user's login password, are operating as an administrator, such as we in the LV account, we use
sudo passwd LV reset LV account password, at this time we directly get root permission to ignore the restrictions on file permissions. Then there is another situation, similar to our own changes in our bank account password, we are not an administrator, we only need to know the old password can be modified, to see the Linux ordinary users according to file permissions to modify the password mechanism:
Ls-l/usr/bin/passwd
Ls-l/etc/shadow

We found/usr/bin/passwd that the command file is red, which is the master permission for rws,s what role?
We use passwd to change the password process is like this, execute the/USR/BIN/PASSWD command, modify the/etc/shadow password file
We found that although/usr/bin/passwd for other users have X permissions, but/ectc/shadow is 0 permissions, then the average user how to modify their current password? (The execution of passwd without any parameters, with the account name is the case mentioned above)
In order to solve the above contradictions, Set_uid debut, when a command file with Set_uid permission, displayed as S, will temporarily borrow the file owner's identity, usually means that the ordinary user borrowing to root to complete the operation.
Here are two examples:
1 passwd Change Password

Remove the S permission and try again

2 LS give s permission before and after

Two Set_gid

1. When this permission acts on the command file, its function is equivalent to Set_uid, but the object is a group, the detailed explanation is that a command file is temporarily assigned to the identity of the file belongs to the group.

2. When the permission is applied to a directory, a file or directory created under that directory inherits the genus Group of that directory. Take a look at the following example:

Three stic_bit anti-delete bits

The normal user can share the editing rights of the file, but cannot delete the other user's files arbitrarily, therefore establishes the Stic_bit permission to constrain. Take a look at the following example:

We found that for other users there is a T permission, the T permission is stic_bit, we use two ordinary users to verify his role:

As shown, we first deleted the LV account under the Lv-one account in the test directory under the 1.txt file, then we give the test directory to add t permissions, and then use Lv-one Delete the test directory under the subdirectory test1, the hint is not allowed, said with the T permission to play a role.

Four Soft links

Format ln-s source File link file
The most intuitive understanding of a soft connection is the shortcut under WinDOS, which realizes that the file execution portal is no longer confined to the location of the file itself, but can be transferred to other locations. For example, by using a shortcut, we can open the film on the F disk under any disk.
Below we discuss the relative path and the absolute path:
Soft link relative path can be, but when we move the link file, the relative path of the soft link is easy to find the source and invalid, the absolute path will not have this problem. Let's take a look at the following example:



Soft Link One application case
If the log file of an application under the/boot partition Test.log gradually to fill the entire boot partition, but the root partition space is still surplus, then we can use the software link to remove this data source under the/boot partition, because the path is not changed, So just let him do a mapping. The specific measures are as follows:
1 Get the original data out first, Cp/boot/test.log/
2 Delete the original data, Rm-rf/boot/test.log
3 Soft Links re-build the data pool Ln-s/test.log/boot/test.log

Five Hard links

Format ln source file link file
Hard-link-generated files if viewing with Du view finds the same size as the source file, but uses the same Inod node, so it is not copied, we can understand that, two kinds of naming of the same object, hard links can not cross partitions, cannot work in the directory.

Linux Summary (12) set_uid set_gid stic_bit Soft link Hard link

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.