Linux entry-level operation (basic command two)

The linux system has been installed on our computer, and the basic operations (switching on and off, viewing basic files, paths, etc.) have been performed. Next, we will enter the operation of user management. Similar to the boot interface of our Windows computer, you need to enter a password, and the same is true for linux.

The root user is a super user administrator and can do anything he wants (just like when we delete and run a software on Windows, we need to use the administrator to run operations). Each user has multiple attributes (id, group is the main)


Create a user: (unless you specify to create a user to the specified directory, the home directory of all users is /home/username by default, the directory is created with the username)

cat/etc/passwd (you can query the users owned by linux)

useradd username (so we create a user named 'username')

passwd username (specify a password for the current username user) root can modify the password of any user and does not need the original password

delete users:

    userdel username (only for root users)

We can use useradd --help to view other redundant options and we will not make redundant statements (such as specifying user id, group)




User group basic information:

    We know that some university professors have classes in many schools, but they have only one full-time unit, but they can work part-time in other schools.

    The same is true for users under linux. Each user can belong to multiple groups, but his main group can only have one.

Create group:

 cat /etc/group can view all user groups under linux

 groupadd xxx create user

 groupadd -g

Delete group:

    groupdel group_name

Combine operation:

e.g. create a user and specify its group

useradd -g group1 -G group2  -u 200 test

Create a user named test, his primary group is group1, the subsidiary group is group2, and the id of user test is 200


User and group modification related operations:

usermod -u 202 test ( modify user wu 's uid to 202)

usermod -g nice wu ( modify the new primary group of user without wu to nice)

  usermod -G nice wu (adds a new affiliate group for user wu )

usermod -l wu nice (modify user wu 's new name nice )

usermod -d /root/nice wu ( modify user wu 's home directory to nice)



Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324735165&siteId=291194637