Bash

Linux Fork Bomb Explained

One famous way to crash your Linux system is to run a “fork bomb” in the terminal. A variant of it looks like this:

WARNING: Malicious code. Don’t run it!

1
:(){:|:&};:

This code looks strange, but it’s actually a conventional code in Bash. To make it a little more obvious, let’s replace the : (colon) with the word bomb. So, our code now looks like this:

1
bomb(){bomb|bomb&}; bomb

› Continue reading

Post to Twitter Post to Delicious Post to Digg Post to Facebook Post to Reddit Post to StumbleUpon

Tags: , ,

Saturday, March 28th, 2009 Bash 1 Comment

Navigate Efficiently To Your Most Used Directories With Autojump

Autojump is “a cd command that learns”.

I use to visit a small number of directories on daily basis. For example, every time I want to visit my studies directory I used to type:

cd ~/Studies/Winter2009/

With autojump, I just need to type:

j Win

And hit the [tab] key (It supports auto-completion).

› Continue reading

Post to Twitter Post to Delicious Post to Digg Post to Facebook Post to Reddit Post to StumbleUpon

Tags: , ,

Tuesday, March 24th, 2009 Bash 1 Comment

Copy a Directory Along With Its Relative Path

Today, a friend of mine wanted to do this:

Copy a directory from path A to path B, preserving its relative path.

For example, if the directory is found at:

./old/path/of/dir

and we want to copy it to

./new/place/

We want the result look like this:

./new/place/old/path/to/dir

› Continue reading

Post to Twitter Post to Delicious Post to Digg Post to Facebook Post to Reddit Post to StumbleUpon

Tags: ,

Sunday, March 22nd, 2009 Bash No Comments

Create a Directory Tree With One Command

This one is via command-line-fu.


1
mkdir -p doc/{text/,img/{wallpaper/,photos/}}

Will create the following directory tree inside current directory:

-doc
—–text
—–img
———-wallpaper
———-photos

Post to Twitter Post to Delicious Post to Digg Post to Facebook Post to Reddit Post to StumbleUpon

Tags: , ,

Saturday, March 21st, 2009 Bash No Comments

A Bash Command To Get Your IP

This is a one line bash command to get your IP.

It queries whatismyip.com, processes the output and displays the IP.

You might want to add it to your aliases file.

UPDATE: Don’t use this command, use the one in the end of this post

1
wget -O - whatismyip.com 2> /dev/null | grep "Your IP Address Is" | sed -e 's/^.*Is//' -e 's/<.*$//'

Enjoy ;)

Update: A nice guy – Theodore- has put this along with a script of his own to get a simple and neat bash script which shows both the internal (wired and wifi) and the external IPs. Script posted at his blog. Script in Theodore’s post is for Mac, but can be easily modified to run on Linux. Thanks Theodore.

Update2: Thanks to commenter Paul Dorman, I visited whatismyip’s forum and realized that they don’t allow to visit their home page too many times (they might ban you if you do so). However, they give an alternative: Another page in their website where you can get your IP. So the new command to query your IP is:

1
wget http://www.whatismyip.com/automation/n09230945.asp -O - 2> /dev/null; echo

Please use this and not the previously mentioned command.
Thanks Paul.

Post to Twitter Post to Delicious Post to Digg Post to Facebook Post to Reddit Post to StumbleUpon

Tags: ,

Monday, March 9th, 2009 Bash 11 Comments

Using Find Command to Find & Manipulate Files

The “find” command is a powerful command, which lets one search for files according to many criteria.

Below are a few examples. I found them here. In this post I just trimmed some of the text of the original post in order to have a quick reference without much explanations.

› Continue reading

Post to Twitter Post to Delicious Post to Digg Post to Facebook Post to Reddit Post to StumbleUpon

Tags: , ,

Saturday, March 7th, 2009 Bash No Comments

Go Up As Much Directory Levels As You Need – Easily

This neat and brilliant script by shell-fu allows you to go up as many directory levels as you want.

For example, instead of typing

cd ../../../..

You’ll be able to type the following and get the same functionality:

cd .. 4

› Continue reading

Post to Twitter Post to Delicious Post to Digg Post to Facebook Post to Reddit Post to StumbleUpon

Tags: , , ,

Saturday, March 7th, 2009 Bash 3 Comments

Get Examples for Random Bash Commands

Following my post about a script to query bash commands from shell-fu, here is another script, which queries shell-fu for examples of a random bash command:

The script is not bullet-proof and might fail if the guys at shell-fu decide to change the website’s layout, but it works for now, and this is good

› Continue reading

Post to Twitter Post to Delicious Post to Digg Post to Facebook Post to Reddit Post to StumbleUpon

Tags: , , ,

Saturday, February 28th, 2009 Bash No Comments

Get Examples for Bash Commands in Your Terminal

This one is by the great shell-fu, a website with many bash examples.

The following script is a powerful enhancement for the bash experience, and a great addition to the manpages, it allows you to query shell-fu for examples about almost any bash command you might want to use.

› Continue reading

Post to Twitter Post to Delicious Post to Digg Post to Facebook Post to Reddit Post to StumbleUpon

Tags: , , ,

Thursday, February 26th, 2009 Bash 4 Comments

Enhanced Bash

The first thing I do when I install a new Linux on my machine is updating .inputrc and .bashrc files to support “Enhanced Bash”. These improves might look minor at first glance, but they had improved my experience with the shell very much.

The main features you achieve by enabling “Enhanced Bash” are:

› Continue reading

Post to Twitter Post to Delicious Post to Digg Post to Facebook Post to Reddit Post to StumbleUpon

Tags: , ,

Friday, January 30th, 2009 Bash 17 Comments
my email
my photo
Hi,
My name is Amir Watad. I have a BSc. in biomedical engineering from The Biomedical Engineering school , Technion , Israel, and a BSc. in electrical engineering from The Electrical Engineering school , Technion , Israel.
I'm a Verification Engineer in Mellanox Technologies Ltd.
I love Linux, the Command Line and the OpenSource Community.
I used to write Poems (Arabic) when I was able to find time for this.
June 2012
S M T W T F S
« Sep    
 12
3456789
10111213141516
17181920212223
24252627282930
SEO Powered by Platinum SEO from Techblissonline

Twitter links powered by Tweet This v1.7.4, a WordPress plugin for Twitter.