Liunx basic commands (permission usage)

Source: Internet
Author: User

Hello everyone, this time I will introduce you to the use of permissions. I will explain that it will be interesting to learn how to stick to basic commands, permissions, users, and what follows liunx, it will be boring and difficult. I hope you can enjoy the joy linux brings to everyone.

By the way, I have been trained in uplooking, so don't be surprised to hear a lot about uplooking ..


Permission management:

Ll install. log

-Rw-r -- 1 eric uplooking 39410 11-03 13:44 install. log


Rw-| r --

Usergroupother

Eric uplooking others

U g o



Optional

Root0) -----> uid = eric --------> group (uplooking) -------> other


File:

R -- --- cat, head, tail, more

W -- --- vim >>>

X -- ---./execute relative path)


Directory;


R -- --- ls r-x to View Details

W -- --- touch rm-wx to create a file


X -- --- cd



Can an object be deleted? Check the permission of the upper-level directory.



Modify permissions:


Rw-| r --

Usergroupother

Eric uplooking others

U g o


Chmod u + r file/dir

Chmod u + r, g-w file/dir if you do not have the permission-w does not take effect command)

Chmod u + r, g-r, o + rw file/dir

Chmod ug + rw, o-rw file/dir

Chmod ugo + rwx file/dir

Chmod a + rwx file/dir


Chmod u = r file/dir

Chmod u = rw, g = rx file/dir

Chmod u = r, g = rx, o = rwx file/dir

Chmod ug = rw, o = tx file/dir

Chmod ugo = rwx file/dir

Chmod a = rwx file/dir


R ------ 4 w ------ 2 x ------ 1

Rwxrwxrwx-777


561 r-xrw --- x-wx-w --- x 321

234-w -- wxr --


Keep in mind that the permissions of these files may change. Check that the/directory is ls-ld.

/Drwxrwxrwt755)

/Etc drwxr-xr-x 755)

/Bin drwxr-xr-x 755)

/Sbin drwxr-xr-x 755)

/Var drwxr-xr-x 755)

/Tmp drwxrwxrwt 1777)

/Etc/shadow-r -------- 400)

/Etc/passwd-rw-r -- (644)

Root administrator default file creation permission-rw-r -- (644)

Root administrator creates the default directory permission drwxr-xr-x (755)

Default permission for creating files for normal users-rw-r -- (664)

Default permission for creating directories for normal users: drwxrwxr-x (775)

/Root drwxr-x --- (750)

/Home/normal user's home directory drwxr-xr-x (700)


Manually add the user's home directory permission and modify it correctly (this is the permission to change the home directory? In the past, 755 won't work, but can be changed to 777)



Add User


Useradd-G kf, yw wg overwrites the original additional group

Usermod-a-G boss abc1 add additional group

Usermod-G yw, kf abc1

Useradd-u 0-o admin repeatedly Add a user-o whose u is equal to 0.


Drwxr-xr-x 2 root 4096 11-04 12:24 B


Uid = 0 (root) gid = 0 (root) groups = 0 (root), 1 (bin), 2 (daemon), 3 (sys), 4 (adm ), 6 (disk), 10 (wheel)


Owner master group additional group



Main Group: This group is only useful when creating a file directory. It is also used for matching.

Additional group: Permission acquisition




Exercise:

1. Create the directory test under the tmp directory and create the file aa.txt under the testdirectory to create the user zorro.

Requirements:

Zorrousers can delete aa.txt but cannot read or write

Mkdir/tmp/test/root rwxr-xr-x

Touch/tmp/test/aa.txt root rw-r --

Chmod o-r/tmp/test/aa.txt

Chmod o + w/tmp/test


2. Create the directory test under the tmp directory and create the file aa.txt under the testdirectory to create the user zorro eric

Requirements:

Zorrousers can read, write, and delete aa.txt files.

Ericusers cannot read, write, and delete aa.txt.

/Tmp/test/root rwxr-xr-x

/Tmp/test/aa.txt zorro root rw-r -----

Zorro

Eric


Chown zorro/tmp/test/aa.txt

Chmod o-r/tmp/test/aa.txt

Chown eric/tmp/test/




3. Create the abc.txt file under/root/and create three users zorro, shrek, and seker as follows:

Sekercan read and write abc.txt files but cannot be deleted

Zorroonly reading abc.txt files cannot be deleted

Shrek cannot read and write the abc.txt file, but it can be deleted.


/Root rwxrwxr-x

/Root/abc.txt seker zorro rw-r -----


Seker

Zorro

Shrek ----> root


Chmod 640 abc.txt

Chown seker. zorro abc.txt

Chmod 775/root/

Usermod-a-G root shrek

Shrek, hello, root






Copy a file with identical attributes as the original file

[Root @ 0425 ~] # Cp-a/root/abc.txt


This article is from the "history_xcy" blog, please be sure to keep this http://historys.blog.51cto.com/7903899/1296616

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.