'shutdown' and 'cat'

beginners, cat, linux commands, shutdown


Thread Tools Search this Thread
# 1  
Old 11-25-2008
Power 'shutdown' and 'cat'

Hi All,

This is actually a good interview question.

On linux, the permissions and group for 'shutdown' and 'cat' is the same.

-rwxr-xr-x 1 root root 18K 2008-05-21 10:43 shutdown
-rwxr-xr-x 1 root root 17K 2007-01-30 19:51 cat

Then why is it that a normal user cannot run the 'shutdown' command ?

I've done some searching and I think it has something to do with SUID.
The 'shutdown' command calls the seteuid(0) where as the 'cat' command does not.

Is this correct ? Could someone please verify? Also is there a list of commands which can only be run by su even though the permissions are the same? I mean how can we know?

Last edited by scottsiddharth; 11-25-2008 at 01:00 AM..
# 2  
Old 11-25-2008
Since there is no SETUID bit set, as you can see yourself looking at the permissions, I think it is the binary itself checking who is executing it. If you try different binaries in /sbin as a non root user you get different output, so it seems not to be a system wide mechanism.

Here is a good explanation for SETUID bit etc., 6.2:

Linux permissions
# 3  
Old 11-25-2008
The following:


in suse uses geteuid. If it's not superuser it reportsL
halt: must be superuser.
# 4  
Old 11-25-2008
This happen because your normal user can't setuid to 0. Try this and see why you cannot run successfully shutdown with normal user:

$ strace shutdown


# strace shutdown
# 5  
Old 11-25-2008
Yes, shutdown uses this, I was reporting halt. Thanks.
# 6  
Old 11-26-2008
$ strace ./shutdown

execve("./shutdown", ["./shutdown"], [/* 16 vars */]) = 0
. *****text omitted*****
getuid32() = 8218
geteuid32() = 8218
setuid32(8218) = 0
getuid32() = 8218
write(2, "shutdown: you must be root to do"..., 39shutdown: you must be root to do that!
) = 39
exit_group(1) = ?
Process 6144 detached

$ ./shutdown
shutdown: you must be root to do that!

Wow. Thanks dude. Never knew such a command existed even.

Thread Tools Search this Thread
Search this Thread:
Advanced Search

Similar Threads More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Can't shutdown the computer mi117 UNIX for Dummies Questions & Answers 6 01-23-2013 05:47 PM
db shutdown script allwin Shell Programming and Scripting 1 06-02-2012 04:10 AM
shutdown.allow not working Vaibhav.T Red Hat 1 03-11-2012 01:48 AM
Server Shutdown manoj.solaris AIX 3 01-07-2011 11:49 AM
Shutdown Script runnerpaul Shell Programming and Scripting 4 12-07-2010 07:17 AM
Script to force Oracle database shutdown when shutdown immediate does not work aixhp UNIX for Dummies Questions & Answers 7 03-11-2010 02:04 PM
shutdown command manoj.solaris AIX 3 06-25-2009 05:38 AM
cat in the command line doesn't match cat in the script shira Shell Programming and Scripting 21 01-28-2009 11:15 AM
for i in `cat myname.txt` && for y in `cat yourname.txt` danimad Shell Programming and Scripting 1 11-06-2008 01:14 AM
shutdown question mokkan Solaris 2 07-17-2008 12:43 AM
Difference between cat , cat > , cat >> and touch !!! skyineyes UNIX for Dummies Questions & Answers 6 05-28-2008 08:21 AM
Shutdown aewpcoles UNIX for Advanced & Expert Users 6 08-03-2006 10:46 AM
non root shutdown???? byblyk Linux 4 07-26-2004 03:01 AM
to shutdown rajashekaran UNIX for Advanced & Expert Users 2 02-18-2002 01:42 PM
All times are GMT -4. The time now is 02:23 PM.

Unix & Linux Forums Content Copyright 1993-2018. All Rights Reserved.
Show Password

Not a Forum Member?
Forgot Password?