How to detect kind of command for root only?

Dear all,

Please help me clarify why i cannot run command in /sbin directory (ex: /sbin/fdisk -l )!

I've checked permission on files which belong /sbin directory with execute permission. However, i still cannot run with normal user.

Sorry for my English.
thanks all,

if fdisk has following permission
-rwxr-xr-x 1 root root 99400 2010-03-22 10:57 fdisk

Then you should be able to run this. try
/sbin/fdisk -h
you should be able to get the help page.

Now coming to the point where we talk about what fdisk does. fdisk is the command to manipulate the disk partition which other user can not, only root has access to do this.

summary..
you can run the fdisk command as other user but can not perform the disk operation using the command.

I hope i clear you doubt.

Thanks Visal,

But i want to know exactly the difference between "run command" and "perform command" as you said.

I mean i can "perform": fdisk -h but cannot fdisk -l.

Additionally, how i can check or recognize what commands only perform by root because command to show permission (ls -la) not clear.

thanks all much,

ok let me give you an example.

If you write a script in which you put some operation which only root can do, for example reading shadow file etc.. and make that script executable by everyone...
anybody can execute the script but script wont work for everyone, since they do not have access to read/write shadow file...
Here everybody can execute your script(run command) but can not perform the right function(perform action).

Same in this case fdisk is nothing but an executable file which is executable by anyone but operation mentioned in the file are not meant to be performed by them.

I hope its better with example.

1 Like

Thanks Vishal much,

Basically, only root should be running the administrative commands in /sbin and /usr/sbin. Non-root users may be technically able to run them - according to the file permissions - but many times the command will fail because the user does not have sufficient access to some resource that the command requires, such as the /proc or /dev filesystems. If you want to empower specific users to run specific commands as root, then set up sudo and use that.