Ubuntu: Generic Hints Tweaks and Tips

Automount USB Drives: How To Disable
Alt + F2, then type in gconf-editor, and hit Enter.

Navigate to apps-->nautilus-->preferences, then uncheck 'media automount'

BASH Command Line Smart Completion: How To Enable
Edit the following file and uncomment the lines shown in bold below... Linux Terminal:~$ sudo nano /etc/bash.bashrc

Edit the following lines:

'''if [ -f /etc/bash_completion ] && ! shopt -oq posix; then''' . /etc/bash_completion fi
 * 1) enable bash completion in interactive shells

Blank / Black / Missing Login Screen
http://ubuntu-tutorials.com/2010/05/06/ubuntu-10-04-lucid-blank-screen-at-startup-workaround/

"From the command line, please enter sudo dpkg-reconfigure xserver-xorg. Keep the default answers if you do not know what to answer. Pay attention to your screen settings, this is probably what makes your graphical session (starting with GDM) not available. Once you're done, enter sudo reboot, and your session should be running back again."

Clear The Apt Get Cache
To clear the unused downloaded packages; Linux Terminal:~$ sudo apt-get autoclean

To clear all downloaded packages; Linux Terminal:~$ sudo apt-get clean

Command Line Aliases: How To Add/Edit
Open a terminal and edit the .bashrc file Linux Terminal:~$ nano ~/.bashrc

Edit or add the following lines:

alias ll='ls -lah' alias la='ls -A' alias l='ls -CF' alias ping='ping -c3' alias pingg='ping -c3 www.google.co.uk' alias rm='rm -iv' alias rav='rsync -a -v' alias get='get_iplayer/get_iplayer'

Reload the file... Linux Terminal:~$ source ~/.bashrc

To check... Linux Terminal:~$ alias

Ctrl-Alt-Backspace Disabled By Default In Xorg: How To Re-enable 9.04 onwards
The option of Ctrl+Alt+Backspace key combination to force a restart of X is now disabled by default, with the aim of eliminating the problem of accidentally triggering the key combination. The following re-enables the behaviour.

System -> Preferences -> Keyboard --> Layouts (tab)

Click the 'Layout Options' button

Click on "Key sequence to kill the X server" option to expand it

Tick the check box to enable

DVD Menu Navigation: How To Enable It
Linux Terminal:~$ sudo apt-get install libdvdread sudo /usr/share/doc/libdvdread4/install-css.sh

Fonts: How To Install
10.10 - right click on font and choose install OR double click and press Install button

10.04 - right click on font and choose install OR double click and press Install button

09.10 - copy the font file to /usr/share/fonts/ directory and run Linux Terminal:~$ fc-cache -f -v

09.04 - copy the font file to /usr/share/fonts/ directory and run Linux Terminal:~$ fc-cache -f -v

Generate A List Of Installed Packages And Use It To Reinstall Packages: How To
Linux Terminal:~$ sudo dpkg --get-selections | grep -v deinstall > ubuntu-files

The file 'ubuntu-files' is created in the root directory of your home folder, save it to a safe place like a USB drive.

''' Installing packages on another Ubuntu installation. '''

When you have finished and rebooted, run the following commands to update... Linux Terminal:~$ sudo apt-get update sudo apt-get dist-upgrade

Now copy that special file from your USB drive to the root directory of your home folder, and run the following commands to set the list of software you wish to install to match the first PC... Linux Terminal:~$ dpkg --set-selections < ubuntu-files sudo dselect

Reboot and enjoy the extra time you just saved... :-)

Gnome Desktop: How To Remove The Trash Icon

 * 1) Press Alt+F2 then type gconf-editor and hit enter
 * 2) In gconf-editor, navigate to apps > nautilus > desktop
 * 3) On the right side look for the entry called: trash_icon_visible
 * 4) Untick the box and that’s it!

Gnome Panel Top & Bottom Panels Missing At Start Up: How To Restore
If you lose the panels that by default are at the top and bottom of the screen housing such things as menus clock and open programmes, try the following: Linux Terminal:~$ gconftool --recursive-unset /apps/panel rm -rf ~/.gconf/apps/panel pkill gnome-panel

Restart the system and all being well you should have back the Gnome panels, they will however be reset to the original system settings.

This fix was found here after much hunting, so many thanks to the author.

There is a handy little script available to backup your panel settings which can be found here.

Gnome Reset To Defaults
rm -rf .gnome .gnome2 .gconf .gconfd .metacity

Gnome Terminal Tricks
You can set the size of the window and the title and the software it runs, like this...

gnome-terminal --title="Battery" --geometry="50x5" --command "watch acpi -b"

GRUB2 Boot Menu: How To Edit
The quickest way to edit the GRUB2 menu is to use startupmanager, to install in a terminal:

sudo apt-get install startupmanager

After installation the menu entry can be found under 'System --> Administration --> Startup Manager'

For details on manually editing GRUB2 see the Ubuntu page here

GRUB Boot Menu: How To Enable
Edit the following file:-

sudo nano /etc/default/grub

Change the lines in bold to match what is shown below:-

GRUB_DEFAULT=0 # GRUB_HIDDEN_TIMEOUT=0 GRUB_HIDDEN_TIMEOUT_QUIET=false GRUB_TIMEOUT=10 GRUB_DISTRIBUTOR=`lsb_release -i -s 2> /dev/null || echo Debian` GRUB_CMDLINE_LINUX_DEFAULT="quiet splash" GRUB_CMDLINE_LINUX=""

Save and then run the following command:-

sudo update-grub

Then, reboot:-

sudo reboot

Handy Commands To Run
After a basic install and addition of repositories the following are handy commands to run:

sudo apt-get dist-upgrade sudo apt-get update sudo apt-get upgrade sudo apt-get autoremove

Hostname (or what the computer is called): How To Change It
The name needs to be changed in the 'hostname' and 'hosts' files.

Open a terminal, type:

sudo nano /etc/hostname

Edit the name displayed and required, save changes (CTRL+o) then exit (CTRL+x)

sudo nano /etc/hosts

127.0.0.1      localhost.localdomain   localhost 127.0.1.1      machine_name_1.fish   machine_name_1

Edit the system name to match that which was entered in the 'hostname' file, save changes (CTRL+o) then exit (CTRL+x)

The line starting 127.0.1.1 is required on an Ubuntu system.

Exit the terminal and reboot the system.

Icons: Enable on System Menu - 9.10 onwards
 Method One 

By default in Karmic Koala the icons on the System menu are by default disabled, to re-enable them:

System --> Preferences --> Appearance --> Interface (tab)

Find and tick 'Show icons in menu'

 Method Two 

Open a terminal and enter the following lines one at a time:

gconftool-2 --set /desktop/gnome/interface/buttons_have_icons --type bool true gconftool-2 --set /desktop/gnome/interface/menus_have_icons --type bool true

Install Icon Sets
If required unzip your icons set and then copy the folder using the command below in a terminal:

sudo cp -r  /usr/share/icons

Login Sound: How To Disable
 Method One  Linux Terminal:~$ sudo -u gdm gconftool-2 --set /desktop/gnome/sound/event_sounds --type bool false

 Method Two 

System --> Preferences --> Startup Applications --> Startup Programs (tab)

Locate and untick 'GNOME Login Sound' entry

Media Automount For USB Drives: How To Disable
Alt + F2, then type in gconf-editor, and press Enter

Navigate to apps-->nautilus-->preferences, then uncheck 'media_automount'

Media Automount Open: How To Disable
By default Ubuntu will automount an external drive and open it in Nautilus, if you want to disable the opening of Nautilus undertake the following:

Alt + F2, then type in gconf-editor, and press Enter

Navigate to apps-->nautilus-->preferences, then uncheck 'media_automount_open'

MeMenu Display Your Real Name: How To
To remove the name from the MeMenu altogether: Linux Terminal:~$ gconftool -s /system/indicator/me/display --type int 0

To show your real name/’about me’ name: Linux Terminal:~$ gconftool -s /system/indicator/me/display --type int 2

To display the default account username: Linux Terminal:~$ gconftool -s /system/indicator/me/display --type int 1

Instructions gleaned from here.

Network Card Change From DHCP to Fixed IP Address: How To
Linux Terminal:~$ sudo killall dhclient sudo nano /etc/network/interfaces

Edit the file to match below, substituting IP and subnet numbering to match your set up:

auto lo iface lo inet loopback auto eth0 iface eth0 inet static address 192.168.0.101 netmask 255.255.255.0 network 192.168.0.0 broadcast 192.168.0.255 gateway 192.168.0.1

Reboot system, and then after reboot: Linux Terminal:~$ sudo nano resolv.conf

Add the following line to the resolv.conf file:

nameserver 192.168.0.1

Network Card Reset Naming: How To
After cloning one system to another Ubuntu will see the new PC's network card as 'eth1' as well as retaining the details of the original card. To reset all the network details undertake the following:

Open a terminal, switch to root and run the following commands:

> /etc/udev/rules.d/70-persistent-net.rules reboot

NotifyOSD - Installation Of GUI Configurator
Out of the box Ubuntu does not support configuration of NotifyOSD's bubble, however there is a hack for that:

Linux Terminal:~$  sudo add-apt-repository ppa:leolik/leolik sudo apt-get update && sudo apt-get upgrade sudo apt-get install libnotify-bin pkill notify-osd

This will install a patched version of NotifyOSD, then:

 32bit: Linux Terminal:~$  wget https://launchpad.net/~amandeepgrewal/+archive/notifyosdconfig/+files/notifyosdconfig_0.1-6~lucid1_i386.deb && sudo dpkg -i notifyosdconfig_0.1-6~lucid1_i386.deb && sudo apt-get install -f

 64bit:  Linux Terminal:~$  wget https://launchpad.net/~amandeepgrewal/+archive/notifyosdconfig/+files/notifyosdconfig_0.1-6~lucid1_amd64.deb && sudo dpkg -i notifyosdconfig_0.1-6~lucid1_amd64.deb && sudo apt-get install -f

The resulting menu entry can be found at 'Applications --> Accessories --> NotifyOSD Configuration'

NVIDIA NVRM Driver Freeze Error
If your system hangs (sometimes for minutes) when watching video, or random lockups, or display corruption, or unusually high system load, then you have an NVIDIA driver and multi-core CPU problem...

NVRM: os_raise_smp_barrier, invalid context!

You are most likely using 10.10 with the default "latest" driver - which is actually now 6 months old and suffers from a few nasty bugs...

NVRM: loading NVIDIA UNIX x86_64 Kernel Module 260.19.06  Mon Sep 13 04:29:19 PDT 2010

To fix this, upgrade to the latest driver by adding the following repository:

sudo apt-add-repository ppa:ubuntu-x-swat/x-updates sudo apt-get update sudo apt-get upgrade

You will now have (as of 25 March 2011) have version 270.29...

NVRM: loading NVIDIA UNIX x86_64 Kernel Module 270.29  Wed Feb 23 16:18:35 PST 2011

Now reboot and kiss goodbye to problems... but do have a very smooth running system :-)

Panel Icons And Applets: How To Change The Defaults For A New User
'''Linux Terminal:~$ sudo nano /usr/share/gconf/defaults/05_panel-default-setup.entries

For example, to remove the Workspace Switcher Applet, delete these lines...

workspace_switcher <-- Workspace Switcher Applet --> applets/workspace_switcher/object_type /schemas/apps/panel/objects/object_type bonobo-applet ...and all the rest up to (but not including) <-- TrashApplet Applet -->

Save and exit the editor, then run... '''Linux Terminal:~$ sudo update-gconf-defaults

Reboot and add a new user to test.

Repositories - Back Up The Listing
'''Linux Terminal:~$ sudo cp /etc/apt/sources.list /etc/apt/sources.list.backup

or '''Linux Terminal:~$

Run A Script When Computer Is Shutdown Or Rebooted: How To
Create your script and make sure you have the BASH shebang line at the top;


 * 1) !/bin/bash

Make your script executable;

chmod a+x scriptname

Copy your script to the main run-level directory;

sudo cp -a -v scriptname /etc/init.d/

Create symbolic links to the shutdown and reboot run-level directories; make sure you have the preceeding K10 in your link name like the examples below; this will make sure it is run first;

sudo ln -s /etc/init.d/scriptname /etc/rc0.d/K10scriptname sudo ln -s /etc/init.d/scriptname /etc/rc6.d/K10scriptname

Root User Account: How To Create
Unlike many other Linux distributions Ubuntu does not by default come with a Root (super user) account.

Open a terminal, type:

sudo -i sudo passwd root nano /etc/gdm/gdm.conf-custom

Add the lines:

[security] AllowRoot=true

Save changes (CTRL+o) press enter, then exit (CTRL+x)

Note: If the file you open is completely blank add the [security] line as well.

Close the terminal and restart system

Root User: How To Switch To
Open a terminal, type:

sudo su - root

Enter the password for the user profile you are in.

Stop CDROM Auto Close
Quick fix...

sudo sysctl -w dev.cdrom.autoclose=0

...and to survive a reboot...

nano /etc/sysctl.d/60-cdrom-autoclose.conf dev.cdrom.autoclose = 0
 * 1) do not autoclose cdrom

Theme For New Users: How To Change The Gnome Default
sudo nano /usr/share/gconf/defaults/16_ubuntu-artwork

From...

/desktop/gnome/interface/gtk_theme     Ambiance /desktop/gnome/interface/icon_theme    ubuntu-mono-dark /desktop/gnome/peripherals/mouse/cursor_theme  DMZ-White /apps/metacity/general/theme   Ambiance

To... (for example Clearlooks)

/desktop/gnome/interface/gtk_theme     Clearlooks /desktop/gnome/interface/icon_theme    gnome /desktop/gnome/peripherals/mouse/cursor_theme  default /apps/metacity/general/theme   Clearlooks

Save and exit the editor, then run...

sudo update-gconf-defaults

Reboot and add a new user to test.

Theme: Have Synaptic Package Manager Use A GTk Theme
If you have set your profile to use a GTk theme when you open the Synaptic Package Manager (SPM) the theme will not be used. This is because essentially it is being run as root so to have it use the theme undertake the following:

In a terminal:

sudo cp -r /home/username/.themes/your_GTk_theme/ /usr/share/themes/

Update Manager: Change the Default Behaviour 9.04 onwards
In previous versions of Ubuntu the Update Manager has displayed an icon in the notification area when updates are available. In 9.04/Jaunty this has been replaced by the Update Manager opening a window, if you find this an intrusion there are two methods to revert its behaviour.

Method One:

Open a terminal, type:

gconftool -s --type bool /apps/update-notifier/auto_launch false

To revert the behaviour open a terminal, type:

gconftool -s --type bool /apps/update-notifier/auto_launch true

Method Two:

Type 'Alt+F2' to open the run dialogue and enter the following:

gconf-editor

In the right-hand pane navigate to

apps --> update-notifier

In the right-hand pane locate 'auto_launch' and unchecked the tick box.

To revert the behaviour simply repeat the above step, but place a check in the auto_launch box.

Upgrade Items, The following packages have been kept back: How To Install
When trying to upgrade the system via the terminal you may receive a message similar to the one below:

Reading package lists... Done Building dependency tree Reading state information... Done The following packages have been kept back: banshee banshee-extension-mirage 0 upgraded, 0 newly installed, 0 to remove and 2 not upgraded.

To force the upgrade of the packages that have been held back run the following:

sudo aptitude safe-upgrade

Aptitude will need to be installed, currently up to and including 10.04 it comes as standard however from the release of 10.10 it will not be included by default. To install it open a terminal and type:

sudo apt-get install aptitude

What Files Are In The Package X?
dpkg-query -L ffmpeg

Which Version Of A Software Package Am I Running?
Open a terminal, type:

apt-cache showpkg 

Replace  with the name of the package you are investigating, for example to find the version of OpenVPN:

apt-cache showpkg openvpn

Which Version Of Ubuntu Linux Am I Running?
cat /etc/lsb-release

Window Buttons: How To Move Them Back To The Right In Ubuntu 10.04 Onwards
http://www.howtogeek.com/howto/13535/move-window-buttons-back-to-the-right-in-ubuntu-10.04/

Fix Random Missing DVD
After a while (perhaps 1 use upon a fresh cold computer start) you may 'lose' your DVD drive. This seems to be a bug with either UDEV or HAL in Ubuntu Linux 9.10 - the symlinks for nodes like 'cdrom' or 'dvd' disappear...

This is what they should look like:-

lrwxrwxrwx 1 root root 3 2010-12-14 09:53 /dev/cdrom -> sr0 lrwxrwxrwx 1 root root 3 2010-12-14 09:54 /dev/cdrw -> sr0 lrwxrwxrwx 1 root root 3 2010-12-14 09:54 /dev/dvd -> sr0 lrwxrwxrwx 1 root root 3 2010-12-14 09:54 /dev/dvdrw -> sr0

To fix this, first check that you have the actual device (like sr0)...

root@mythbuntu-server2:~# dmesg |grep -i dvd [   1.664900] ata3.00: ATAPI: HL-DT-ST BDDVDRW GGC-H20L, 1.03, max UDMA/133 [   1.793129] scsi 2:0:0:0: CD-ROM            HL-DT-ST BDDVDRW GGC-H20L 1.03 PQ: 0 ANSI: 5 [   2.123681] sr0: scsi3-mmc drive: 40x/40x writer dvd-ram cd/rw xa/form2 cdda tray root@mythbuntu-server2:~# lshw -c disk *-cdrom description: DVD-RAM writer product: BDDVDRW GGC-H20L vendor: HL-DT-ST physical id: 1 bus info: scsi@2:0.0.0 logical name: /dev/cdrom logical name: /dev/cdrw logical name: /dev/dvd logical name: /dev/dvdrw logical name: /dev/scd0 logical name: /dev/sr0 version: 1.03 capabilities: removable audio cd-r cd-rw dvd dvd-r dvd-ram configuration: ansiversion=5 status=nodisc

...then recreate the symbolic links:-

sudo -i cd /dev/ ln -s sr0 cdrom ln -s sr0 cdrw ln -s sr0 dvd ln -s sr0 dvdrw

UPDATE #1 - despite doing the above, you can still lose your DVD drive. It actually comes down to Ubuntu thinking the tray is open, when it is clearly not!

setcd -i  (this will show "CD Tray is open") lshw -c disk  (this will show "status=open")

This is obviously a software bug (probably udev or hal) but there is no known software cure, except to reboot :-(

UPDATE #2 - someone has suggested appending the word noapic to the grub boot menu and rebooting...

sudo nano /etc/default/grub GRUB_CMDLINE_LINUX_DEFAULT="quiet splash noapic"

...so far, so good!

http://book.opensourceproject.org.cn/distrib/ubuntu/hacks/