chmod
alters the permissions for a file or directory, you could allow full read/write access to a file or directory by running the following command:
chmod 777 myfile.ext
You could do the same on a directory recursively:
chmod -R 777 mydirectory
But if we look at the directory listing of this path now, we can’t tell what integer value this affected:
$ ls -lash
0 -rwxrwxrwx 1 ao staff 0B 18 Nov 13:29 myfile.ext
How to get the CHMOD value
If we want to get the actual integer value back, we could use the stat
command and tell it what we want from it:
Each of the below command will now return a 777
back.
On Mac
stat -f "%OLp" myfile.ext
# 777
On Linux
stat --format '%a' myfile.ext
# 777
On Busybox!
stat -c '%a' myfile.ext
# 777