An Ubuntu live CD can save a regular sysadmin alot of trouble. It boots an entire Ubuntu Linux system right off the CD, without touching the harddrive. It can then be used for backups without requiring the system to even have an operating system.

One-liner password generator Edit

Generates 40 sets of 12 characters of small and large caps alphanum characters and includes punctuation characters:

for i in `seq 1 40`; do tr -dc "[:alnum:][:punct:]" < /dev/urandom | head -c 12; echo \n; done

Join AD domain Edit

You can join your Ubuntu machine to an Active Directory domain as described in the AD article.

Pipe text to and from the clipboard Edit

You can pipe the output of ls to the clipboard:

ls | xclip -selection c

And then you can output the clipboard contents:

xclip -o -selection c

Encrypted boot partition Edit

In ubuntu 8.04 you can encrypt the system partition by installing from the alternate install cd. The installation guide will give you the option to encrypt the drive it installs to.

Install on a usb drive Edit

Restore a grub MBR Edit

The CLI way Edit

Find the partition that has the root of your linux installation (usually the only one with partition ID 83):

sudo fdisk -l

Mount it and install grub on the MBR (replace sda and sda1 with the appropriate in your case):

sudo mkdir /mnt/hd
sudo mount -t ext3 /dev/sda1 /mnt/hd
sudo grub-install --root-directory=/mnt/hd /dev/sda

Network speed and duplex Edit

Info Edit

Show the status of the network cards' current speed and duplex setting and whether it was auto-negotiated:

sudo mii-tool

Show each network cards capabilities:

sudo ethtool eth0; sudo ethtool eth1

Change speed and duplex Edit

Set eth0 to 10half manually (doesn't last a reboot):

ethtool -s eth0 speed 10 duplex half autoneg off

To set speed and duplex that will last a reboot, add the following to your /etc/network/interfaces in the stanza for your network card:

pre-up ethtool -s eth0 speed 10 duplex half autoneg off

Server monitorEdit

The CLI wayEdit

This small script counts the seconds of downtime (remember to set the IP address):

while [ true ]; do
 ping -W1 -c1 IP_address 1> /dev/null
 if [ $? -eq 0 ]; then
  echo Running...
  sleep 1
 else ((i++))
  echo Error. "Not running! Downtime: $i seconds"

Date format Edit

Gnome clock applet Edit

You can set the clock applet's format to something custom with these commands (this makes it the ISO standard date and time format - it follows PHP's strftime format):

gconftool-2 --set /apps/panel/applets/clock_screen0/prefs/custom_format --type string "%Y-%m-%d %H:%M"
gconftool-2 --set /apps/panel/applets/clock_screen0/prefs/format --type string "custom"

Unity clock applet Edit

Ubuntu 11.04 introduced Unity, which has different applets than Gnome. The date format can be set in a similar way to Gnome:

gsettings set com.canonical.indicator.datetime custom-time-format "'%F %H:%M'"
gsettings set com.canonical.indicator.datetime time-format "'custom'"

System setting Edit

You can change the default date format in Ubuntu to the ISO 8601 format.

  • First make sure the locale definition files are compiled:
sudo localedef -f UTF-8 -i en_DK en_DK.UTF-8
  • Then edit /etc/environment and add:

If you want to avoid the Setting locale failed error, when SSH'ing to servers without the en_DK.UTF-8 locale generated:

  • Comment out this line in /etc/ssh/ssh_config
SendEnv LANG LC_*

Your locale settings will then not be brought with you to remote servers.

SSL certificate Edit

Adding a self-signed certificate:

certutil -d sql:$HOME/.pki/nssdb -A -t "P,," -n <certificate nickname> -i <certificate filename>

Listing added certificates:

certutil -d sql:$HOME/.pki/nssdb -L

Deleting an added certificate:

certutil -d sql:$HOME/.pki/nssdb -D -n <certificate nickname>

Cursor size Edit

Set the cursor size with this command:

gsettings set org.gnome.desktop.interface cursor-size 64

Flush DNS cache Edit

This works on Ubuntu 18.04:

sudo systemd-resolve --flush-caches

See also Edit

External links Edit

Community content is available under CC-BY-SA unless otherwise noted.