Ubuntu Technical
Ubuntu technical problems and solutions reference, a modern cookbook.
Tag Archives: ubuntu 11.10
Stop or start BOINC daemon after boot
Posted by on March 15, 2012
I have installed BOINC client, to subscribe to some projects meant to discovery alien life or at least some new pulsars.
However, I have noticed that the client, in contrast to it’s Windows counterpart, didn’t have an option in Preferences for auto-start on system boot. Of course it was starting up automatically and that’s not good in my book. So I started digging a little bit, and came across the documentation page
In a nutshell, the “init” script is:
/etc/init.d/boinc-client
The following commands (with self-explanatory options) can be directly run on the script:
./etc/init.d/boinc-client start ./etc/init.d/boinc-client stop ./etc/init.d/boinc-client restart ./etc/init.d/boinc-client status
As I have now found out, in a Debian-based Linux distributions you use the update-rc.d command to turn a system service (daemon) on or off at boot time (I needed to use the -f force option to remove boinc-client, don’t know exactly why):
# tells the system to start the BOINC client as a daemon at boot time sudo update-rc.d boinc-client defaults 98 # tells the system not to start the BOINC client at boot time sudo update-rc.d -f boinc-client remove
Cheers
Sync directories excluding file types
Posted by on March 11, 2012
I have recently needed to find a solution to moving the content of a directory from one folder into another, but excluding certain file types. After digging through the documentation I have found the rsync command.
Short extract from it’s man pages:
Rsync is a fast and extraordinarily versatile file copying tool. It can copy locally, to/from another host over any remote shell, or to/from a remote rsync daemon. It offers a large number of options that control every aspect of its behavior and permit very flexible specification of the set of files to be copied. It is famous for its delta-transfer algorithm, which reduces the amount of data sent over the network by sending only the differences between the source files and the existing files in the destination. Rsync is widely used for backups and mirroring and as an improved copy command for everyday use.
So, here is the script to copy files from one place to another ignoring certain file types (in this example I exclude .avi files):
rsync /source/folder -av --exclude='*.avi' /destination/folder
The -v option is for verbose, so that we can see in the output what’s being synced.
Enjoy.
Restore lost admin group membership
Posted by on February 13, 2012
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:
groups
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:
cd /mnt/etc
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
Thanks to fossfreedom and ccollins
Add new application to Open With Other Application…
Posted by on February 1, 2012
What if you want to add a new application in the “Open With Other Application…” section? Maybe you want to add that particular application as the default application to open certain type of files.
Here is an example of how I can add Vim as an option to open a text file. Vim will open the file in a new terminal session.
An .desktop file needs to be created in ~/.local/share/applications
So, let’s use vim for this purpose, it is just appropriate.
vim ~/.local/share/applications/vim.desktop
Press i to enter in edit mode and type in the following:
[Desktop Entry] Categories=; Comment=Edit file in Vim Exec=vim %f GenericName=Process Viewer Hidden=false Icon=vim Name=Vim Terminal=true Type=Application Version=1.0
after that, press ESC to exit the edit mode and type :wq to write to the file and quit.
That’s it. Now when you right click on a file, vim will be present in the list of Open With Other Application section, and you can add it as a default application.
Thanks for this answer to Marty Fried
Install Windows after Ubuntu is installed
Posted by on January 6, 2012
If one has Ubuntu already installed, and then Windows is installed on a different partition, they will notice that grub will be messed up. Ubuntu won’t be found anymore.
Here are the steps to safely do this:
1. Firstly, the data should be backed up. Whenever a new OS is installed, mistakes are easily made.
2. Boot the Ubuntu desktop CD, resize Ubuntu’s partition to make space for Windows. The resulting partition must be a NTFS partition. (Skip this if you already have a NTFS partition.
3. Then install Windows into the NTFS partitions.
4. Next boot into Ubuntu CD again and re-install grub. There is a visual tool that helps. It’s called boot-repair
sudo add-apt-repository ppa:yannubuntu/boot-repair && sudo apt-get update sudo apt-get install -y boot-repair && boot-repair
Documentation on the tool can be found on Ubuntu boot repair documentation
The tool looks like this:
Thanks for the tip to bodhi.zazen


