Showing posts with label desktop. Show all posts
Showing posts with label desktop. Show all posts

Tuesday, August 25, 2009

command-not-found in Ubuntu 9.04 and 9.10

command-not-found is a special package in ubuntu that give you some extra information when you type a command that is not installed on the command line. It will look inside the package database and suggest a possible package to install so that the command can be run. command-not-found is installed automatically when you install ubuntu 9.04.

For example , I got this when I typed jed.
$ jed
The program 'jed' is currently not installed. You can install it by typing:
sudo apt-get install jed
bash: jed: command not found

However when I type

$ jid
bash: jid: command not found

The command -not-found hook neatly searches the package database and suggest a possible package for installation. The upcoming release of Ubuntu ( 9.10 aka Karmic Koala) will have spell checking incorporated into the command -not-found feature . It will suggest a list of possible packages even if you make a spelling mistake. See the following screen shot of my Karmic Koala Alpha 3.

Saturday, August 22, 2009

Reset a forgotten root password with a live CD

If you have forgotten the root password of a system, you can very easily reset it with a live CD
Any live Linux cd from standard Linux distros such a ubuntu , knoppix etc can be used.

Boot the system with the live CD
Open a terminal and use dmesg command to find out the hard disk.
The ide hard disk are generally named as hda, hdb etc. SATA and SCSI disks are named sda sdb etc. My SATA hard disk is detected as below.

[ 3.206832] sda: sda1 sda2 sda3 sda4 <>
[ 3.266679] sd 0:0:0:0: [sda] Attached SCSI disk

The above hard disk has several partitions. sda2 , sda2 ,sda3 are primary partitions , sda4 is divided into several logical partitions. You have to find out where your root partitions is mounted.
You can use cfdisk to find out the partitions.
$sudo cfdisk /dev/sda

I am getting the following screen .





You can examine the screen and find out the Linux partitions . If you have multiple installations , this can be tricky. You can quit from cfdisk and return to terminal. Now, try to mount the desired partition into some directory. ( Assuming that you Linux partition is /dev/sda2 , the following commands are described.)

Aquire root powers on the terminal with ( in the case of ubuntu live cd which I use)

$sudo su
 # mount /dev/sda2  /mnt/  
Now, chroot to /mnt
  #  chroot /mnt
Change the password

# passwd

Next unmount the partition and enjoy .

# umount /mnt

Wednesday, August 19, 2009

Replacing the default screen shot utility on ubuntu with shutter

Shutter, according to its website is a feature full screen shot program. As a tech blogger experimenting with GNU/Linux and its derivatives, it offers me a number of handy features. In fact, I have replaced it as my default screen shot tool. When I press Print Screen on my keyboard,shutter pops up and does a nice job.

Installation.

The shutter website hosts a step by step installation tutorial for graphical installation on Ubuntu. If you are oriented towards command line, follow these steps

1) Import the GPG key
$ sudo wget -q http://shutter-project.org/shutter-ppa.key -O- | sudo apt-key add -
2) Add the PPA repository--- to /etc/apt/sources.list
deb http://ppa.launchpad.net/shutter/ppa/ubuntu jaunty main

( Replace jaunty with your version of ubuntu)

3) Install shutter
$ sudo apt-get update
$ sudo apt-get install shutter

Features

Shutter offers lot of features for a blogger. Some of them are,
  • take a screen shot of your complete desktop, a rectangular area or capture a website
  • take screen shot directly or with a specified delay time
  • save the screen shots to a specified directory and name them in a convenient way (using special wild-cards)
  • Shutter is fully integrated into the Gnome Desktop (TrayIcon etc.)
  • generate thumbnails directly when you are taking a screenshot and set a size level in %
  • Shutter session collection
    • keep track of all screenshots during session
    • copy screeners to clipboard
    • print screenshots
    • delete screenshots
    • rename your file
  • upload your files directly to Image-Hosters (e.g. http://ubuntu-pics.de), retrieve all the needed links and share them with others
  • edit your screenshots directly using the embedded drawing tool

Making shutter the default screen shot tool on Ubuntu.
Assuming that you are using Genome desktop on ubuntu, you can set Print Screen and Alt-Print Screen can be
configured to launch shutter as below.
a) Open shutter
b) Select Edit->preferences from the menu
c) Click on behavior tab . See the screen shot below.




d) Enable Gnome Key binding by ticking the check boxes.

Monday, August 17, 2009

Using multiple window managers with nested Xserver

I use gnome as my default desktop at home and at office. However, my machines have alternate desktop environment such as kde or xfce installed. I use it to test out features of these environment. The normal way to switch to a different desktop is to log out from the current desktop , select a new session from the gdm login window and login again. However, it is possible to open a new desktop environment in a virtual console using xnest nested xserver.

Installation

$ sudo apt-get install xnest

Using Xnest to run another window manager.

Method 1
Xnest server can be started from a terminal as below


Xnest :1 -ac &


See the screen shot below. The :1 above indicates virtual X display numbered 1. You can also try other numbers.



Now on the terminal , Type the following command.
export DISPLAY=:1

The above line exports the variable DISPLAY to :1. Now you can open a terminal in the Xnest window by typing xterm & in the terminal. See the screen shot below.



Now try to start up a window manager such as icewm by typing icewm inside the xterm.


I could start icewm and fluxbox and kde like this. However, trying to start gnome-session resulted in some error. I am yet to find out the reason .


Method 2
This method uses gdmflexiserver . gdmflexiserver is a part of gdm and it is used to run gdm session on demand on a virtual terminal.

You can start it to give a gdm login prompt as below.

$ gdmflexiserver -n


You will get a new virtual X with a gdm login screen. See the picture below.




You can log in as a different user using a different session from the above screen. ( All the screen shots were taken on ubuntu 8.10)

Sunday, August 9, 2009

Exploring Ubuntu Recovery Mode

Today, I did a fresh installation of Ubuntu 9.04 inside virtual box. My original idea was to play with sudoers and sudo command. I edited /etc/sudoers and logged out. Next time I tried to sudo , I go some parse error in /etc/sudoers. I was stuck . I needed sudo for modifying the file. But sudo was preventing me because of the error.

Then, I remembered about the recovery mode. Rebooted the machine and I pressed escape to get the standard grub screen as shown below.


Selecting recovery mode showed the following screens. ( The second figure below shows the remaining part of the recovery screen which is hidden from the first screen.)




I selected drop to a root shell. It allowed me to enter root account with out a password. I fixed my /etc/sudoers and my problem was gone.

Later I rebooted again and re-entered the recovery mode again to find out what capabilities it offers.

The recovery screen offers you the following menu entries on ubuntu 9.04 .

a) Try to make free space - this is useful if your machine is stuck for the want of free disk space.
b) Dpkg - If you select this option you can repair broken packages. Very useful ,if the system is stuck after a package installation.
c) fsck - if the system is stuck with file system error you can try this option.
d) grub - You can update the grub boot loader from this option.
e) netroot - Your TCP/IP network settings will be enabled and system will drop to a root shell.
This option is useful if you are trouble shooting network related issues.
f) root- Plain old root shell . Suitable for editing config files.
g) xfix - This option will try to reconfigure your X window system

Friday, August 7, 2009

Setting up automatic login in ubuntu

I was installing Ubuntu at a friends computer today. He wanted to use the computer with out the login/password prompt as it was a home PC . I did the following steps to achieve this.
Click on System ->Administration-Login Window.

You will get a screen like this.



Click on security and check the enable automatic login check box.


Select the user name a automatic log in.

The login preferences window offers several other options. For example, you can setup timed logins. This will allow you to login using user name and password with in a specified time.If you don't do this the user name specified will be automatically logged.

Also, if you are enabling the system administrator account "root" , you can allow him to login to the GUI by ticking the appropriate option.

Monday, August 3, 2009

Enhancing contextual menus on Ubuntu Desktop

Ubuntu desktop uses Gnome and its default desktop. You can add several interesting features to your contextual menus. ( You get a contextual menu when you right click on an object.). Let us see how we can add a simple script to the contextual menu.
There is a special directory ( .gnome2/nautilus-scripts/ ) inside your home folder into which you can put your custom scripts. Any script you place in that location can be accessed by right-clicking on a file or window and selecting it from the Scripts sub menu. (The Scripts menu item will be visible only if you have some valid scripts installed.

Let us try to open a terminal from the contextual menu. Change to the scripts directory. ( Note that .gnome is a hidden directory, try control -h in nautilus to see hidden files. )

$ cd ~/.gnome2/nautilus-scripts/

Create the following script

Code:
 #!/bin/sh
gnome-terminal
Save the file as myterminal
Change the permission of the file and make it executable

$ chmod u+x myterminal

Now right click on the contextual menu. You should get it as below.





When you execute a contextual menu script , a number of environment variables are passed to the script from nautilus. For example, if you select some files and then right click and select a script , the list of selected files will be passed to the script as an environment variable . You can use this variable inside the script for further processing.

Some of the variables passed are.

NAUTILUS_SCRIPT_SELECTED_FILE_PATHS
Newline-delimited paths for selected files if they are local
NAUTILUS_SCRIPT_SELECTED_URIS
Newline-delimited URIs for selected files
NAUTILUS_SCRIPT_CURRENT_URI
URI for current location
NAUTILUS_SCRIPT_WINDOW_GEOMETRY
Position and size of the current window

Here is a bare minimum example with which you can try out the use of environment variable.

Suppose you want to open a terminal and change to a particular directory, you can put the following code in nautilus-scripts directory. ( There is no error checking).

Code:
 #!/bin/sh

mydir=$NAUTILUS_SCRIPT_SELECTED_FILE_PATHS
if [ -d $mydir ]; then
cd $mydir
gnome-terminal
exit
fi

Now right click and select the script. Your terminal will open with the selected directory as the working directory.

There are a number of nautilus scripts available on the internet. In the ubuntu 9.04 repository, the following script collections are available.
nautilus-script-audio-convert - A nautilus audio converter script
nautilus-script-collection-svn - Nautilus subversion management scripts

You can also get lot of useful scripts from http://g-scripts.sourceforge.net/.