More useful Ubuntu and Linux Mint tips and tricks for the desktop user.

Useful Linux commands and tips for Ubuntu users.

How to unlock the root account on Ubuntu and Linux Mint.

Use the passwd command to unlock the root account on Ubuntu and Linux Mint.

Use it like this:

sudo passwd root

Then type a new password for the root account. This will allow you to use the su command to get a root prompt.

Miscellaneous Linux commands that any Linux user would find useful.

The Linux command-line has some powerful features. The ability to filter the output of a command with grep(1) is very useful indeed. In the example below I am using the ls command and then filtering with grep.

$ ls -hula | grep conso**.wad

-rw-------  1 flynn flynn 2.4M 2012-07-12 22:42 consoleCopy.wad

Some incredible shell tricks. As seen in this posting: http://www.securitronlinux.com/bejiitaswrath/cispa-bill-still-a-threat-and-awesome-linux-shell-tricks/. Capitalising the first character of your username.

flynn@ubuntu:~/Documents$ echo -e ${LOGNAME^}
Flynn

And rendering the username in all caps.

flynn@ubuntu:~/Documents$ echo -e ${LOGNAME^^}
FLYNN

MSDOS styled command prompt for Linux. This is a controversial addition to your Linux system, but if you want this prompt then here it is.

PROMPT_COMMAND='export PWD_UPCASE="${PWD^^}"'
PS1='C:${PWD_UPCASE//\\//\\\\}> '

Using the df command and Listing the free space on your Linux system.

Using the Linux rename command and other useful commands.

How to use the text console on Linux to experience the Linux command-line: Linux Mint 13 text console usage.

How to install a vanilla kernel on a modern Linux distribution. Installing a kernel the vanilla way.

Some interesting Linux commands here: interesting and obscure Linux tips.

The ldd command for Linux when run against a Linux executable as I have, will return a list of the Dynamically Linked libraries that the program is linked against. This can be useful when debugging a program that you are trying to get running.

~$ ldd ./hello
	linux-vdso.so.1 =>  (0x00007fffb61ff000)
	libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007fedd9a55000)
	/lib64/ld-linux-x86-64.so.2 (0x00007fedd9e0c000)

Returning a list of all processes owned by your user.

~$ ps -ef | grep $LOGNAME
flynn     1603     1  0 Jul12 ?        00:00:00 /usr/bin/gnome-keyring-daemon --daemonize --login
flynn     1622  1476  0 Jul12 ?        00:00:00 /bin/sh /etc/xdg/xfce4/xinitrc -- /etc/X11/xinit/xserverrc
flynn     1655  1622  0 Jul12 ?        00:00:00 /usr/bin/ssh-agent /usr/bin/dbus-launch --exit-with-session /usr/share/xubuntu/session.sh
flynn     1658     1  0 Jul12 ?        00:00:00 /usr/bin/dbus-launch --exit-with-session /usr/share/xubuntu/session.sh
flynn     1659     1  0 Jul12 ?        00:00:02 //bin/dbus-daemon --fork --print-pid 5 --print-address 7 --session
flynn     1667     1  0 Jul12 ?        00:00:00 /usr/lib/xfce4/xfconf/xfconfd
flynn     1673  1622  0 Jul12 ?        00:00:32 xscreensaver -no-splash
flynn     1675  1622  0 Jul12 ?        00:00:00 xfce4-session
flynn     1681     1  0 Jul12 ?        00:03:39 xfwm4
flynn     1683     1  0 Jul12 ?        00:00:23 xfce4-panel
flynn     1685     1  0 Jul12 ?        00:00:16 Thunar --daemon
flynn     1687     1  0 Jul12 ?        00:00:08 xfdesktop
flynn     1690     1  0 Jul12 ?        00:00:00 xfsettingsd --force
flynn     1694     1  0 Jul12 ?        00:14:42 /usr/bin/pulseaudio --start --log-target=syslog
flynn     1696     1  0 Jul12 ?        00:00:00 /usr/lib/gvfs/gvfsd
flynn     1700     1  0 Jul12 ?        00:00:00 /usr/lib/policykit-1-gnome/polkit-gnome-authentication-agent-1
flynn     1704     1  0 Jul12 ?        00:00:00 /usr/lib/gvfs//gvfs-fuse-daemon /home/flynn/.gvfs
flynn     1715     1  0 Jul12 ?        00:00:00 /usr/lib/evolution/2.32/evolution-alarm-notify
flynn     1723     1  0 Jul12 ?        00:00:00 bluetooth-applet
flynn     1726  1694  0 Jul12 ?        00:00:00 /usr/lib/pulseaudio/pulse/gconf-helper
flynn     1729     1  0 Jul12 ?        00:00:04 /usr/lib/libgconf2-4/gconfd-2
flynn     1731     1  0 Jul12 ?        00:00:00 gnome-volume-control-applet
flynn     1740     1  0 Jul12 ?        00:00:00 nm-applet --sm-disable
flynn     1744     1  0 Jul12 ?        00:00:01 /usr/bin/python /usr/share/system-config-printer/applet.py
flynn     1747     1  0 Jul12 ?        00:00:26 update-notifier
flynn     1752     1  0 Jul12 ?        00:00:00 zeitgeist-datahub
flynn     1764     1  0 Jul12 ?        00:00:00 /usr/bin/python /usr/bin/zeitgeist-daemon
flynn     1771     1  0 Jul12 ?        00:00:00 xfce4-power-manager
flynn     1774     1  0 Jul12 ?        00:00:01 xfce4-settings-helper
flynn     1776     1  0 Jul12 ?        00:00:00 xfce4-volumed
flynn     1785     1  0 Jul12 ?        00:00:01 /usr/lib/gvfs/gvfs-gdu-volume-monitor
flynn     1787  1683  0 Jul12 ?        00:00:01 /usr/lib/xfce4/panel/wrapper /usr/lib/xfce4/panel/plugins/libsystray.so 4 29360193 systray Notification Area Area where notification icons appear 
flynn     1800  1683  0 Jul12 ?        00:00:01 /usr/lib/xfce4-indicator-plugin/xfce4/panel-plugins/xfce4-indicator-plugin  5 29360194 indicator Indicator Plugin An indicator of something that needs your attention on the desktop 
flynn     1803  1683  0 Jul12 ?        00:00:00 /usr/lib/xfce4/panel/wrapper /usr/lib/xfce4/panel/plugins/libxfsm-logout-plugin.so 9 29360196 xfsm-logout-plugin Session Menu Shows a menu with options to lock the screen, suspend, shutdown, or log out 
flynn     1806  1683  0 Jul12 ?        00:00:00 /usr/lib/xfce4/panel/wrapper /usr/lib/xfce4/panel/plugins/libthunar-tpa.so 24 29360206 thunar-tpa Trash Applet Display the trash can 
flynn     1807  1764  0 Jul12 ?        00:00:00 /bin/cat
flynn     1809  1764  0 Jul12 ?        00:00:00 [zeitgeist-datah] 
flynn     1816     1  0 Jul12 ?        00:00:00 /usr/lib/gvfs/gvfsd-trash --spawner :1.10 /org/gtk/gvfs/exec_spaw/0
flynn     1818     1  0 Jul12 ?        00:00:00 /usr/lib/gvfs/gvfs-gphoto2-volume-monitor
flynn     1820     1  0 Jul12 ?        00:00:01 /usr/lib/gvfs/gvfs-afc-volume-monitor
flynn     1824     1  0 Jul12 ?        00:00:00 /usr/lib/indicator-application/indicator-application-service
flynn     1826     1  0 Jul12 ?        00:00:00 /usr/lib/indicator-messages/indicator-messages-service
flynn     1828     1  0 Jul12 ?        00:00:01 /usr/lib/indicator-sound/indicator-sound-service
flynn     1852     1  0 Jul12 ?        00:01:12 /usr/bin/python /usr/lib/ubuntuone-client/ubuntuone-syncdaemon
flynn     1863     1  0 Jul12 ?        00:00:00 /usr/lib/gvfs/gvfsd-network --spawner :1.10 /org/gtk/gvfs/exec_spaw/1
flynn     1886     1  0 Jul12 ?        00:00:00 /usr/lib/gvfs/gvfsd-dnssd --spawner :1.10 /org/gtk/gvfs/exec_spaw/3
flynn     1991     1  0 Jul12 ?        00:00:00 /usr/bin/gnome-screensaver --no-daemon
flynn     4427  1683  0 Jul12 ?        00:00:00 bash /usr/bin/banshee --redirect-log --play-enqueued
flynn     4432  4427  0 Jul12 ?        00:05:47 banshee /usr/lib/banshee/Banshee.exe --redirect-log --play-enqueued
flynn     4448     1  0 Jul12 ?        00:00:00 /usr/lib/gnome-settings-daemon/gnome-settings-daemon
flynn     4462     1  0 Jul12 ?        00:00:00 /usr/bin/python /usr/lib/ubuntu-sso-client/ubuntu-sso-login
flynn     4528     1  0 Jul12 ?        00:00:00 /usr/lib/gvfs/gvfsd-metadata
flynn     4794     1  0 Jul12 ?        00:00:02 /usr/lib/bamf/bamfdaemon
flynn    13250  1205  0 13:52 tty2     00:00:00 -bash
flynn    13450  1206  0 13:54 tty3     00:00:00 -bash
flynn    13870     1  0 18:20 ?        00:00:00 /usr/lib/gvfs/gvfsd-http --spawner :1.10 /org/gtk/gvfs/exec_spaw/4
flynn    15025     1  0 21:54 ?        00:00:08 transmission-gtk
flynn    15165 13450  0 21:57 tty3     00:00:00 mocp
flynn    15166 15165  1 21:57 ?        00:00:11 mocp
flynn    15660 13250  0 22:10 tty2     00:00:00 mc
flynn    15661 15660  0 22:10 ?        00:00:00 cons.saver /dev/tty2
flynn    15662 15660  0 22:10 pts/0    00:00:00 bash -rcfile .bashrc
flynn    15727  1673  0 22:10 ?        00:00:00 glmatrix -root
flynn    15738 15660  0 22:12 tty2     00:00:00 /bin/sh /usr/bin/sensible-editor /home/flynn/Documents/Code/ldd.text
flynn    15746 15738  0 22:12 tty2     00:00:00 /usr/bin/mcedit /home/flynn/Documents/Code/ldd.text
flynn    15747 15746  0 22:12 ?        00:00:00 cons.saver /dev/tty2
flynn    15748 15746  0 22:12 tty2     00:00:00 /bin/sh /tmp/mc-flynn/mcusriqGpTv
flynn    15749 15748  0 22:12 tty2     00:00:00 ps -ef
flynn    15750 15748  0 22:12 tty2     00:00:00 grep flynn

Counting how much disk space files in a directory are taking up.

flynn@ubuntu:/media/Elements/Movies$ du -ackh | tail -n 1
65G	total

Viewing only certain files in a folder. Using the ls command and wildcards.

~$ ls -hula ../../Desktop/*.jpg
-rw-r--r-- 1 flynn flynn  28K 2012-07-10 21:39 ../../Desktop/0817-Australia-collar-bomb-suspect_full_600.jpg
-rw-r--r-- 1 flynn flynn  99K 2012-07-11 22:45 ../../Desktop/101031unknown1b.jpg
-rw-r--r-- 1 flynn flynn 3.0M 2012-07-09 21:29 ../../Desktop/1341805787928.jpg
-rw-r--r-- 1 flynn flynn 371K 2012-07-10 21:52 ../../Desktop/1341828408233.jpg
-rw-r--r-- 1 flynn flynn 2.7M 2012-07-11 22:45 ../../Desktop/1341907701198.jpg
-rw-r--r-- 1 flynn flynn 635K 2012-07-11 22:45 ../../Desktop/1342007983380.jpg
-rw-r--r-- 1 flynn flynn  59K 2012-07-11 22:45 ../../Desktop/1342008134206.jpg
-rw-r--r-- 1 flynn flynn 205K 2012-07-11 22:45 ../../Desktop/1342008295830.jpg
-rw-r--r-- 1 flynn flynn 204K 2012-07-12 22:53 ../../Desktop/1342096201790.jpg
-rw-r--r-- 1 flynn flynn  61K 2012-07-11 22:45 ../../Desktop/640x480, wretched_and_filthy_640_25.jpg
-rw-r--r-- 1 flynn flynn  52K 2012-07-11 22:45 ../../Desktop/iphone-3gs-camera.jpg
-rw-r--r-- 1 flynn flynn 949K 2012-07-10 21:36 ../../Desktop/iphone-insides.jpg
-rw-r--r-- 1 flynn flynn 117K 2012-07-11 22:45 ../../Desktop/iphone-insides-motherboard-sml.jpg
-rw-r--r-- 1 flynn flynn 1.3M 2012-07-10 21:37 ../../Desktop/iphone-rear-of-lcd-screen.jpg
-rw-r--r-- 1 flynn flynn 150K 2012-07-11 22:45 ../../Desktop/iphone-rear-of-lcd-screen-sml.jpg
-rw-r--r-- 1 flynn flynn 1.0M 2012-07-09 21:29 ../../Desktop/london-stadium.jpg
-rw-r--r-- 1 flynn flynn  44K 2012-07-11 22:45 ../../Desktop/oap_home4.jpg
-rw-r--r-- 1 flynn flynn  59K 2012-07-12 22:46 ../../Desktop/wretched_and_filthy_640_20.jpg
-rw-r--r-- 1 flynn flynn  60K 2012-07-11 22:45 ../../Desktop/wretched_and_filthy_640_22.jpg

Printing out various information about your system easily. Seeing how much memory your system has and how much has been used up.

flynn@ubuntu:~$ vmstat -s
      5912404 K total memory
      5390012 K used memory
      2066764 K active memory
      2935616 K inactive memory
       522392 K free memory
      1481900 K buffer memory
      3049064 K swap cache
      2559996 K total swap
         7096 K used swap
      2552900 K free swap
      1107650 non-nice user cpu ticks
        87719 nice user cpu ticks
       313550 system cpu ticks
     23468879 idle cpu ticks
        24232 IO-wait cpu ticks
            8 IRQ cpu ticks
        64063 softirq cpu ticks
            0 stolen cpu ticks
      4082004 pages paged in
      3292808 pages paged out
            0 pages swapped in
         1774 pages swapped out
     32197903 interrupts
    158362281 CPU context switches
   1342080281 boot time
        48176 forks

Viewing information about a zipfile with the Linux command-line. Using the zipinfo command.

flynn@ubuntu:~/Downloads$ zipinfo cratnew.zip
Archive:  cratnew.zip
Zip file size: 189895 bytes, number of entries: 2
-rw-r--r--  2.3 unx   531385 bx defN 07-Jul-15 18:54 cratnew.wad
-rw-r--r--  2.3 unx     1752 tx defN 07-Jul-15 18:58 cratnew.txt
2 files, 533137 bytes uncompressed, 189609 bytes compressed:  64.4%

To view a list of the partitions mounted on your machine, you may use either of these commands. Firstly; the cat /proc/partitions command.

flynn@ubuntu:~/Documents$ cat /proc/partitions
major minor  #blocks  name

   8        0  488386584 sda
   8        1     440320 sda1
   8        2  358400000 sda2
   8        3  126976000 sda3
   8        4          1 sda4
   8        5    2560000 sda5
   8       16  488386584 sdb
   8       17  225280000 sdb1
   8       18   33792000 sdb2
   8       19          1 sdb3
   8       21  229238784 sdb5
  11        0    5930586 sr0
   8       32 1953514584 sdc
   8       33 1953511424 sdc1
flynn@ubuntu:~/Documents$

Or the mount(1) command, this will also list the mounted partitions on your system.

flynn@ubuntu:~/Documents$ mount
/dev/sdb1 on / type xfs (rw)
proc on /proc type proc (rw,noexec,nosuid,nodev)
none on /sys type sysfs (rw,noexec,nosuid,nodev)
fusectl on /sys/fs/fuse/connections type fusectl (rw)
none on /sys/kernel/debug type debugfs (rw)
none on /sys/kernel/security type securityfs (rw)
none on /dev type devtmpfs (rw,mode=0755)
none on /dev/pts type devpts (rw,noexec,nosuid,gid=5,mode=0620)
none on /dev/shm type tmpfs (rw,nosuid,nodev)
none on /var/run type tmpfs (rw,nosuid,mode=0755)
none on /var/lock type tmpfs (rw,noexec,nosuid,nodev)
binfmt_misc on /proc/sys/fs/binfmt_misc type binfmt_misc (rw,noexec,nosuid,nodev)
gvfs-fuse-daemon on /home/flynn/.gvfs type fuse.gvfs-fuse-daemon (rw,nosuid,nodev,user=flynn)
/dev/sda1 on /media/e01436e0-4aa5-420b-94aa-0b35bd00020e type ext4 (rw,nosuid,nodev,uhelper=udisks,commit=0,commit=0)
/dev/sda3 on /media/a6f66737-afea-48c3-9694-f6da22904d37 type ext4 (rw,nosuid,nodev,uhelper=udisks,commit=0,commit=0)
/dev/sdb2 on /media/3fabc97d-c76a-4922-8705-5536e89cfd21 type ext4 (rw,nosuid,nodev,uhelper=udisks,commit=0,commit=0)
/dev/sdb5 on /media/52d826a6-7de5-45db-b693-dd7c7e82af37 type ext4 (rw,nosuid,nodev,uhelper=udisks,commit=0,commit=0)
/dev/sda2 on /media/c84b3630-79a5-4ab3-85a5-f50bc23a3da9 type xfs (rw,nosuid,nodev,uhelper=udisks)
/dev/sdc1 on /media/Elements type fuseblk (rw,nosuid,nodev,allow_other,blksize=4096,default_permissions)
/dev/sr0 on /media/300 type udf (ro,nosuid,nodev,uhelper=udisks,uid=1000,gid=1000,iocharset=utf8,umask=0077,dmode=0500)

Setting up Ubuntu for multimedia playback.

DVD playback on Linux.

The best way to get the right program to playback DVD discs is with smplayer, type this command to get it: sudo apt-get install smplayer. To get DVD playback in Ubuntu Karmic Koala, you need to  download the libdvdcss library and compile and install with ./configure && make && make install. Then
you need the libdvdread library and repeat the process with that tarball and then you can play back DVD discs with smplayer. The libdvdread library would not work on my system after I installed the libdvdcss DVD decryption library, so I built it again from vanilla source and that fixed it. The libdvdcss library is not supplied by default with most Linux distributions, but installing it is easy. The overall impression of the Ubuntu Karmic Koala distribution is that is quite polished and I do not bother with the accelerated 3D graphics drivers like Nvidia but I am sure they would be easy to install. I have found it easier when I have tried them, that it is easier to download the drivers from the  Nvidia website and compile them from source. That is a good way, but is not always successful with a vanilla kernel but I am happy with the distribution kernel as the driver support is sufficient for my needs and I get the automatic updates from Ubuntu to keep my system up to date.

Here is a comments thread with some varied experiences with early releases of Ubuntu Karmic Koala.
http://forums.theregister.co.uk/forum/6/2009/11/03/karmic_koala_frustration/
.

Setting up xorg correctly.

You might have noticed that the xorg.conf is missing, this is because xorg can auto-detect everything and does not need it, but if like me you want one, then read on… You need to press Ctrl->Alt-F2 to switch to a text console and login and then type: sudo /etc/init.d/gdm stop to stop the gdm process and then type Xorg -configure to generate a Xorg configuration file in /root. You can
then copy this file into /etc/X11 as xorg.conf and then setup your resolutions in the file. My xorg.conf for Ubuntu Karmic is below. I had problems with my graphics card and took it out and booted without it and the graphics would not work until I setup a xorg.conf file. My integrated graphics chipset works perfectly and is quite fast, but it was not going to work until I set it up manually. Now I have a fast 1280×1024 24BPP desktop.

Section "ServerLayout"
	Identifier     "X.org Configured"
	Screen      0  "Screen0" 0 0
	InputDevice    "Mouse0" "CorePointer"
	InputDevice    "Keyboard0" "CoreKeyboard"
EndSection

Section "Files"
	ModulePath   "/usr/lib/xorg/modules"
	FontPath     "/usr/share/fonts/X11/misc"
	FontPath     "/usr/share/fonts/X11/cyrillic"
	FontPath     "/usr/share/fonts/X11/100dpi/:unscaled"
	FontPath     "/usr/share/fonts/X11/75dpi/:unscaled"
	FontPath     "/usr/share/fonts/X11/Type1"
	FontPath     "/usr/share/fonts/X11/100dpi"
	FontPath     "/usr/share/fonts/X11/75dpi"
	FontPath     "/var/lib/defoma/x-ttcidfont-conf.d/dirs/TrueType"
	FontPath     "built-ins"
EndSection

Section "Module"
	Load  "dri"
	Load  "extmod"
	Load  "glx"
	Load  "dbe"
	Load  "record"
	Load  "dri2"
EndSection

Section "InputDevice"
	Identifier  "Keyboard0"
	Driver      "kbd"
EndSection

Section "InputDevice"
	Identifier  "Mouse0"
	Driver      "mouse"
	Option	    "Protocol" "auto"
	Option	    "Device" "/dev/input/mice"
	Option	    "ZAxisMapping" "4 5 6 7"
EndSection

Section "Monitor"
	#DisplaySize	  320   240	# mm
	Identifier   "Monitor0"
	VendorName   "PHL"
	ModelName    "PHILIPS 107B"
	HorizSync    30.0 - 92.0
	VertRefresh  50.0 - 160.0
	Option	    "DPMS"
EndSection

Section "Device"
        ### Available Driver options are:-
        ### Values: <i>: integer, <f>: float, <bool>: "True"/"False",
        ### <string>: "String", <freq>: "<f> Hz/kHz/MHz"
        ### [arg]: arg optional
        #Option     "SWcursor"           	# [<bool>]
        #Option     "HWcursor"           	# [<bool>]
        #Option     "NoAccel"            	# [<bool>]
        #Option     "ShadowFB"           	# [<bool>]
        #Option     "UseFBDev"           	# [<bool>]
        #Option     "Rotate"             	# [<str>]
        #Option     "VideoKey"           	# <i>
        #Option     "FlatPanel"          	# [<bool>]
        #Option     "FPDither"           	# [<bool>]
        #Option     "CrtcNumber"         	# <i>
        #Option     "FPScale"            	# [<bool>]
        #Option     "FPTweak"            	# <i>
        #Option     "DualHead"           	# [<'bool>]
	Identifier  "Card0"
	Driver      "nv"
	VendorName  "nVidia Corporation"
	BoardName   "NVCrush11 [GeForce2 MX Integrated Graphics]"
	BusID       "PCI:1:0:0"
EndSection

Section "Screen"
	Identifier "Screen0"
	Device     "Card0"
	Monitor    "Monitor0"
	SubSection "Display"
		Viewport   0 0
		Depth     1
	EndSubSection
	SubSection "Display"
		Viewport   0 0
		Depth     4
	EndSubSection
	SubSection "Display"
		Viewport   0 0
		Depth     8
	EndSubSection
	SubSection "Display"
		Viewport   0 0
		Depth     15
	EndSubSection
	SubSection "Display"
		Viewport   0 0
		Depth     16
	EndSubSection
	SubSection "Display"
		Viewport   0 0
		Modes     "1280x1024" "1024x768" "800x600"
		Depth     24
	EndSubSection
EndSection

You should not have to go to all this trouble to set up your graphics, you should be able to use something like this: http://en.opensuse.org/SaX2. That can be run from the framebuffer console and then you can setup all of your X hardware like mouse, keyboard and your monitor. I used to use this when I was running Suse 10.1. It is very easy to use and configure your xorg.conf file to get it just right, and you can test the desktop resolution before you apply it.

Cool Linux screensavers I enjoy that Windows users might never see. Not even
in LongHorn.

Xearth. http://www.cs.colorado.edu/~tuna
/xearth/

GlMatrix. A screensaver that renders 3D falling code just like the beginning sequence in the first Matrix Film.

OpenGl Bouncing Cow. A Cow on a Trampoline. Need I say more?

OpenGl Flying Toasters. Shiny chrome toasters. Flying toast. A great combination.

3D Rendered Fractal Mountains. http://www.epcc.ed.ac.uk/~spb/xmountains/

For more information on Xscreensaver, including updates: visit http://www.jwz.org/xscreensaver/.