[root@localhost ws]# more /etc/group
root:x:0:
bin:x:1:bin,daemon
daemon:x:2:bin,daemon
sys:x:3:bin,adm
adm:x:4:adm,daemon
[group_name, Password (x), Group ID (GID), Group List (multiple user names are separated by commas)]
[root@localhost ws]# id
uid=0(root) gid=0(root) groups=0(root),490(sfcb)
[root@localhost ws]# id ajay
uid=506(ajay) gid=507(ajay) groups=507(ajay)
Create a New Group
[root@localhost ws]# groupadd -g 601 HSS
Add the users in new group
[root@localhost ws]# usermod -G HSS ajay
[root@localhost ws]# id ajay
uid=506(ajay) gid=507(ajay) groups=507(ajay),601(HSS)
[root@localhost ws]# more /etc/login.defs
# Password aging controls:
#
# PASS_MAX_DAYS Maximum number of days a password may be used.
# PASS_MIN_DAYS Minimum number of days allowed between password changes.
# PASS_MIN_LEN Minimum acceptable password length.
# PASS_WARN_AGE Number of days warning given before a password expires.
#
PASS_MAX_DAYS 99999
PASS_MIN_DAYS 0
PASS_MIN_LEN 5
PASS_WARN_AGE 7
#
# Min/max values for automatic uid selection in useradd
#
UID_MIN 500
UID_MAX 60000
#
# Min/max values for automatic gid selection in groupadd
#
GID_MIN 500
GID_MAX 60000
Grant administrative rights to a normal user
[root@localhost ws]# vim /etc/sudoers
## Allow root to run any commands anywhere
root ALL=(ALL) ALL
ajay ALL=(ALL) ALL
Change group of file/directory.
[root@localhost ws]# ls -lrt
total 4
-rwxr-xr-x 1 root ajay 878 Jun 14 11:22 glist.sh
[root@localhost ws]# chgrp HSS glist.sh
[root@localhost ws]# ls -lrt
total 4
-rwxr-xr-x 1 root HSS 878 Jun 14 11:22 glist.sh
Permission
You can use octal number to represent mode/permission:
0+r+w+x = 0+4+2+1 = 7
output of ls command will show permissions as below
- = - for file d means directory
next three (bit 2,3,4) for user eg. rwx
next three (bit 5,6,7) for group eg. rwx
next three (bit 8,9,10) for others eg. rwx
Change the permission of file for user/group/others
[root@localhost ws]# chmod 775 glist.sh
[root@localhost ws]# ls -lrt
total 4
-rwxrwxr-x 1 root HSS 878 Jun 14 11:22 glist.sh
root:x:0:
bin:x:1:bin,daemon
daemon:x:2:bin,daemon
sys:x:3:bin,adm
adm:x:4:adm,daemon
[group_name, Password (x), Group ID (GID), Group List (multiple user names are separated by commas)]
[root@localhost ws]# id
uid=0(root) gid=0(root) groups=0(root),490(sfcb)
[root@localhost ws]# id ajay
uid=506(ajay) gid=507(ajay) groups=507(ajay)
Create a New Group
[root@localhost ws]# groupadd -g 601 HSS
Add the users in new group
[root@localhost ws]# usermod -G HSS ajay
[root@localhost ws]# id ajay
uid=506(ajay) gid=507(ajay) groups=507(ajay),601(HSS)
[root@localhost ws]# more /etc/login.defs
# Password aging controls:
#
# PASS_MAX_DAYS Maximum number of days a password may be used.
# PASS_MIN_DAYS Minimum number of days allowed between password changes.
# PASS_MIN_LEN Minimum acceptable password length.
# PASS_WARN_AGE Number of days warning given before a password expires.
#
PASS_MAX_DAYS 99999
PASS_MIN_DAYS 0
PASS_MIN_LEN 5
PASS_WARN_AGE 7
#
# Min/max values for automatic uid selection in useradd
#
UID_MIN 500
UID_MAX 60000
#
# Min/max values for automatic gid selection in groupadd
#
GID_MIN 500
GID_MAX 60000
Grant administrative rights to a normal user
[root@localhost ws]# vim /etc/sudoers
## Allow root to run any commands anywhere
root ALL=(ALL) ALL
ajay ALL=(ALL) ALL
Change group of file/directory.
[root@localhost ws]# ls -lrt
total 4
-rwxr-xr-x 1 root ajay 878 Jun 14 11:22 glist.sh
[root@localhost ws]# chgrp HSS glist.sh
[root@localhost ws]# ls -lrt
total 4
-rwxr-xr-x 1 root HSS 878 Jun 14 11:22 glist.sh
Permission
You can use octal number to represent mode/permission:
- r: 4
- w: 2
- x: 1
0+r+w+x = 0+4+2+1 = 7
output of ls command will show permissions as below
- = - for file d means directory
next three (bit 2,3,4) for user eg. rwx
next three (bit 5,6,7) for group eg. rwx
next three (bit 8,9,10) for others eg. rwx
Change the permission of file for user/group/others
[root@localhost ws]# chmod 775 glist.sh
[root@localhost ws]# ls -lrt
total 4
-rwxrwxr-x 1 root HSS 878 Jun 14 11:22 glist.sh
No comments:
Post a Comment