Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

In Ubuntu 13.10, for the default setting, the following command in Terminal

user@host:~/path$ sudo su

results in entering an prompt

root@host:/home/user/path#

And this command

user@host:~/path$ sudo bash

enters prompt

root@host:~/path#

Is this means a different between those two commands to be that ~ have different meaning?

Usually I use sudo only. But sometimes it is not enough. For example if I wanted to write a command that modifies some file with cat >> file <<EOF, and the file is only writeable for root, I have to either use sudo su or sudo bash(assume bash is your preferred shell). But the above example seems to show that use sudo bash is better because the operation environment is more like the previous one. Is this the case? What else are different between those commands?

share|improve this question
    
You can use sudo tee for redirection with sudo rights. –  Daniel Andersson Mar 29 at 11:27
3  
    
@AvinashRaj The website only shows how to work with simple redirections like ls > out, but not for two way redirections as in my case. So can you or @DanielAndersson show me how to use sudo tee in this case? –  Earth Engine Mar 29 at 11:51
    
~ represents your $HOME directory. –  Avinash Raj Mar 29 at 11:56
1  
@EarthEngine: Just write cat <<EOF | sudo tee -a file, followed by content and a new EOF. Your order works as well. Also, the FAQ linked by @AvinashRaj explains the difference in sudo su and sudo bash further down: Special notes on sudo and shells –  Daniel Andersson Mar 29 at 11:57
show 3 more comments

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.