Ubuntu technical problems and solutions reference, a modern cookbook.
Tag Archives: mount
February 13, 2012Posted by on
I found myself recently in the awkward situation of replacing all the groups my user was part of, with a group I wanted to append to.
Due to the fact that I have installed VirtualBox, my user needed to be part of the vboxusers group. All good I thought, so I wanted to add that group to my user.
So I used the following Wrong command
sudo usermod -G vboxusers myuser
As per the help
usermod --help -G, --groups GROUPS new list of supplementary GROUPS -a, --append append the user to the supplemental GROUPS
I have realised that I forgot to add the append option. So actually to add the new group to the existing list of groups.
The correct command would have been:
sudo usermod -aG vboxusers myuser
After my reboot, because the effect of the command is not visible until a logout/login is performed, I have found myself without sudo/admin rights. The result of the command:
was myuser and vboxusers. Great, no admin rights.
So here is what I did to solve this problem.
Boot up from the LiveCD. Hope you have one at hand. Doesn’t have to be the latest distribution.
Open the terminal and mount your root:
sudo mount /dev/sda1/mnt sudo chroot /mnt
Note: instead of sda1 you should use the partition on which your root is mounted. If you are not sure about it, check in Disk Utility application (the default one on your liveCD.
Locate the groups:
The file which holds the groups is simply called groups. But because you have recently changed this file with the wrong command, you need to check the backup file in order to determine which were your old groups, so that you can add them back. The backup file is groups-.
Now, you have 2 options to go forward. The first one is to manually edit the groups file to add your user against the groups (take the back-up file as an example). The second option is to simply re-add the groups to your user with the usermod command. This way you learn the right format of the command:
usermod -aG group user
Note: there is no need to use sudo in a liveCD session.
Now remove the liveCD and the reboot will make you a happy user
November 13, 2011Posted by on
I know there are a lot of people who are adding their drives in /etc/fstab. I personally don’t like that approach, because in Nautilus I will see 2 copies of the same drive. One mounted and the other unmounted and when it gets pressed I got an error saying that the drive is already mounted.
I prefer a solution where the drive gets mounted exactly as Nautilus does it, when the drive is mounted by simply pressing the unmounted drive.
First we need to find out where each drive is located, so that we know where each drive is located on the disk. Using the following command, we get the desired outcome:
ls /dev/disk/by-label -lah
The output look something like this:
lrwxrwxrwx 1 root root 10 2011-11-13 14:58 Storage -> ../../sda6
Assuming we need to auto mount the drive called Storage, we create it’s mounting point:
sudo mkdir /media/Storage
Now, a script needs to be created which mounts the drive:
vi ~/mountscript.sh .... #!/bin/bash sudo mount /dev/sda6 /media/Storage
Need to make the script executable and then test it
sudo chmod +x mountscript.sh ./mountscript.sh
You will notice that the script requires us to introduce the password. That’s not good when we are going to add this script to be run at start-up. So we need to exclude the 2 commands we are using (mount and the script we’ve just created) from sudo to ask us for the password.
Add this line at the end replacing your user with the name of your own user:
your user ALL=(ALL) NOPASSWD: ~/mountscript.sh, /bin/mount
Now both commands, mountscript.sh and mount are excluded from being prompted a password.