What is the difference between the sudo
and su
command? Why does OS X handle these different than Linux?
The difference between the sudo and su command
terminalunix
Related Question
- The difference between .bash_profile and .bashrc
- MacOS – the difference between ‘Capacity’ and ‘%iused’ when running the ‘df’ command in the terminal
- Difference between tty[p,r,s][N] and pts
- Difference between dig @www.google.com ns . and dig www.google.com ns
- MacOS – the difference between downloading and installing software from AppStore and Terminal
- The exact difference between ‘tty’ and a ‘console’
- MacOS – Can anyone explain to me the difference between terminal apps, CLI, CLT and Prompt
Best Answer
OS X handles
sudo
andsu
identically to Linux.sudo
is a command that, without any additional options, will run a command as root. For example:su
on the other hand, will switch the current user to root (again without any extra commands). In the example below, I have to runsudo su
, since I don't know the root password for my system:The key difference between
sudo
andsu
issudo
runs a command as root, whereassu
makes you root. Much like other command line utilities there are a number of alternative ways to use bothsudo
andsu
, if you're interested you can always runman <command>
eg.man sudo
to get more information.