6 ms·
Ironically, "sudo su" works really well if you do need to get to root. But yeah, "sudo" is a much safer practice.
by sudonim 15y ago
Ironically, "sudo su" works really well if you do need to get to root. But yeah, "sudo" is a much safer practice.
- akent 15y ago"sudo -i", please!
- spc476 15y agosudo vi^Mpassword^M:shell Years ago a friend of mine asked my help in securing a Unix system with sudo. I bascially told him it was nearly impossible because there were (and still are) too many ways to escape back to a root shell with sudo, so, in my humble opinion, gives a false sense of security.
- marshray 15y agoBut as far as letting people run a root shell goes, sudo is a handy way to do it.
- chousuke 15y agoI don't think the point is "more secure" root access. Rather, sudo is just a convenient way to invoke superuser privileges only when necessary. If you need a longer session with uid 0, use sudo -i. Having a separate root login is pretty much pointless. I doubt having separate passwords helps security either, since local privilege escalation vulnerabilities are common anyway. I've used sudo to restrict root access to specific command line invocations for certain users. With due care (ie. no access to software with shell escapes) it is secure. In any case, distributions seem to be moving towards eliminating the superuser altogether in common use cases. I think advocating sudo was just the beginning.
- graywh 15y agostart by disallowing vi through sudo and tell people to use sudo -e instead
- kwantam 15y agoI sudo su very frequently because I'm almost always executing more than one command as root. Standard warnings apply, but my approach for being sure that I am who I think I am is to put my username in my prompt and color code it so that when I'm root the username turns red. I also color code the hostname so that I can tell at a glance what machine I'm on. For example, export PS1='[\[\033[1;34m\]\u\[\033[0m\]@\[\033[1;30m\]\h\[\033[0m\] $newPWD]\$ ' where $newPWD is a friendly, shortened $PWD. On that same machine, the root prompt is identical except that the color is set to 1;31m instead of 1;34m, which makes it bright red.
- silvestrov 15y agoNo need for 'su' to get a root shell. You can use 'sudo -s' for that, and you still set a root-specific PS1 in the bashrc file.
- thwarted 15y agoThis doesn't always run the same rc scripts (depending on the shell and local convention). I'm used to typing sudo su - (with optional username) to get the environment as close as possible to what it would be if I logged in as the target user.
- deleted 15y ago[deleted]
- silvestrov 15y agoalias ssu='sudo /bin/bash -login'
- pilif 15y agosudo -s launches a shell in non interactive mode (which goes through .bashrc or .zshenv and .zshrc depending on your shell) whereas sudo -i emulates a usrer login which puts the shell in interactive mode (.profile, .zshenv) Also -i does more stuff to simulate a login like setting $HOME and cd'ing there. Usually you might want to use sudo -i or 'su -' which both simulate a login. But sudo su - really isn't needed any more since -i has been added
- nkassis 15y agoIf you have a saddist sysadmin he wouldn't allow you to use su or any other dangerous command that are not approved. Sudo is a rather impressive tool. If you need to give someone access to root for one or two commands, it can do that. It's logging ability is lost when you do sudo su. You should avoid it as much as possible on servers with many admins. That log trail can be a real butt saver.
- jacques_chester 15y agosudo $YOUR_SHELL_NAME_HERE achieves the same purpose.
- pdmccormick 15y ago`sudo -s` works nicely too.
- deleted 15y ago[deleted]
- tincholio 15y agoOr you can just use "sudo -i"