≡ Menu


I use Google Calendar exclusively. However to access this product you need to use a web browser. There is nice program called gcalcli (Google Calendar Command Line Interface) which allows to access Google Calendar from bash shell. Now I can see an agenda using a specified start/end time and date from a shell prompt over ssh session :D

gcalcli is a Python application that allows you to access you Google Calendar from a command line. It's easy to get your agenda, search for events, and quickly add new events. Additionally gcalcli can be used as a reminder service to execute any application you want.

Current Features

  1. List your calendars
  2. Show an agenda using a specified start/end time and date
  3. Search for calendar events
  4. "Quick add" new calendar events to your default calendar
  5. Run as a cron job and execute a command for reminders
  6. Work against specific calendars (default, owner, read-only)
  7. Color support
  8. unicode support

Download Google Calendar Command Line Interface

=> Visit official project page here

A small how to written to assist sys admins. It offers tools and high level advice to solve slow websites problems:

Oh boy it's been an intense 4 weeks. I was pulled in to assist with troubleshooting several major failures at work with loosely related systems. Including my own. All systems are public facing, hence the intensity.

This article attempts to capture a high level view of one of the problems and the methods and tools used (not how to use the tools, that's for another time) to try and solve it. I'm not putting all the details in. Some details are emphatically not appropriate, other details won't increase understanding of the methodology and process taken.

In the interest of helping other sysadmins, I've linked to the various tools used. Some are well known, others more obscure.

=> Advanced Sysadmin Troubleshooting: Slow Websites (via RootPrompt)

Vmware server comes with the nifty vmware-cmd utility. It allows an administrator to perform various operations on a virtual machine from Linux command line / shell prompt such as:

=> Stop / Start VM

=> Get VM status

=> Setup variables

=> Powerdown VM and much more

Task: Lists the virtual machines on the local server

You can list all servers and config file, enter:
# vmware-cmd -l


Turn on VM / Power up VPS

Just pas start option to vmware-cmd,
# vmware-cmd /nas/vms/FreeBSD/FreeBSD.vmx start

To stop VM/VPS, enter:
# vmware-cmd /nas/vms/FreeBSD/FreeBSD.vmx stop

To reset VM/VPS, enter:
# vmware-cmd /nas/vms/FreeBSD/FreeBSD.vmx reset

To suspend VM/VPS, enter:
# vmware-cmd /nas/vms/FreeBSD/FreeBSD.vmx suspend

Find out if OpenBSD VM is on or off:
# vmware-cmd /disk2.vmware/vms/OpenBSD/OpenBSD.vmx getstate

getstate() = off

vmware-cmd offers other options, please consult VMWARE documentation for more information.

Recently I came across very powerful and nifty tool called cutter. Just imagine that people in your private network using peer to peer (P2P) software such as Kazaa, iMesh or others and you want to cut them or just want to cut all ftp connection over your firewall but not all traffic to host. Network security administrators sometimes need to be able to abort TCP/IP connections routed over their firewalls on demand

cutter utility

In the following sample network diagram client workstation sending ftp, http, ssh traffic using (Linux based) router to server outside our network, and you would like to cut ftp traffic without interrupting other connection? So how do you block and cut traffic? Simply, use cutter utility.

client ->    Linux firewall -> Internet --> Servers
FTP    ->  -> Internet --> FTP Server
HTTP   ->  -> Internet --> HTTP Server
SSH    ->  -> Internet --> SSH Server

Cutter is an open source program that allows Linux firewall administrators to abort TCP/IP connections routed over Linux based firewall. This tool is very handy in situation like:

  • To terminate connection such as SSH tunnels or VPNs left by your own users
  • To abort crackers attacks as soon as they detected
  • To kill high bandwidth consuming connection
  • To kill peer-to-peer traffic etc

How do I use cutter command?

Use apt-get to install cutter on a Debian / Ubuntu Linux firewall:
# apt-get install cutter

1) Login to your iptables based firewall router

2) Identify your internal connection (use netstat or tcpdump)

3) Use cutter the command as follows:
cutter {IP-address} {Port}

Cut all connections from to server
# cutter

Cut all ssh connection from to server
# cutter 22

Cut all ssh connection from to ssh server
# cutter 22

Please note that cutter has been designed for use as a administrators tool for Linux firewalls do not use this tool for malicious purpose. For more information about this tool & how actually it works by sending FIN -> ACK -> RST sequence of packets to terminate connection, see the official web site.

Update: As pointed out by Mina Naguib you can also use tcpkill command for same purpose.

Related articles:

Most of the time GUI is not available on remote Linux system, you login over ssh and start to work, if you need to run two or three task at a time, you login over ssh two or three times. However, with screen windows manager utility you can run multiple terminals at the same time from single console login over ssh session (UNIX guru uses the term called multiplexing for this concept). Any seasoned Linux admin should be aware of this nifty tool :)

Install screen if it is not installed under Debian Linux

Type the following command:
# apt-get install screen

FreeBSD user can use ports to install screen

# cd /usr/ports/misc/screen
# make install clean

Login to remote server over ssh

$ ssh me@myserver.com

(C) Start screen session. You can name your window/session (1 is name of session):
$ screen -S 1

Let us start pine mail reader on first session or window.
$ pine

(D) Next you would like to download something from ftp/http site while you are reading emails. You need to create another screen window by pressing special key combination. Press CTRL + a followed by c key (first hit CTRL+a, releases both keys and press c). As soon as you hit 'c' you will get new shell prompt at console. Now use wget to download belenix.iso.bz2 (Solaris live CD) from net:
$ wget http://www.genunix.org/distributions/belenix_site/binfiles/belenix.iso.bz2

(E) But how do I switch between these two tasks?

  • Switching between windows is the specialty of screen utility. So to switch between pine and wget window (or session) press CTRL+a followed by n key (first hit CTRL+a, releases both keys and press n).
  • To list all windows use the command CTRL+a followed by " key (first hit CTRL+a, releases both keys and press " ).
  • To switch to window by number use the command CTRL+a followed by ' (first hit CTRL+a, releases both keys and press ' it will prompt for window number).

Common screen commands

screen commandTask
Ctrl+a cCreate new window
Ctrl+a kKill the current window / session
Ctrl+a wList all windows
Ctrl+a 0-9Go to a window numbered 0 9, use Ctrl+a w to see number
Ctrl+a Ctrl+aToggle / switch between the current and previous window
Ctrl+a SSplit terminal horizontally into regions and press Ctrl+a c to create new window there
Ctrl+a :resizeResize region
Ctrl+a :fitFit screen size to new terminal size. You can also hit Ctrl+a F for the the same task
Ctrl+a :removeRemove / delete region. You can also hit Ctrl+a X for the same taks
Ctrl+a tabMove to next region
Ctrl+a D (Shift-d)Power detach and logout
Ctrl+a dDetach but keep shell window open
Ctrl-a Ctrl-\Quit screen
Ctrl-a ?Display help screen i.e. display a list of commands

Suggested readings:

See screen command man page for further details:
man screen

In the first part we talked about find command basic usage.

Now let us see how to use find command
(a) To gain lots of useful information about users and their files

(b) Monitor and enhance the security of system using find command

Finding all set user id files

setuid ("suid") and setgid are access right flags that can be assigned to files and directories on a Unix based operating system. They are mostly used to allow users on a computer system to execute binary executables with temporarily elevated privileges in order to perform a specific task.
# find / -perm +u=s
# find / -perm +4000

See also, shell script to find all programs and scripts with setuid set on.

Finding all set group id files

# find / -perm +g=s
# find / -perm +2000

See also, shell script to find all programs and scripts with setgid bit set on.

Finding all large directories

To find all directories taking 50k (kilobytes) blocks of space. This is useful to find out which directories on system taking lot of space.
# find / -type d -size +50k


Finding all large files on a Linux / UNIX

# find / -type f -size +20000k


However my favorite hack to above command is as follows:
# find / -type f -size +20000k -exec ls -lh {} \; | awk '{ print $8 ": " $5 }'

/var/log/kern.log: 22M
/sys/devices/pci0000:00/0000:00:02.0/resource0: 128M
/sys/devices/pci0000:00/0000:00:00.0/resource0: 256M
/opt/03Jun05/firefox-1.0.4-source.tar.bz2: 32M

Above command will find all files block size greater than 20000k and print filename followed by the file size. Output is more informative as compare to normal find command output :D

Many newcomers find it difficult use the find command at shell prompt under Linux / *BSD or Solairs UNIX oses. Find is nifty tool on remote server where UNIX admin can find out lot of information too. Desktop users may find handy GNOME Search tool as a utility for finding files on system. Find command can perform a search based on a variety of search constraints. It searches through one or more directory tree(s) of a filesystem, locating files based on some user-specified criteria. By default, find returns all files below the current working directory. Further, find allows the user to specify an action to be taken on each matched file. Thus, it is an extremely powerful program for applying actions to many files. It also supports regexp matching.

GNOME Search Tool GUI Program

GNOME Search Tool is a utility for finding files on your system. To perform a basic search, you can type a filename or a partial filename, with or without wildcards. You can start this program from menus or by typing following command at shell prompt:
$ gnome-search-tool &
Internally GNOME Search Tool uses the find, grep, and locate UNIX commands. The case sensitivity of the search depends on your operating system. For example, on Linux, the find, grep, and locate commands support the -i option, so all searches are case-insensitive.

the GNOME Linux / UNIX GUI Search Tool(click to enlarge)

Find command syntax

find {search-path} {file-names-to-search} {action-to-take}


  • search-path : Define search path (default current directory). For example search in /home directory.
  • file-names-to-search : Name of the file you wish to find. For example all c files (*.c)
  • action-to-take : Action can be print file name, delete files etc. Default action is print file names.

Find command examples

Let us try out some examples.

Finding files and printing their full name

You wish to find out all *.c (all c source code) files located under /home directory, enter:
$ find /home -name "*.c"

You would like to find httpd.conf file location:
$ find / -name httpd.conf

Finding all files owned by a user

Find out all files owned by user vivek:
# find / -user vivek

Find out all *.sh owned by user vivek:
# find / -user vivek -name "*.sh"

Finding files according to date and time

Files not accessed in a time period – It is useful to find out files that have or have not been accessed within a specified number of days. Following command prints all files not accessed in the last 7 days:
# find /home -atime +7

  • -atime +7: All files that were last accessed more than 7 days ago
  • -atime 7: All files that were last accessed exactly 7 days ago
  • -atime -7: All files that were last accessed less than7 days ago

Finding files modified within a specified time – Display list of all files in /home directory that were not last modified less than then days ago.
# find /home -mtime -7

Finding newer (more recently) modified files

Use -newer option to find out if file was modified more recently than given file.
# find /etc/apache-perl -newer /etc/apache-perl/httpd.conf

Finding the most recent version of file

It is common practice before modifying the file is copied to somewhere in system. For example whenever I modify web server httpd.conf file I first make backup. Now I don't remember whether I had modified the /backup.conf/httpd.conf or /etc/apache-perl/httpd.conf. You can use the find command as follows (tip you can also use ls -l command):
find / -name httpd.conf -newer /etc/apache-perl/httpd.conf

Locate command

The locate command is often the simplest and quickest way to find the locations of files and directories on Linux and other Unix-like operating systems.

For example, the following command uses the star wildcard to display all files on the system that have the .c filename extension:
# locate "*.c"

Further readings

  • Read find and locate command man page for more information.