Details of Common commands on Linux servers and Common commands on linux
I. User
1. useradd is used to create an account.
Useradd newname // create newnamepasswd newname // set & change the password. After entering this command, you will be prompted to enter the password
2. delete a user
userdel newname
3. Switch users
su - youruser
4. ssh remote login
ssh -l root 192.168.0.11ssh root@192.168.0.11
Specified Port:
ssh -p 12333 192.168.0.11ssh -l root -p 12333 216.230.230.114ssh -p 12333 root@216.230.230.114
5. Update the ssh logon port of the server
After logging on to the server
#sudo vi /etc/ssh/sshd_config
Change port 22 to port number.
Restart the SSH service after modification./etc/init. d/ssh restart
Ii. Group
1. Create a group
groupadd testgroup
2. modify a group
groupmod -n test2group testgroup
3. delete a group
groupdel testgroup
4. View groups
Cd/homels-l # The third column indicates the owner of the file or directory, and the fourth column indicates the group of the file or directory.
5. modify a user group
-L: Rename the user, but the name of the user's home directory in the/home directory does not change. You need to manually modify the name.
-G: Modify the group in which the user is located
usermod -g siatstudent newname
To add a user to multiple groups at a time, use the-G parameter (uppercase G ):
usermod -G friends,happy,funny newname
Note: Be careful when using usermod, because when using the-g or-G parameter, it will remove the user from the original group and add the user to the new group. If you do not want to leave the original group and want to join a new group, you can add the-a parameter on the basis of the-G parameter. a is the abbreviation of the English append, indicating "append ". For example:
Usermod-aG happy newname // newname belongs to two groups: siatstudent and happy
Groups newname # view the group to which newname belongs