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.
Ubuntu – How to gain root privileges
permissionsroot
Related Solutions
You probably need to change /D-drive
's ownership, and might need to change its permissions. Specifically what you'll need to do depends on exactly what you're trying to accomplish:
If you want to use a partition mounted as
/D-drive
for one user (who is notroot
) to store data, just non-recursively take ownership of the mount point (do this while the drive is mounted).sudo chown $USER:$USER
(If you're not logged in as the user who you want to give this ability, you must replace each instance of
$USER
with the username. Otherwise, that command can be run verbatim, as the$USER
environment variable expands to the current user's username.)The reason to run
chown
without the-R
flag (i.e., nonrecursively) is:- Presumably you haven't put any files in
/D-drive
, so you don't need to change the ownership on files inside it. Once the ownership is properly set, you'll be able to put files in it, files created there will have those default permissions, and files moved or copied there will (usually) have the permissions of the originals. /D-drive
will start out containing a folder calledlost+found
. This folder should remain where it is, nobody butroot
should be able to delete it, and nobody butroot
should be able to look inside it. This is used to store data recovered whenfsck
is run (which can happen either automatically or manually). Potentially any files (or parts of any files) could end up inside it. You might, at some point, want to create some files that some user cannot read. Solost+found
should keep its default ownership and permissions.
- Presumably you haven't put any files in
If you want multiple users to be able to create, delete, and modify files inside
/D-drive
, including files written by other such users, then you should:- Create a group.
- Put users who you want to have this ability into the group.
- Make this new group the group-owner of
/D-drive
. - Set permissions on
/D-drive
so that:- Members of this new group have full control over it.
- By default, any file created in it will be group-owned by this new group, rather than by its creator's primary group. (The setgid bit has this effect, when applied to directories.)
Supposing you've decided to call this group
team-d
, here are the commands to do all this:sudo groupadd team-d
sudo usermod -a -G team-d username
(run this for each user you want in the group)sudo chgrp team-d /D-drive
sudo chmod g+rws /D-drive
If you want multiple users to be able to put their files into
/D-drive
, and to be able to modify and delete them, but not to have that same ability with respect to each other's files, then you should:- Create a group.
- Put users who you want to be able to store files in
/D-drive
in the new group. - Make this new group the group-owner of
D-drive
. - Set permissions on
D-drive
so that:- Members of the new group can access it, see what's inside, and create their own files there.
- Members of the new group cannot rename or delete files created by other members of the group (that is, make it a sticky directory).
Calling the group
team-d
as before, here are the commands to accomplish this:sudo groupadd team-d
sudo usermod -a -G team-d username
(run this for each user you want in the group)sudo chgrp team-d /D-drive
sudo chmod +t /D-drive && sudo chmod g+rwx /D-drive
You probably do not want all users to be able to put files in
/D-drive
, since this would include user accounts that don't represent real people and exist only so that certain system services can be run with reduced abilities (for security reasons). If you look in the file/etc/passwd
, you'll see users likemail
,www-data
, andbackup
.However, if you insist on allowing all users to access this directory (but not letting them rename or delete each other's files), you can do this by giving write permission to "others" (rather then owner or group-owner) and making it a sticky directory:
sudo chmod o+rwxt /D-drive
By default, the root account is accessed by sudo.
For a complete discussion in the topic, and information for how to set a root password, see: RootSudo - Community Ubuntu Documentation
With that said, it is extremely unlikely you need to set a root password, I advise you use
sudo -i
Or for graphical applications, use gksu
gksu nautilus
Best Answer
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 withsudo -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.