Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am aware that we can execute a command/script as a super/another user using sudo command. But Is there a possibility where the sudo utility itself is unavailable/removed by the user. If so, what could be the alternative to sudo other than su? Also, do sudo and su serve the same purpose?

share|improve this question
    
I didn't downvote you, but I can see why someone might - The question could easily be interpreted as trying to get advice on hacking a system and some people might not like that. (I suspect that your question was innocent though) – davidgo Aug 9 '13 at 8:00
1  
This Question might give you some info about the different usages of su and sudo, resp. Especially Dan's answer is worth a read. (Downvote neither from me ;)) – mpy Aug 9 '13 at 8:01
up vote 7 down vote accepted

'sudo' allows you to launch any program as any user. It is 'setuid root', as the program itself requires root permissions to do this. The power of sudo is that you can easily configure who can do what. You can allow a user to execute nmap (and only nmap) using sudo.

'su' allows you to launch a shell as any user. When you launch a shell, you can obviously launch any other program. It is therefore more dangerous; on well-administered systems, su access is generally disabled, but sudo might be available for distinct programs.

The reason why the two programs above are used is accountability. Sudo logs all requests that are made. Therefore, it is very easy for an administrator to track what a user has done using root privileges. If you grant access to a shell, a user can do whatever he/she likes (it is a 'black hole'). (Of course, advanced logging on kernel-level thwarts this).

Of course, these programs can also be marked setuid. This changes the permissions to the owner of the binary when executing it. If you manage to activate the setuid bit on e.g. /bin/bash and set the owner of /bin/bash to root, you will be root everytime you execute /bin/bash.

Lastly, physical access to the machine will allow you to do whatever you like. You can boot from a flash drive and access the local filesystem. You could even configure your bootloader to use a different init process which immediately launches a shell in single-user mode (without asking for a password).

share|improve this answer
    
so does that mean sudo i more preferred to su? – AlwaysALearner Aug 9 '13 at 10:03
    
It depends on the usage case - sudo is more preferred when a "normal" user needs to perform a specific task requiring enhanced access while su allows a user to behave as another user (for example root to do sysadmin maintenance on the server) – davidgo Aug 9 '13 at 19:58
    
sudo is preferred to su for multiple reasons. First of all: you only have to enter your own password, and not remember the (complicated, or even disabled) root password. You are accountable (a log somewhere shows you did sudo), and sudo can be restricted. – parasietje Feb 29 at 8:45

It seems that no one has answered the question of whether or not there exist alternatives to sudo besides su, so you might be interested to know that the sudo website actually maintains a list of sudo alternatives:

http://www.sudo.ws/other.html

The list includes both open-source and commercial software. Here are the open-source sudo alternatives listed at the moment (I can't post links to all of these because my reputation is too low):

  • vsys
  • GNU userv
  • sus
  • super
  • priv
  • calife
  • ssu
  • su1
  • op

That said I've never used any of these alternatives, nor have I ever seen or heard of them in any other context.

share|improve this answer

Log in as root (if allowed on your tty) or reboot the computer and log in with init=/bin/bash on the command line to restore the required functionality.

I point out that only root can remove sudo.

sudo and su serve similar but different purposes. "sudo" allows you to do something with someone elses permissions while "su" allows you to "become" that user and lets you behave like them.

share|improve this answer

If the machine has openssh-server installed, then an alternative to sudo might be:

ssh root@localhost ..command.. ..goes.. ..here..

If it hasn't been disabled then there is su as you mentioned:

su - root -c "..command.. ..goes.. ..here.."
share|improve this answer

If sudo isn't installed (or you aren't allowed by it's configuration to use it), and you don't have access to root's password for su, it is the policy of the administration of the machine. Take it up with them, I will not help anybody go against the machine's management.

share|improve this answer
1  
So what if the question is asking on how to hack a system? It's important that everyone knows how to hack systems. This ensures that when those same people setup systems, they can do so in a way that avoids the vulnerability. Treating this as some kind of 'forbidden knowledge' just leads to things being left vulnerable. Theres an entire career in knowing how to hack, it's called penetration testing. So get off your high horse supercop. In any case if he is asking such a basic system, he's not likely to be the next Kevin Mitnick. – David C. Bishop Nov 24 '14 at 0:54
    
This doesn't answer the question, so it should be posted as a comment. The downvotes can be explained by that rather than disagreement with the point you make. – fixer1234 Aug 13 '15 at 19:56

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .