Let's start with location. I like to think of this as the location of the script file in the file system. Common navigational commands can be used to manage the location of scripts. For example, the ls (list) command can be used to determine if a script file is in a certain directory. Notice also that the ls command displays the ownership of the example file.
[root@server1 ~]# ls -l /etc/cron.daily-rwxr-xr-x 1 root root 311 Jan 01 2016 example
Likewise, the find command can be used to find a certain file.
[root@server1 ~]# find / -iname example/etc/cron.daily/example
You only need the read and write permission to interact with a non-script file, such as a text file.
[root@server1 ~]# ls -l /home/user1/documents-rw-rw-rw- 1 root root 311 Jan 01 2016 example
If you try to run a script file, such as a BASH or SH file, and the file does not have the x (execute) permission, error "permission denied" will appear.
[root@server1 ~]# ls -l /etc/cron.daily-rw-rw-rw- 1 root root 311 Jan 01 2016 example[root@server1 ~]# bash /etc/cron.daily/examplePermission denied
Adding the execute permission to the file allows the script file to be run. With the chmod command, you can use a string of numbers to add the execute permission, such as 755. You could also use +x to add the execute permission to owner, group, and other. Or, you can specify only owner by using the following:
[root@server1 ~]# chmod 755 /etc/cron.daily/example[root@server1 ~]# ls -l /home/user1/documents-rwxr-xr-x 1 root root 311 Jan 01 2016 example[root@server1 ~]# bash /etc/cron.daily/exampleHello World
SUID of a file
SUID on a directory
When using the chmod (change mode) command to modify the permissions of a file, use 4 to add the SUID permission.
[root@server1 ]# chmod 4660 /path/to/file
Instead of using 4 for SUID, the letter "s" can be used instead. u+s adds the SUID permission, u-s removes the SUID permission.
[root@server1 ]# chmod u+s /path/to/file #Add SUIDchmod u-s /path/to/file #Remove SUID