This article summarizes some common commands for adding users and managing permissions in linux system O & M, hoping to help you.
1. Add a user to adduser. The root permission is required for execution.
1. Role
The useradd command is used to create a user account and create a user's starting directory. The permission is a Super User.
2. Format
Useradd [-d home] [-s shell] [-c comment] [-m [-k template] [-f inactive] [-e expire] [-p passwd] [-r] name
General Usage: sudo adduser testuser adds a user named testuser.
2. passwd is used to change the password.
3. chfn is used to modify user data.
4. chsh is used to change the user's shell
5. chmod is used to change the user's permissions.
The general usage is as follows:
Chmod 777 test.txt
777 indicates the permission value. The first 7 is the permission value of the "owner", the second 7 is the permission value of the person in the same group, and the third 7 is the permission value of others.
What does 7 mean?
If the read permission is granted, the value is 4. If the write permission is granted, the value is 2. If the execution permission is granted, the value is 1. 7 = 1 + 2 + 4
Test.txt is the file to be set.
There is also a way to back up English text. The "owner" is called u, the "person in the same user group" is called g, and the others are called o. (It is the first letter of user, group, and other .)
Chmod u-x mydoc
Minus the execution permission of the owner on the mydoc file.
Chmod g + rw mydoc
Add read and write permissions for mydoc files to users of the same user group.
Chmod g-rwx, o-rwx mydoc
Except the owner, neither the user group nor anyone else can read, write, or execute the mydoc file.
Chmod a + rwx mydoc
A is all ). From then on, all users can read, write, and execute mydoc files.
6. chown changes the owner.
General Usage: chown testuser test.txt transfers the test.txt permission to testuser.
7. chgrp is similar to chown, but this method is used to change the user group.
8. The sudo command is temporarily promoted to the root permission for operations.
9. uname displays the current version information.
Common parameters are as follows:
Uname-m Displays the hardware model.
Uname-n indicates the name of the network node.
Uname-r: The number of release versions in the operating system (smaller than version ).
Uname-s displays the operating system name.
Uname-v displays the version number of the operating system.
Uname-a is displayed.
10. who displays who is currently using it.
11. whoami shows who you are.
Attached instances
For example, add a cdy user
The Code is as follows: |
Copy code |
Linux @ cdyemail :~ $ Adduser cdy Adduser: Only root may add a user or group to the system. Linux @ cdyemail :~ $ Sudo adduser cdy # Use root user permissions to add Adding user 'cdy '... Adding new group 'cdy' (1001 )... Adding new user 'cdy' (1001) with group 'cdy '... Creating home directory '/home/cdy '... Copying files from '/etc/skel '... Enter new UNIX password: # Enter the User password Retype new UNIX password: Passwd: password updated successfully Changing the user information for cdy Enter the new value, or press ENTER for the default # Enter the user information Full Name []: Room Number []: Work Phone []: Home Phone []: Other []: Is the information correct? [Y/n] y Linux @ cdyemail :~ $ Cat/etc/passwd | grep cdy # check whether a user is created Cdy: x: 1001: 1001:,:/home/cdy:/bin/bash Linux @ cdyemail :~ $ Cat/etc/group | grep cdy # check whether a group is created by default. Cdy: x: 1001: |
Switch to the console: log on
The Code is as follows: |
Copy code |
Cdyemail login: cdy Password: |
View logged-on users
The Code is as follows: |
Copy code |
Nux @ cdyemail :~ $ Who Cdy tty2 # successful login Test Linux tty1 Linux tty7 (: 0) Linux pts/0 (: 0.0) Linux pts/1 (: 0.0) |
I use ubuntu. the test time is different from that in the book. The book introduces adduser. useradd is a file, that is, adduser is just a link.
The Code is as follows: |
Copy code |
Linux @ cdyemail:/bin $ which adduser useradd /Usr/sbin/adduser /Usr/sbin/useradd Linux @ cdyemail:/bin $ ls-l/usr/sbin/adduser/usr/sbin/useradd -Rwxr-xr-x 1 root 35106 2010-01-27 18:26/usr/sbin/adduser -Rwxr-xr-x 1 root 76876 2010-09-03 18:28/usr/sbin/useradd |
The connection is not shown here, so you can check the help adduser -- help.