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
Page55/67
Date26.02.2024
Size1.85 Mb.
#63678
1   ...   51   52   53   54   55   56   57   58   ...   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

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),1003(finance)
[root@rhel-instance
]# ls /home/

user user user02
[root@rhel-instance
]# rm -rf /home/user01/

As you can see, we needed to manually delete the home directory. This way of removing a user is good if we want to keep its data for future use.
To fully remove a user, we shall apply the -r option. Let’s try it with user02:
[root@rhel-instance
]# userdel -r user02

[root@rhel-instance
]# ls /home/

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

[root@rhel-instance
]# id user02

id: 'user no such user
Now, let’s remove the finance group with the groupdel command:
[root@rhel-instance
]# groupdel finance

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

As we have seen, it’s simple and easy to create users and groups in RHEL and make simple assignments. In the next section, let’s check in more depth how to manage groups and assignments to them.

Securing Systems with Users, Groups, and Permissions
142
Managing groups and reviewing assignments
We have seen how to create a group with groupadd and delete it with groupdel. Let’s see how to modify a created group with groupmod.
Let’s create a group to work with. We will create the misspelled acounting group by running the following:
[root@rhel-instance
]# groupadd -g 1099 acounting

[root@rhel-instance
]# tail -n /etc/group

acounting:x:1099:
You see we made a mistake in the name by not spelling it accounting. We may even have added some user accounts to it and we need to modify it. We can do sousing groupmod and running the following:

Download 1.85 Mb.

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




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

    Main page