Ubuntu: Generic Hints Tweaks and Tips

BASH Command Line Smart Completion: How To Enable
Edit the following file and uncomment the lines shown in bold below...

sudo nano /etc/bash.bashrc

'''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;

sudo apt-get autoclean

To clear all downloaded packages;

sudo apt-get clean

Command Line Aliases: How To Add/Edit
Open a terminal and edit the .bashrc file

nano ~/.bashrc ... alias ll='ls -lah' alias la='ls -A' alias l='ls -CF' alias ping='ping -c3' alias rm='rm -iv'

Reload the file...

source ~/.bashrc

To check...

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
To fully enable DVD Menu support open a terminal and type:

sudo apt-get install libdvdread sudo /usr/share/doc/libdvdread4/install-css.sh

Generate A List Of Installed Packages And Use It To Reinstall Packages: How To
Make the list, open a terminal and run the following commands:

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.

Install Ubuntu on another PC.

When you have finished and rebooted, run the following commands to update...

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

dpkg --set-selections < ubuntu-files sudo dselect

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

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:

Open a terminal and run the following commands:

gconftool --recursive-unset /apps/panel

Then enter the next command:

rm -rf ~/.gconf/apps/panel

And enter one more command:

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"

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

Installing OpenOffice 3.2
** NEW METHOD **

System --> Administration --> Software Sources --> 3rd Tab [Updates] --> Ubuntu Updates --> Tick 'Proposed Updates'

Click Close. This will automatically start a system software update. Follow the prompts as normal.

Login Sound: How To Disable
 Method One 

Open a terminal, type:

sudo -u gdm gconftool-2 --set /desktop/gnome/sound/event_sounds --type bool false

 Method Two 

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

Find and untick 'GNOME Login Sound' entry

Network Card Change From DHCP to Fixed IP Address: How To
Open a 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

After reboot open a terminal and type:

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

Panel Icons And Applets: How To Change The Defaults For A New User
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...

sudo update-gconf-defaults

Reboot and add a new user to test.

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.

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

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/

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