Tag Info

New answers tagged

1

Bash has two completion engines: a simple one that mostly only does completion of commands in command position and file names in argument position, and a fancy one that completes arguments based on the command. To get man page completion, you need the fancy one. When you start bash, only the simple completion engine is enabled. To get the fancy engine, you ...


5

Running su invokes bash in non-login mode. Bash then reads .bashrc to configure its environment. Runing su - invokes bash as a login shell. In this mode /etc/profile is executed if it exists. Bash also searches for ~/.bash_profile, ~/.bash_login and ~/.profile executing the first file it finds. Although not documented, it appears to execute ~/.bashrc ...


-2

No. If logging is enabled for sudo, sudo -i FOO logs FOO (thus leaving an audit trace) while sudo su; FOO will only log the su but not the commands that follow it (like FOO). And of course the main difference is the use of passwords: sudo -i needs only the password of the user (if sudo is configured that way) while sudo su needs the password of root.


0

Yes. man su | sed '/^FILES/,/^$/!d' FILES /etc/pam.d/su default PAM configuration file /etc/pam.d/su-l PAM configuration file if --login is specified /etc/default/su command specific logindef config file /etc/login.defs global logindef config file There's no sudoers there. Maybe these files have been configured in a ...


8

To answer your question directly: no, there is no good reason to do this. Also, sudo su produces two log entries when one would suffice. I've seen many people do this, and when I ask why they don't just run sudo -s, the answer is just that they don't know about the -s flag to sudo, and generally they switch after I point it out. However, to your list of ...


26

As you stated in your question, the main difference is the environment. sudo su - vs. sudo -i In case of sudo su - it is a login shell, so /etc/profile, .profile and .bashrc are executed and you will find yourself in root's home directory with root's environment. sudo -i is nearly the same as sudo su - The -i (simulate initial login) option runs the shell ...


0

For future reference: To suppress dd output completely redirect stderr to /dev/null like so: dd if=/dev/urandom of=sample.txt bs=5MB count=1 2> /dev/null This works nicely if you want to, for example, time the process using the time command in bash and assign the result to a variable, without getting any of the output that dd produces. reference: ...


1

Pipe the password into the su, which in turn is piped to ssh. Example below. Note how foopass is the correct password for user foo, so it runs the id command happily. Note how badpass is the wrong password for user foo, so it generates Authentication failure. $ echo "echo foopass | su foo -c id" | ssh -t -o RequestTTY=yes steve@localhost Pseudo-terminal ...


4

sudo su asks for the user's password, the user has to be in the sudo/adm/admin/wheel group (depening on flavour of the OS) to be able to execute sudo. The root password will be prompted when using su alone. Check the settings in /etc/sudoers file to see why you are not being asked for a password while using sudo. Most likely the time-out is set to a few ...


1

Try this command to su a command as different user. su user -c command could someone suggest how to run it with PATH exported?



Top 50 recent answers are included