Ubuntu: Generic Hints Tweaks and Tips

Burning a CD on the Command Line with Wodim
Scan for the drive...

Linux Terminal:~$ wodim --devices wodim: Overview of accessible drives (1 found) : - 0 dev='/dev/scd0'	rwrw-- : 'HL-DT-ST' 'BDDVDRW GGC-H20L' -

Now burn the CD...

Linux Terminal:~$ wodim dev=/dev/scd0 -v -data cd_image.iso

Network Configuration
https://help.ubuntu.com/11.10/serverguide/C/network-configuration.html

Applications - Discover Where Their Components Are Installed: How To
The first step below will help you identify the system name for the software, that is what the operating systems sees it as not what your call it. In this example we are using Adobe's Flash.

Linux Terminal:~$ sudo dpkg -l | grep flash

The returned out put will look similar to this:

Linux Terminal:~$ ii adobe-flashplugin 11.2.202.228-0oneiric1 Adobe Flash Player plugin version 11

Next:

Linux Terminal:~$ sudo dpkg -L adobe-flashplugin

The output generated will look similar to the following:

Linux Terminal:~$ /. /usr /usr/lib /usr/lib/xulrunner /usr/lib/xulrunner/plugins /usr/lib/xulrunner-addons /usr/lib/xulrunner-addons/plugins /usr/lib/mozilla /usr/lib/mozilla/plugins /usr/lib/iceape /usr/lib/iceape/plugins /usr/lib/iceweasel /usr/lib/iceweasel/plugins /usr/lib/firefox /usr/lib/firefox/plugins /usr/lib/midbrowser /usr/lib/midbrowser/plugins /usr/lib/adobe-flashplugin /usr/lib/adobe-flashplugin/libflashplayer.so /usr/share /usr/share/icons /usr/share/icons/hicolor /usr/share/icons/hicolor/32x32 /usr/share/icons/hicolor/32x32/apps /usr/share/icons/hicolor/32x32/apps/flash-player-properties.png /usr/share/icons/hicolor/22x22 /usr/share/icons/hicolor/22x22/apps /usr/share/icons/hicolor/22x22/apps/flash-player-properties.png /usr/share/icons/hicolor/24x24 /usr/share/icons/hicolor/24x24/apps /usr/share/icons/hicolor/24x24/apps/flash-player-properties.png /usr/share/icons/hicolor/16x16 /usr/share/icons/hicolor/16x16/apps /usr/share/icons/hicolor/16x16/apps/flash-player-properties.png /usr/share/icons/hicolor/48x48 /usr/share/icons/hicolor/48x48/apps /usr/share/icons/hicolor/48x48/apps/flash-player-properties.png /usr/share/pixmaps /usr/share/doc /usr/share/doc/adobe-flashplugin /usr/share/doc/adobe-flashplugin/copyright /usr/share/doc/adobe-flashplugin/changelog.Debian.gz /usr/share/pixmaps/flash-player-properties.png

Things To Do After Ubuntu Install
http://debianhelp.wordpress.com/2011/09/12/to-do-list-after-installing-ubuntu-11-10-aka-oneiric-ocelot/

ALSA + NVIDIA + ION + HDMI
Unmute all the S/PDIF + S/PDIF Default + S/PDIF 1.

Linux Terminal:~$ alsamixer

Test to make sure your hardware works first.

Linux Terminal:~$ aplay -D plughw:0,3 /usr/share/sounds/alsa/Noise.wav

Add the following contents to the file /etc/asound.conf.

pcm.!default { type plug slave.pcm { type hw card 0 device 3 } }

Retest it with the following command.

Linux Terminal:~$ aplay /usr/share/sounds/alsa/Noise.wav

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 'myip'="curl ifconfig.me" alias ping='ping -c3' alias pingg='ping -c3 www.google.co.uk' alias pingm='ping -c3 address of dsl modem' alias pings='ping -c3 address of internal server' alias rm='rm -iv' alias rav='rsync -a -v' alias get='get_iplayer/get_iplayer' alias install='sudo apt-get install' alias remove='sudo apt-get autoremove' alias search='sudo apt-cache search' alias update='sudo apt-get update' alias upgrade='sudo apt-get upgrade' alias uu='sudo apt-get update && sudo apt-get upgrade' alias uuf='sudo apt-get update && sudo apt-get dist-upgrade'

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

Dependencies: What Associated Packages Does A Programme Rely On?
First you will need to install an additional package, in a terminal:

sudo apt-get install apt-rdepends

Once installed in a terminal:

apt-rdepends

For example:

apt-rdepends reminnia

Most packages will output more data than the standard settings for the terminal will allow, in these instances you can use the pipe command:

apt-rdepends apache2 | more

apt-rdepends apache2 | less

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... :-)

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

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

sudo cp -r  /usr/share/icons

Keyboard Indicator
Allow you to add an indicator applet to the Gnome panel which will show whether your Caps, Scroll or Page Lock keys are inactive or active. It is also configurable to show only those keys you are interested in, for instance on my ThinkPad Edge I am only interested in the Caps Lock.

In a terminal:

sudo apt-get install lock-keys-applet killall gnome-panel

Right click the Gnome panel, click "Add to panel" and add the "Lock Keys" applet. To configure right-click on the applet and select 'Preferences'.

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 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 - Install GUI Configurator: How To
Out of the box Ubuntu does not support configuration of NotifyOSD's bubble, the following PPAs remedy this oversight:

The first PPA will install a patched version of NotifyOSD

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

The second PPA installs the GUI configurator:

Linux Terminal:~$  sudo add-apt-repository ppa:nilarimogard/webupd8 sudo apt-get update && sudo apt-get install notifyosdconfig

The resulting menu entry can be found in Gnome 2 in 'Applications --> Accessories --> NotifyOSD Configuration', in Unity just type NotifyOSD in the Launcher.

NotifyOSD - Keyboard Indicators (Caps/Num/Scroll Lock): How To
NOTE: This section is not yet completed...

The following has been duplicated from here, and will only work if you have undertaken the installation of the modified NotifyOSD from leolik.

Download the shell script here, use right click and 'Save link as...'.

Make the shell script executable

Copy the shell script to the main bin folder

Linux Terminal:~$  sudo cp ~/From_where_you_downloaded_it_to/lock_keys /bin

Open CompizConfig Settings Manager

Under the 'General' section click on 'Commands'

Under the 'Command' tab enter the following in to blank lines:  lock_keys caps lock_keys num lock_keys scrl 

Click on the Key Bindings tab

Link the corresponding Run Command # with the command from the previous tab  Click on Disabled Check Enabled Click Grab Key Combination Press the key 

NOTE: You may need to tick the box under 'Enable this plugin'

Close Settings Manager

Test

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:~$

Restricted Extras - Install: How To
terminal:~$ sudo apt-get install ubuntu-restricted-extras

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 - Create: How To
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 - Switch To: How To
Open a terminal, type:

sudo su - root

Enter the password for the user profile you are in.

Static IP Address: How To (up to 11.04)
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

Static IP Address: How To (11.10 onwards)
Fish

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 CPU Am I Running? How To Find Out
Linux Terminal:~$ uname -m

The above will give you a very basic idea or whether you are running a 32-bit or 64-bit CPU, the following will give you much more information.

Linux Terminal:~$ cat /proc/cpuinfo

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!

Links
Mindseeder's Ubuntu Tips

Ubuntu Hacks Book