I don’t remember exactly how I learned about most of my Linux command line knowledge and file permissions, but this morning at 3am I found myself learning something new. I actually knew permissions are user, group and others, but I really didn’t pay attention to what others really means. At 3am I created a shell script to back up some configuration files and I gave that shell script execute permission:
chmod o+x myshellscript
When I tried to run the shell script I found I didn’t have permission to execute the shell script. Even though the shell script was marked executable and I was the owner and could change permissions on the script I couldn’t execute it. It makes perfect sense though, and my thinking was flawed. It’s best not to think of yourself as the owner of a file, better to think of yourself as the user of the file. O is others and adding others execute permission means just that, all others (besides you) can execute the script. For the user who owns the file to execute the file they must have the user execute permission set:
chmod u+x myshellscript
Of course you could also be a member of a group with permission to execute provided that group execute permission is set. Yes, it’s a simple thing, but it shows how lazy osmosis learning isn’t always comprehensive. Better to read a few books, take a few courses, or read a lot online.