How do I gain root privileges in Ubuntu Desktop 12.04? I installed to a USB stick to try it out. Now when I installed it on a VM, I don't have the same options as I did on the USB stick, such as opening remote desktop, installing drivers, and some of the video capabilities.
3 Answers
There are 2 ways to do things with elevated permissions.
sudo
lets you run commands in your own user account with root privileges.
su
lets you switch user so that you're actually logged in as root.
But this options is by default disabled on Ubuntu. Instead you can simply start a root shell with sudo -i
.
Read What are the differences between "su", "sudo -s", "sudo -i", "sudo su"? for more information.
Use either method only as and when needed, they can cause your system damage if used without caution.
-
sudo -i
is the typical way to get a 'rootshell' on an Ubuntu box. It will log everything you do as your original user account, but you're acting as root. – Broam Nov 05 '18 at 21:15
This should make you root after you enter your user's password, assuming you were the first account to be created. Be careful when you're root. Only login as root when you really need to, and logout as soon as you're done.
sudo su -
Alternatively you can run specific commands with root privileges by prepending them with sudo
. For example:
sudo cp -p foo bar/

- 261
- 2
- 3
You cant gain something you already have. If you can use sudo, than you dont need to gain it.
Ua, excuse me... But sudo is not how you "gain" root privileges. sudo is used when you already have root level access from the admin group and want to use it.
The question implies "gain" as something that you do not have. Probably not written correctly.
Common Example: So you need sudo, or root on your computer but you can't use sudo BECAUSE you need to "gain" the privilege because you accidentally locked your self out etc. by editing sudoers and removing yourself because you thought you could login as root on Ubuntu.
sudo doesn't solve everything. And you can't gain something you already have.
"By default, the Root account password is locked in Ubuntu. This means that you cannot login as Root directly or use the su command to become the Root user."
Instead, use sudo... Example: https://help.ubuntu.com/community/RootSudo#sudo
– mondjunge Aug 27 '12 at 12:25