Count Lines From Standard Input in Shell

Here’s a script that will help you count the lines of input from the standard input:

Now, you can find out the number of files in a directory using:


As Jeff Harver has kindly pointed out in the comments, the same thing as the long script above can be accomplished using:

Backup Your Linux Machine

I was up to maintenance of my Debian box, and I came in need of creating and maintaining multiple, date-based backups of the machine.

Here is the bash script I wrote to accomplish this.

Once executed, this script will backup the target specified by “$target” (the whole filesystem in this case) and create a tar.gz file under “/backups/month/date.tar.gz”. You have to specify an “admin” email account to which notifications will be sent.

Having Your Shell Tweet

Have you ever wanted to have your *nix shell access Twitter?

Using the RESTful API, you can achieve this. However, you would need to set up your instance as an app and then configure the API keys and all the what-nots. I personally try to avoid such hassle whenever possible.

So, I got this shell script for you (which is not originally mine, but has undergone a fair bit of modification by me) which achieves this:

What this script does is fairly simple:

It opens up a a connection the mobile version of the twitter, submits a fake Login form, gains access to the page, and then posts all the input parameters collectively as your Tweet.

The problem currently is that you have to write in your twitter credentials inside the file. I might change that one day.


You will need to install “curl” on your machine to be able to run this.

Access super user shell

I recently had a problem with my Debian box; namely, that I couldn’t access my superuser shell the usual way by typing:

As this is a problem with the user bit of the “su” command not being set properly, you can fix this by logging in as root (or any other user with superuser privileges) and type:

I hope this saves someone’s time out there 😉

Setting up SSH keys

Sometimes you work with your remote host so much, that having to enter a password every time becomes a real pain. If that is the case, you should follow with this instructions to set up automatic handshake with your remote host.

First off, you have to have OpenSSH on both the host and your local machine. SSH into your remote host to create the .ssh” directory in your home folder.

Now we are going to use the SSH Key Generator to create the authorized key.

You will be prompted to enter a passphrase for this identity key. Choose something hard to break.

Now all you have to do is copy the identity key to the remote host.

Of course, you will replace” with your actual remote host’s access information. Now, you will run a simple script that will tell the remote host which identity it should use, and also starts a new shell that will enable you to SSH to the remote host without entering any passwords.

Now try typing “ssh” and you will see that you are all set.