What's new

Welcome to Ruzgar.com

Join us now to get access to all our features. Once registered and logged in, you will be able to create topics, post replies to existing threads, give reputation to your fellow members, get your own private messenger, and so, so much more. It's also quick and totally free, so what are you waiting for?

Ask question

Ask questions and get answers from our community


Answer questions and become an expert on your topic

Contact us

Contact the site administrator directly.


Just like Facebook join them and enjoy.

Centos Lesson 7 User and Group Management


Staff member
Oct 3, 2021
Reaction score
There are usually too many users on Linux.

In Windows, there is usually 1 Administrator and 1 or more users.

Linux's Administator is the root user.

UID : User ID --> User ID
GID: Group ID--> Group ID

In Linux, we make users with the command useradd and groupadd .

useradd [parameters] username
hroupadd [parameters] groupname

  • -c, --comment: Provides information about the user.
  • -d, -home-dir: Specifies the user's home directory.
  • -e, --expiredate: Specifies the date the user account will be deactivated. It should be written in Year-Month-Day format.
  • -g, --gid: Specifies the user's 1st group name.
  • -G, --groups: Specifies other groups that the user will join.
  • -m creates the home directory of the user you created with the --create-home: -d parameter. Without this command, no user-specific directory will be created.
  • -s, --shell: Specifies the user's shell directory. By default it is /bin/bash.
  • -u, --uid: Specifies the user's id. A value greater than 500 is recommended.

Besides, usermod command is also available.

  • -l, --login: Change the user's login name.
  • -L, --lock: Locks the user account.
  • -m, --move: Moves the user's home directory to another directory.
  • -U, --unlock: Unlocks the user.

Now let's examine the groupadd command:

-fg, GID: Specifies the id of the group.
-r: This parameter is used if the system account is to be added. It must be less than 500.

When you log in to the terminal, you will be logged in as root with the command
su -
. You can add users as root.

useradd -c "admin" -d /home/ruzgar -m -s /bin/bash -u 630 ruzgar
after entering the command
We give the password to the new ruzgar user by saying
passwd ruzgar

If we enter the
id ruzgar
code, we can see the uid, gid, syslog and groups information of the newly created ruzgar user.

With all this code we are actually modifying the files.

User Information: /etc/passwd
Group Information: /etc/group
Password Information: /etc/shadow

It is kept in files.

To view the list of all created users:
You can use the code
cat /etc/passwd
. You will be surprised to see many users.

If we want to see only 1 user's information
cat /etc/passwd | We write the username at the end with the grep ruzgar
Similarly, you can see the list of user groups defined on your system with the code
cat /etc/group
Similarly, the list of users registered on your system with the code
cat /etc/shadow
is displayed with their encrypted passwords.

Username in 1 row. Then the encryption technique is used in the 2nd area. 1 means MD5, 2 means Blowfish, 5 means SHA256 and 6 means SHA512. 3. The next part is the encrypted password value. This value is not the actual value. It is encrypted.

With this command finally !! If you see users with name, it means that the user is without password.

Usermod and Groupmod Commands:


usermod [parameters] username
groupmod [parameters] groupname

It is used in the form.

usermod Parameters:
  • -c, --comment:/etc/passwd : Changes the comment line in the file.
  • 3-, --expire-date: Specifies when the user will expire. It should be entered as Y-A-G.
  • -p, --passwd: Converts the user's password into clear text, a very dangerous command.
  • -s, --shell: Changes the user's shell directory.
  • -L: Locks the user's password.
  • -U: Unlocks the password.
groupmod Parameters:

  • -g, --gid: Changes the GID of the group. (group id)
  • -n, --new-name: Changes the name of the specified group
  • -p, --password: Makes the encrypted password readable.
The userdel and groupdel commands are used to delete users and groups.

userdel [parameters] username
groupdel [parameters] is used as groupname

userdel command parameters:
  • -r, --remove : It will delete the user's home directory.
  • -Z, --selinux-user : Removes SELinux users from the system.
These codes will not delete the user completely in some cases. If you want to delete the user completely:

  • Code:
    passwd -l ruzgar
    : User is locked
  • Code:
    mkdir -p /root/backup/
    : Let's create the backup folder
  • Code:
    tar -czvf /root/yedek/ruzgar.tar.gz /home/ruzgar
    : Let's put the user files named ruzgar into the backup folder.
  • Code:
    pgrep -u Ruzgar
    [*]killall -KILL -u ruzgar
    Let's stop the user's processes with this code.
  • Code:
    find /var/spool/at -name "[^.]*" -type f -user ruzgar -delete
    All files belonging to the user are deleted.
  • Code:
    crontab -r -u ruzgar
    The user's cron files are removed.
  • Code:
    lprm ruzgar
    : user's printing operations are canceled.
  • Code:
    find / -user ruzgar -print
    : all files whose owner is ruzgar are listed. The process will take a long time.
  • Code:
    userdel -r ruzgar
    : we deleted the user
  • Code:
    id ruzgar
    : We can check if it has been deleted.

command shows failed login attempts. Gets information from /var/log/wtmp file.
command shows failed login attempts. Gets information from /var/log/btmp file. Only root user can use it.
Shows users' last login and logout dates.

PASSWD Command:

  • Code:
    paswd [parameters] is used as username
  • -d,--delete: Deletes the user password. The user cannot enter the system.
  • -l, --lock: Locks the user.
  • u-, --unlock: Unlocks.
  • -n: The day the user's password will be valid. User cannot change password before.
  • -x: The maximum number of days the user's password can be valid. Then the user has to change the password.
  • -w: Specifies the number of days before the password change period expires that the user will be warned.
  • -i: If the user does not login within these days, the user account is locked.
  • -s: Returns the user password. Indicates encryption.
WALL, WHO and WRITE Commands

wall "Message content" : Sends a message to all users.
who [parameters]
  • -a, --all : Gets all parameters selected.
  • -b, --boot: Returns the last time the system was booted.
  • -m: Shows the ip and terminal information of the current user.
  • -q, --count: Returns users who are online in the system.
  • -r, --runlevel: Indicates the runlevel of the system.
  • -u, --users: Shows users that are connected to the system.
write [username] [terminalinfo]
Instant messaging command for the panel. With the who -m user name command, panel information is learned and a message is sent to the other party, for example, with the write ruzgar pts/1 command.