3 Basic Commands and Simple Shell Scripts Once you have your first Red Hat Enterprise Linux rhel


[root@rhel-instance ]# grep user /etc/passwd



Download 1.85 Mb.
View original pdf
Page54/67
Date26.02.2024
Size1.85 Mb.
#63678
1   ...   50   51   52   53   54   55   56   57   ...   67
Pablo Iranzo Gómez, Pedro Ibáñez Requena, Miguel Pérez Colino, Scott McCarty - Red Hat Enterprise Linux 9 Administration-Packt Publishing (2022) -chap 3 82 - 180
[root@rhel-instance
]# grep user /etc/passwd

user01:x:1001:1001:User 01:/home/user01:/bin/bash
The usermod command uses the same options as useradd. It will be easy to customize your current users now.
Let’s create user as an example of how to use the options:
[root@rhel-instance
]# useradd --uid 1002 -groups wheel \

--comment "User 02" --home-dir /home/user02 \
--shell /bin/bash user02
[root@rhel-instance
]# grep user /etc/passwd

user02:x:1002:1002:User 02:/home/user02:/bin/bash
[root@rhel-instance
]# id user02

uid=1002(user02) gid=1002(user02) groups=1002(user02),10(wheel)
Tip
When the command line is too long, the \ character can be added, then press Enter and continue the command on anew line.
Now, we know how to create a user, but we may need to create a group too and add our users to it. Lets create the finance group with the groupadd command:
[root@rhel-instance
]# groupadd finance

[root@rhel-instance
]# grep finance /etc/group

finance:x:1003:
We can add the user and user users to the finance group:
[root@rhel-instance
]# usermod -aG finance user01

[root@rhel-instance
]# usermod -aG finance user02

[root@rhel-instance
]# grep finance /etc/group

finance:x:1003:user01,user02

Creating, modifying, and deleting local user accounts and groups
141
Important Note
We are using the -aG option to add the user to the group, instead of modifying the groups the user belongs to.
Once we know how to create users and groups, let’s check how to delete them with the userdel command:
[root@rhel-instance
]# userdel user01

[root@rhel-instance
]# grep user /etc/passwd

[root@rhel-instance
]# id user01

id: 'user no such user

Download 1.85 Mb.

Share with your friends:
1   ...   50   51   52   53   54   55   56   57   ...   67




The database is protected by copyright ©ininet.org 2024
send message

    Main page