Find all the files in Linux with suid bit set

find [path_to_search] -perm /u=s

But in above syntax we could face some error. So in order to handle these errors, we will redirect them to file /dev/null which is also known as a null device. Null device is a file in linux that discards all the data written to it without throwing any error and shows that write operation succeeded. Below example reflects the whole scenario.

find / -perm /u=s 2>/dev/null

/              –> path to root directory
-perm      –> permission
/u=s        –> Here u is for owner of the file, s stands for suid bit
2>           –> ‘2’ is file descriptor for stderr and redirects ‘>’ them to null device file
/dev/null  –> Null device file

Leave a Reply

Your email address will not be published. Required fields are marked *