2.1 KiB
User Management Basic Commands
There are several commands that are crucial when managing users in Linux. Here are some of the most important ones:
-
useradd
: This command is used to create a new user. For example:useradd username
-
usermod
: This command modifies the properties of an existing user. For example, to add a user to a group:usermod -aG groupname username
-
userdel
: This command deletes a user. For example:userdel username
. Be careful with this command, it should be used with caution. -
passwd
: This command is used to change the user's password. For example, to change the password for a user:passwd username
-
su
: This command is used to switch the current user to another user. For example, to switch to a user named "username", you would type:su username
-
sudo
: This command is used to run commands with administrative privileges. For example:sudo command
. It's equivalent to saying "run this command as the superuser". -
chown
: This command is used to change the owner of a file or directory. For example:chown username filename
-
chgrp
: This command is used to change the group of a file or directory. For example:chgrp groupname filename
-
groups
: This command is used to display the groups a user is a part of. For example:groups username
-
id
: This command is used to display the user ID and group ID of a user. For example:id username
-
whoami
: This command is used to display the current logged in user. Just type:whoami
-
adduser
: This command is used to add a user (more user friendly thanuseradd
). For example:adduser username
-
addgroup
: This command is used to add a group. For example:addgroup groupname
-
deluser
: This command is used to remove a user. For example:deluser username
-
delgroup
: This command is used to remove a group. For example:delgroup groupname
Remember, the manual (man
) pages are your best friend when learning about commands in Linux. You can access the man page for any command by typing man
followed by the command name. For example, man useradd
will show you the man page for the useradd
command.