linux-Command Permissions

Source: Internet
Author: User

linux-Command Permissions

1) New user natasha,uid is 1000,gid to 555, note information is "master"

2) Modify Natasha user's home directory for/natasha

3) View the last line of the user information profile

4) Set the password "123" for the Natasha user

5) View the last line of the user's password profile

6) Lock the Natasha user account

Unlocking the Natasha user account

7) New group Police,gid to 999

To view the last line of a group configuration file

8) Add Natasha user to police group

9) Modify the group name of the police group to Jingcha

10) Delete Natasha user, even home directory and mailbox deleted together

USERDEL–R Natasha

11) Delete Jingcha Group

1) Create a directory test in the user's home directory, enter test to create an empty file File1

[Email protected] ~]# mkdir test

[Email protected] Bogon ~]# CD test/

[Email protected] Bogon test]# touch file1

2) display file information in long format, note the permissions of the file and the user and group to which it belongs

[Email protected] Bogon test]# ls-l

Total 0

-rw-r--r--1 root root 0 Mar 16:24 file1

3) Set permissions for file File1 so that other users can write to this file.

[Email protected] Bogon test]# chmod 666 file1

4) View the setting results ,

[Email protected] Bogon test]# ls-l

-rw-rw-rw-1 root root 0 Mar 16:24 file1

5) Remove the Read permission from the same group of users to the file File1 and view the setting results.

[Email protected] Bogon test]# chmod g-w file1

[Email protected] Bogon test]# ls-l

-rw-r--rw-1 root root 0 Mar 16:24 file1

6) Use digital notation to set permissions for file files, all readable, writable, and executable, and the owning group user and other users have only read and execute permissions. Review the setup results when the settings are complete.

[Email protected] Bogon test]# chmod 755 file1

[Email protected] Bogon test]# ls-l

-rwxr-xr-x 1 root root 0 Mar 16:24 file1

7) Change the permissions of the file File1 in digital form so that the owner can only read the file. No other user has permission. View the settings results.

[Email protected] Bogon test]# chmod file1

[Email protected] Bogon test]# ls-l

-R--------1 root root 0 Mar 16:24 file1

8) go back to the upper directory to see the test permissions

[Email protected] Bogon test]# CD.

[Email protected] Bogon ~]# ls-ld test

Drwxr-xr-x 2 root root 4096 Mar 16:24 test

9) Add write permissions to this directory for other users

[Email protected] Bogon ~]# chmod-r g+w test

[Email protected] Bogon ~]# ls-ld test

Drwxrwxr-x 2 root root 4096 Mar 16:24 test

1) Create a new user by manipulating the file Alex

Tail-1/etc/passwd

Alex:x:1010:1010::/home/alex:/bin/bash

Tail-1/etc/shadow

alex:!! : 17240:0:99999:7:::

Tail-1/etc/group

ALEX:X:1010:

Tail-1/etc/gshadow

alex:!::

Mkdir/home/alex

Cp-r/etc/skel/. [!.] */home/alex/

Chown-r alex.alex/home/alex/

Touch/var/spool/mail/alex

Chown-r Alex.mail/var/spool/mail/alex

1) Create a new directory/test/dir, the owner is Tom, the array for the Group1,/test directory has permission of 777

Mkdir-p/test/dir

Useradd Tom

Groupadd group1

Chown Tom.group1/test/dir

chmod 777/test/

2) New user jack, switch to the jack user, verify the jack user rwx permissions to the dir directory (open another terminal, and then modify the Dir directory's others permissions)

Useradd Jack.

[[email protected] test] #chmod O=rw/test/dir

[Email protected] test]# Ls–ld/test/dir

drwxr-xrw-. 2 Tom Group1 6 March 18:06/test/dir

Su-jack

3) Add Jack to the group1 group to verify the Jack User's rwx permissions to the dir directory (open another terminal, then modify the group permissions of the Dir directory

4) switch to Tom User, verify the RWX permission of Tom user to dir directory (open another terminal, modify the user permission of Dir directory in turn)

5) Create a new file in Dir directory Tom.txt, the owner is Tom, the group is the Group1,/test directory permissions of 777

[Email protected] dir]# chown tom.group1 tom.txt

[Email protected] dir]# chmod 777 Tom.txt

[Email protected] dir]# ls-l tom.txt

-RWXRWXRWX 1 Tom group1-17:27 Tom.txt

6) New user rose, switch to Rose User, verify the Rose User's rwx permissions to Tom.txt (open another terminal, modify tom.txt others permissions to match the verification process)

(1) RWX permissions

[Email protected] dir]$ ls-l tom.txt

-RWXRWXRWX 1 Tom group1-17:27 Tom.txt

[email protected] dir]$ cat Tom.txt

echo "Tom"

[Email protected] dir]$ vim Tom.txt

(2) RW permissions

[Email protected] dir]# chmod 776 tom.txt

[Email protected] dir]# ls-l tom.txt

-rwxrwxrw-1 Tom Group1-17:31 Tom.txt

7) Add rose to the group1 group and, under the Rose user, verify the rwx permissions of the rose user to Tom.txt (open another terminal and modify Tom.txt group1 permissions to match the verification process)

8) switch to Tom User, verify Tom User's rwx permission to Tom.txt (open another terminal, modify Tom.txt user permission to cooperate with the verification process)

linux-Command Permissions

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.