Searching filesystem from command line

There are several commands available on the command line to locate files and folders on the file system. This article reviews three of them, viz whereis ,locate. find.

1) whereis
This command can search for  the binary, source, and manual page files for a comand

$ whereis  whereis
whereis: /usr/bin/whereis /usr/share/man/man1/whereis.1.gz

2) locate:   locate uses a database created by an updatedb to efficiently locate files. Works great, assuming your database is updated often enough to be reasonable upto date. Most boxes using locate have the updatedb occuring in cron.  On my ubuntu box, I got a long list of files when I tried to locate  command.   RTFM locate

$locate locate

3)  find: find is perhaps one of the most powerful commands there is.   However, find is slow compared to locate as it  recursively search the paths supplied to  it.

The syntax of find is specified like this.

find path-list expression

It may look rather cryptic. 
Even though the man page lists only three  parts for the command as above, 
for simplicity  we can imagine  that  find  syntax  is havng  four fields.               
1 2 3 4
find starting point find which files action on result

You can formulate your find command based on the above table. For example,
if you want to find all  avi files in a folder named movies

1 2 3 4
find movies -name “*.avi” -print
$find  movies   -name "*.avi"  -print

Here are some examples you can try

a) to find all directories on the system whose permissions of 777

$        find / \( -type d -a -perm -777 \)     -print

b) find all core files in home directories and remove them

$         find /home -name core -exec rm {}     \;


c) find all files owned by a particular user no matter whose home directory they are in:

$       find /home -user      -print

d) find all files that have been modified (or had their modification time changed) in the last 30 days:

$      find / -mtime -30 -print

e) find all tmp files older than 30 days and remove

$ find /dirpath \( -name \*.tmp -a -mtime     +30 \) -exec rm {} \;

The man page of find has several other option that you can try.

Overview of Xrandr

I bought a new monitor at home and added a second monitor in the office, so I had a lot to do with the graphics of my Linux setup. What do you use in these cases? My preferred tool for all these operations is certainly xrandr.

In particular I’m used to use it from the command line version and after doing some tests using the syntax that i’ve found in the startup of the graphic environment.

In this article we will see some common use case.

The X Resize, Rotate and Reflect Extension (RandR) allows clients to dynamically change X screens, so as to resize, rotate and reflect the root window of a screen. The initial X11 design did not anticipate the need for dynamic resizing and it was necessary to restart the X server to bring about the changes. However, changing the screen resolution on the fly without changing the desktop size had been available under XFree86 since the beginning. RandR extension framework brought the ability to change display characteristics without restarting the X session. The extension framework allows laptops and handheld computers to change their screen size to drive external monitors at different resolutions than their built in screens.

If one’s desktop environment doesn’t provide a graphical tool for interfacing with this functionality, the xrandr command line tool may be used.

Most Linux distributions have the xrandr package in their repository, so you can install it using your package manager for ubuntu:

aptitude install libxrandr2


First check what version you are using:

#xrandr -v
xrandr program version       1.3.3
Server reports RandR version 1.3

In my example I will always use the version 1.3, some features may not work on former version.


To find out what monitors are connected you can use the query command with the following:

#xrandr -q
Screen 0: minimum 320 x 200, current 1440 x 900, maximum 4096 x 4096
VGA-0 connected 1440x900+0+0 (normal left inverted right x axis y axis) 476mm x 268mm
   1920x1080      60.0 +
   1600x1200      65.0     60.0
   1680x1050      69.9     60.0
   1600x1024      60.2
   1400x1050      74.8     70.0     60.0     60.0
   1280x1024      75.0     60.0
   1440x900       75.0*    59.9
   1280x960       60.0
   1360x768       60.0     59.8
   1280x800       74.9     59.8
   1152x864       75.0     75.0     70.0     60.0
   1280x768       74.9     59.9
   1024x768       75.1     75.0     70.1     60.0
   832x624        74.6
   800x600        72.2     75.0     60.3     56.2
   848x480        60.0
   640x480        72.8     75.0     72.8     75.0     66.7     60.0     59.9     59.9
   720x400        70.1
DVI-0 connected 1440x900+0+0 (normal left inverted right x axis y axis) 476mm x 268mm
   1920x1080      60.0 +
   1600x1200      65.0     60.0
   1680x1050      69.9     60.0
   1600x1024      60.2
   1400x1050      74.8     70.0     60.0     60.0
   1280x1024      75.0     60.0
   1440x900       75.0*    59.9
   1280x960       60.0
   1360x768       60.0     59.8
   1280x800       74.9     59.8
   1152x864       75.0     75.0     70.0     60.0
   1280x768       74.9     59.9
   1024x768       75.1     75.0     70.1     60.0
   832x624        74.6
   800x600        72.2     75.0     60.3     56.2
   848x480        60.0
   640x480        72.8     75.0     72.8     75.0     66.7     60.0     59.9     59.9
   720x400        70.1
LVDS connected (normal left inverted right x axis y axis)
   1024x768       60.0 +   60.0
   1360x768       59.8
   800x600        60.3     59.9
   848x480        59.7
   720x480        59.7
   640x480        59.9     59.4
S-video disconnected (normal left inverted right x axis y axis)

In my output you can see that I connected both VGA and DVI (I am still doing tests with my new monitor) and that LVDS (laptop screen) is switched off and the S-video is not connected.

You can also see that with this simple command you can see all the resolution and refresh rate supported by the screens.

Basic use with screens

The basic use to give command to screens is xrandr --output SCREEN COMANDO, so for example to turn off the VGA screen you can use:

xrandr --output VGA-0 --off

Turning off an output media is useful sometimes, for example i’ve at work a screen with resolution 1600×1200 while my laptop screen is 1680×1050, i use the laptop in a docking station with the lid closed so turning off LVDS help in getting a good resolution on the screen.

Change the resolution of a screen

To change resolution size, you can use xrandr and the –mode option:

xrandr --output DVI-0 --mode 1440x900 --refresh 75

With this command you’ll switch your DVI screen at 1440×900 resolution and with a refresh rate of 75.

Cloning a screen

Assumed to attach a VGA output to your laptop and you want to clone your main screen, so what appears on the laptop screen is also shown on the external screen, nothing more easy with xrandr:

 xrandr --output LVDS --auto --output VGA --auto --same-as LVDS

In general use $ xrandr -q to discover the appropriate output names for your configuration. The –auto option will select the preferred resolution for each output, this is identified with a plus (+) in the $ xrandr -q listing and is normally the best resolution available.

2 screen side by side

it’s possible to create a virtual desktop putting 2 screen side by side, it is possible to set screen locations as –left-of, –right-of, –above and –below. Assuming displays sizes of the LVDS 1024×768 and the VGA 1200×1600 you can use one of these 2 commands:

$  xrandr --output LVDS --auto --output VGA --auto --right-of LVDS
$  xrandr --output LVDS --mode 1024x768 --pos 0x0 --output VGA  --mode 1600x1200 --pos 1024x0

They will give the same result, so i suggest using the first version, –right-of it’s much more easy to rembember and to use.

Automate it on login

You can automate your xrandr operation putting them in the directory /etc/X11/Xsession.d/, so for example you could add a file: /etc/X11/Xsession.d/45custom_xrandr-settings

# If an external monitor is connected, place it with xrandr
# External output may be "VGA" or "VGA-0" or "DVI-0" or "TMDS-1"
# EXTERNAL_LOCATION may be one of: left, right, above, or below
               EXTERNAL_LOCATION="--left-of $INTERNAL_OUTPUT"
               EXTERNAL_LOCATION="--right-of $INTERNAL_OUTPUT"
               EXTERNAL_LOCATION="--left-of $INTERNAL_OUTPUT"
xrandr |grep $EXTERNAL_OUTPUT | grep " connected "
if [ $? -eq 0 ]; then
    xrandr --output $INTERNAL_OUTPUT --auto --output $EXTERNAL_OUTPUT --auto $EXTERNAL_LOCATION
    # Alternative command in case of trouble:
    # (sleep 2; xrandr --output $INTERNAL_OUTPUT --auto --output $EXTERNAL_OUTPUT --auto $EXTERNAL_LOCATION) &
    xrandr --output $INTERNAL_OUTPUT --auto --output $EXTERNAL_OUTPUT --off


Several graphical frontends are available for xrandr (all using GTK):

  • Grandr
  • URandR
  • ARandR
  • Zarfy — A GUI to libxrandr. It presents the user with visual representaion of active displays on an interactive map of the screen memory. Features free postioning, configuration saving, scripting for R&R and an alternate gui for switching between monitors.

Script to Install Incredible Compiz Experimental Plugins

I was looking for something like this for so long. Using this incredible script, you can easily install some of the finest Compiz plugins in Ubuntu which are not available by default since they are dubbed “experimental”. This is one script you should not give a miss at any cost.

Compiz Experimental Plugins

Compiz Experimental Plugins
Screenshot above is a typical example. It is called Stack Window Switcher and it comes along with Compiz Experimental Plugins. This is one of my favorite new Compiz plugins among the lot. If you like the Shift Switcher plugin which currently comes as default in ccsm, you are going to adore Stack Window Switcher.

Other plugins include Freely Transformable Windows, Elements, Fireflies, Cube Snow Globe, Animations Plus, Cube 3D Models, Wizard and many many more. Instead of reading through the names, why don’t you install these awesome Compiz experimental plugins and find out for yourself what I am talking about here.

Important Note

  • Before getting started, here are some things you should consider. The script is supposed to work in both 32bit and 64bit machines having Ubuntu Maverick or Lucid installed. Though I have tried this only on my Ubuntu Maverick 32bit machine.
  • Script will work only for those who use Compiz version 0.8.x. For those using any other version should not use this script. Find out the Compiz version using the following command. Mine was Compiz version 0.8.6.
compiz --version
  • On a last note, you should know exactly what you are doing. Experimental plugins could make or break your system. All the best.

Script to Install Compiz Experimental Plugins in Ubuntu Maverick, Lucid Easily

  • Open Terminal and do the following one by one.
cd ~/Downloads
  • Next command is going to download and install a lot of stuff. It will take some time to finish depending on your bandwidth speeds.
sudo apt-get install compiz-fusion-bcop compiz-dev \build-essential libtool \libglu1-mesa-dev libxss-dev \libcairo2-dev git-core
  • You need to access Git now.
git clone git://
  • Now cd into the new Scripts directory.
cd scripts
  • And finally, run the script.
./compiz-addons install all
  • Done. Hopefully everything went well. Now to enable the changes, log out and log back in and start ccsm from System – Preferences – CompizConfig Settings Manager(Simply restarting Compiz will also work fine).
Compiz Experimental Plugins
  • To uninstall all the plugins, cd into ~/Downloads/scripts directory as above and run the following in Terminal.
./compiz-addons uninstall all

Offline Dictionary for Ubuntu

Anyway ubuntu have dictionary by default. You can find the dictionary from
Application –> office –> Dictionary.
You can find the meaning of a English word using this. When you search for meaning of a word its communicate with online dictionary server for ex. then get the result. It requires Internet connection. If you not having the Net connection / poor connection its useless. In this situation offline dictionary will helpful to you. Here is how to do this.

Open the terminal (Application -> Accessories -> Terminal) and run the following commands:

apt-get install dictd
apt-get install dict-gcide
apt-get install dict-moby-thesaurus

Now Goto Dictionary (Application -> Office -> Dictionary) then Edit –> Preference
Click the “Add” button to add a new dictionary.
Enter following details.
Description : Local Server
Transport : Dictionary Server
Hostname :
Port : 2628

Then click on add. Then Edit –> Preference select Local server.
Thats all. Now you can search locally.