[root@rhel-instance
]# umask 0077[root@rhel-instance
]# touch file4.txt[root@rhel-instance
]# ls -l file4.txt-rw-------. 1 root root 0 Mar 11 22:35 file4.txtLet’s reestablish umask in our session to the defaults to continue practicing:
[root@rhel-instance
]# umask 0022Now, we may find ourselves with the need to create a directory fora specific user or group or to change the owner of a file. To be able to change the ownership
of a file or directory, the chown or chgrp tools are used. Let’s see how it works. Let’s move to /var/tmp and create the folders for finance and accounting:
[root@rhel-instance
]# cd /var/tmp/[root@rhel-instance tmp]# mkdir finance[root@rhel-instance tmp]# mkdir accounting[root@rhel-instance tmp]# ls -ltotal 0drwxr-xr-x. 2 root root 6 Mar 11 22:35 accountingdrwxr-xr-x. 2 root root 6 Mar 11 22:35 financeNow, let’s create the groups for finance and accounting:
[root@rhel-instance tmp]# groupadd finance[root@rhel-instance tmp]# groupadd accountinggroupadd: group 'accounting' already existsIn this example, the accounting group was already created. Let’s change the group for each directory with chgrp:
[root@rhel-instance tmp]# chgrp accounting accounting/[root@rhel-instance tmp]# chgrp finance finance/[root@rhel-instance tmp]# ls -ltotal 0drwxr-xr-x. 2 root accounting 6 Mar 11 22:35 accountingdrwxr-xr-x. 2 root finance 6 Mar 11 22:35 finance