Setting permissions with the symbolic method

Whenever you create a file as a normal user, by default, it will have read and write permissions for the user and the group, and read permissions for others. If you create a program file, you have to add the executable permissions yourself. With the symbolic method, you could use one of the following commands to do so:

chmod u+x donnie_script.sh
chmod g+x donnie_script.sh
chmod o+x donnie_script.sh
chmod u+x,g+x donnie_script.sh
chmod a+x donnie_script.sh

The first three commands add the executable permission for the user, the group, and others. The fourth command adds executable permissions for both the user and the group, and the last command adds executable permissions for everybody (a for all). You could also remove the executable permissions by replacing the + with a -. And, you can also add or remove the read or write permissions, as appropriate.

While this method can be handy at times, it also has a bit of a flaw. That is, it can only add permissions to what's already there, or remove permissions from what's already there. If you need to ensure that all of the permissions for a particular file get set to a certain value, the symbolic method can get a bit unwieldy. And for shell scripting, forget about it. In a shell script, you'd need to add all kinds of extra code just to determine which permissions are already set. The numerical method can vastly simplify things for us.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.21.100.34