Enrollments Open for Certification Course on Artificial Intelligence and Deep Learning by IIT Roorkee

  Apply Now

Linux Basics

77 / 85

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:

  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

No hints are availble for this assesment

Answer is not availble for this assesment

Note - Having trouble with the assessment engine? Follow the steps listed here

Loading comments...