Running everything as root without sudo on every line
If you have a list of commands that needs to be executed as root, without having to put sudo on every line, or, if you have commands that uses “>” character to redirect standarad output to a file that require root to write to, like this
echo "text" > /root/some-file.txt |
You can do this:
sudo -s |
Example:
[email protected] ~ $ sudo -s [sudo] password for user: ubuntu-server ~ # |
Now any command you run will be as root, and all new files created will have owner user and group to be ‘root’
After you finish, remember to exit from root mode:
exit |
Example:
ubuntu-server ~ # exit exit [email protected] ~ $ |