Why is sudo bash needed?
-
I was reading the following code: $ sudo bash # cd /home/ # ./gitpull.sh Why do I need the first line, what does it do exactly? What if I just did $ sudo instead of $ sudo bash ?
-
Answer:
it starts a bash shell as a root level user. You need it because typically normal users can't access /home/ the danger of what you are doing is you are in a root shell -- you can mess up your machine morez easilyz
David542 at Super User Visit the source
Other answers
You would be much better off doing: $ sudo sh -c 'cd /home; ./gitpull.sh' Because the commands invoked as root will be logged. Invoking a shell directly through sudo avoids all of the security benefits of sudo and should be avoided.
William Pursell
sudo allows users to run programs with the security privileges of another user (normally the superuser, or root). bash starts a new bash shell. So, sudo bash starts a new bash shell with the security privilege of root user.
suzanshakya
sudo <shell>, if it works, betrays a poor installation of sudo and a potential security weakness. sudo should not be configured to allow arbitrary commands like shell; the purpose of sudo is to allow authenticated non-root users to run certain commands as root, without knowing the root password. If sudo bash is allowed to any user, that user is root simply by virtue of knowing his own password. If an attacker obtains the password of any one of the accounts which are able to do sudo bash, the attacker thereby has root. The proper way to do the equivalent of sudo bash (obtain a root shell) is su, followed by giving the root password, not your own.
Kaz
Related Q & A:
- How does sudo remember you already entered root's password?Best solution by Unix and Linux
- How to call a function with parameter in a bash script?Best solution by tldp.org
- How to add two variable in bash?Best solution by Stack Overflow
- How to run “sudo apt-get update” through proxy in commandline?Best solution by Unix and Linux
- How to count the number of lines in a file using Bash?Best solution by Stack Overflow
Just Added Q & A:
- How many active mobile subscribers are there in China?Best solution by Quora
- How to find the right vacation?Best solution by bookit.com
- How To Make Your Own Primer?Best solution by thekrazycouponlady.com
- How do you get the domain & range?Best solution by ChaCha
- How do you open pop up blockers?Best solution by Yahoo! Answers
For every problem there is a solution! Proved by Solucija.
-
Got an issue and looking for advice?
-
Ask Solucija to search every corner of the Web for help.
-
Get workable solutions and helpful tips in a moment.
Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.