Linux Basics

You are currently auditing this course.
99 / 107

Permissions - setting setuid

You can make a program setuid by giving s instead of x permission. If you have written a script x.sh, an example would be:

chmod +s x.sh
  1. Start creating file with the name whoownsit_username.sh in /tmp directory:

    nano /tmp/whoownsit_$USER.sh
    

    Note: If your user name is sandeep1234, the filename would be whoownsit_sandeep1234.sh

  2. Put the following content in the editor in the previous step:

    whoami
    
  3. Save it by pressing Ctrl+x and press y

  4. Give it setuid permission:

    chmod +sx /tmp/whoownsit_$USER.sh
    
  5. Check if you have given correct permission by

    ls -l /tmp/whoownsit_$USER.sh
    

It should display something like this in permissions: rwsrwsr-x

Note: setuid doesn't work in shell scripts. Please see http://www.faqs.org/faqs/unix-faq/faq/part4/section-7.html


Loading comments...