Posts

Showing posts with the label permissions

setuid permissions in Linux

Image
setuid stands for Set User  ID on Execution. What is User ID(UID)? UID is a number used to uniquely identify the user on the system, and to determine which system resources the user can access. When you create a file, the ownership of the file will be based on the user id and group id of the user created the file. When you run a process, the process will be running with the user id and group id of the user starting the process . It means, if user1 created an executable file, the owner and group of file will be the user1, but when we run the executable with other user, the uid of the process will be the other user not the user created the executable. getuid()  returns the User Id of the calling process. In the above screenshot, I created hello.c with the user 'jamal', so the owner and group is 'jamal'. But when running the generated executable/process we get the uid of the user who started the executable/process. If you set the setuid bit on the executa...

sticky bit in Linux

Image
In addition to read, write and executable (rwx), there are three special permissions for files and directories: Sticky bit SUID Permission SGID Permission The use of sticky bit is to have a folder shared between all the users. For example, if you have a folder with 777 permissions, this means user for example user1 can delete the files can read, write and delete the files created by user2. With sticky bit enabled on the directory, user1 can only read/write the file but cannot rename or delete the file. /tmp is a folder in Linux with sticky bit enabled How to set sticky bit? chmod +t mydir How to unset sticky bit? chmod -t mydir How to find out all directories with sticky bit enabled? find / -perm +1000 chmod 1777 mydir will create the directory with sticky bit enabled