1

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?

8
  • You can use sudo tee for redirection with sudo rights. Mar 29, 2014 at 11:27
  • 3
    help.ubuntu.com/community/RootSudo Mar 29, 2014 at 11:27
  • @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? Mar 29, 2014 at 11:51
  • ~ represents your $HOME directory. Mar 29, 2014 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 Mar 29, 2014 at 11:57

0

You must log in to answer this question.

Browse other questions tagged .