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


[root@rhel-instance ]# chmod 0755 file.txt



Download 1.85 Mb.
View original pdf
Page66/67
Date26.02.2024
Size1.85 Mb.
#63678
1   ...   59   60   61   62   63   64   65   66   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
]# chmod 0755 file.txt

[root@rhel-instance
]# ls -l file.txt

-rwxr-xr-x. 1 root root 0 Mar 11 22:30 file.txt
[root@rhel-instance
]# chmod 0640 file.txt


Securing Systems with Users, Groups, and Permissions
156
[root@rhel-instance
]# ls -l file.txt

-rw-r-----. 1 root root 0 Mar 11 22:30 file.txt
[root@rhel-instance
]# chmod 0600 file.txt

[root@rhel-instance
]# ls -l file.txt

-rw-------. 1 root root 0 Mar 11 22:30 file.txt
As we said before, the default configuration of permissions is set by umask. We can very easily seethe value:
[root@rhel-instance
]# umask

0022
[root@rhel-instance
]# umask –S

u=rwx,g=rx,o=rx
All the newly created files have execute permissions removed (With this umask, 0022, the one provided by default in RHEL, we will have write permissions for group and others also removed (Even when it is not recommended to change umask, we could give it a try to learn how it works. Let’s start by using the most permissive umask, 0000, to see how all read and write permissions are assigned to newly created files:
[root@rhel-instance
]# umask 0000

[root@rhel-instance
]# touch file2.txt

[root@rhel-instance
]# ls -l file2.txt

-rw-rw-rw-. 1 root root 0 Mar 11 22:33 file2.txt
Now, let’s use the more restrictive umask for group and others permissions:
[root@rhel-instance
]# umask 0066

[root@rhel-instance
]# touch file3.txt

[root@rhel-instance
]# ls -l file3.txt

-rw-------. 1 root root 0 Mar 11 22:33 file3.txt
If we try a higher number, it won’t work and will return an error:
[root@rhel-instance
]# umask 0088

-bash: umask: 0088: octal number out of range

Checking, reviewing, and modifying file permissions
157
You can see that the effect of 0066 and 0077 is the same:

Download 1.85 Mb.

Share with your friends:
1   ...   59   60   61   62   63   64   65   66   67




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

    Main page