Monthly Archives: October 2009

simple Bash calculator on command line interface

Bash is a shell Command-Line Interface that is very popular in  Unix/ Linux. Like a shell on Unix, Bash is not a simple shell. It  has  lots of features.

One of the features of Bash can be used as a simple calculator. If you are in command-line mode, you do not need to run the calculator application to do a simple calculation process. Simply run the commands like the following in your Bash shell:

admin@smartproteam~$ Echo $ ((2 * 3))
admin@smartproteam~$ Echo $ ((1024 * 1024))
admin@smartproteam~$ Echo $ ((2321 * 3 – 4))

few usefull text processing using “awk” with examples

1.print the latest file from a  directory

admin@smartproteam~$ls -ltr *.* | awk ‘{ f=$NF }; END{ print f }’
example2.txt

2.Adding double space to a  file

admin@smartproteam~$cat example2.txt | awk ‘NF{print $0 “\n”}’
whazzz you

12

223

1

12

433

4433

3.Print total number of  line  in a  file

admin@smartproteam~$cat example2.txt | awk ‘END{print NR}’
7

4.print line number 4 from a file

admin@smartproteam~$cat example1.txt | awk ‘NR==4′
man the man

5.Searching words using awk

admin@smartproteam~$cat example1.txt | awk ‘/you/’;

you the man

6.print the lines which are less than 10 which are 10 characters or longer

admin@smartproteam~$cat example1.txt | awk ‘length >  10′
you the man
man the man
man says to ma:wq

linux command “paste” with example

paste : Using paste you can merge lines of files.

example :

think that you have two text files example1.txt and example2.txt

in example1.txt which contents

admin@smartproteam~$cat example1.txt
the man
wat man
you the man
man the man
man says to ma:wq

in example2 test file

admin@msartproteam~$cat example2.txt
whazzz you
12
223
1
12
433
4433

now you will run paste command

admin@smartproteam~$paste example1.txt example2.txt
the man whazzz you
wat man 12
you the man     223
man the man     1
man says to ma:wq       12
433
4433

using

-d, –delimiters=LIST
reuse characters from LIST instead of TABs

-s, –serial
paste one file at a time instead of in parallel

admin@smartproteam~$paste -s -d:example1.txt example2.txt
whazzz you:12e223x1a12m433p4433

System Rescue cd 1.3.1 released

SystemRescueCd is an operating system by definition, though the primary purpose of SystemRescueCD is to repair unbootable or otherwise damaged computer systems after a system crash. SystemRescueCD is not intended to be used as a permanent operating system. It runs from a Live CD or a USB flash drive.

System Rescue cd 1.3.1 released with kernel version 2.6.31.1 and with alternative kernel 2.6.27.35.

Highlights :

  • NTFS-3G
  • TigerVNC 1.0.0
  • PartImage 0.6.8

SystemRescueCD

System tools included :

  • GNU Parted : creates, resizes, moves, copies partitions, and filesystems (and more).
  • GParted : GUI implementation using the GNU Parted library.
  • Partimage : popular opensource disk image software which works at the disk block level
  • FSArchiver : flexible archiver that can be used as both system and data recovery software
  • File systems tools (for Linux and Windows filesystems): format, resize, and debug an existing partition of a hard disk
  • Ntfs3g: enables read/write access to MS Windows NTFS partitions.
  • sfdisk : saves / restores partition table (and more).
  • Test-disk tool : to check and undelete partition, supports reiserfs, ntfs, fat32, ext2/3 and many others
  • Memtest+ : to test the memory of your computer (first thing to test when you have a crash or unexpected problems)
  • Network tools :  (Samba, NFS, ping, nslookup, …) to backup your data across the network

click here to download

Generate a hardware report in html format using lshw on linux

If you want to generate a hardware report of your workstation,desktop and laptop it very useful command.

lshw means list hardware on linux.

Example :

admin@smartproteam~$sudo lshw -html > myhardwarelist.html

(note : you need to be root to run this command )

myhardwarelist.html on the pwd(present working directory) with list of your hardware and configuraion in html format.

spliting a large file into small chunks on linux

Using “split” command you chunk large files into smaller chunks.

For you if you have 500mb of file you chunk into 100mb file each

Split : split a file into pieces

admin@smartproteam~$ split 100mb mydocs-files.zip

it wil create 5 files each one of the size 100mb

xa

xb

xc

xd

xe

if you want to join all the files agian

admin@smartproteam~$cat x* > mydocs-files.zip

man page in color text with most

most – browse or page through a text file

most  is  a  paging program that displays, one windowful at a time, the
contents of a file on a terminal.

most  is  a  paging program that displays, one windowful at a time, the contents of a file on a terminal.

if you want to display man page in colors in ubuntu.

you need to install “most” package

admin@smartproteam~$ sudo apt-get install most

now you need to set the default pager to most for update the alternatives

admin@smartproteam~$sudo update-alternatives –config pager

[sudo] password for sushanthreddy:


There are 5 alternatives which provide `pager’.


Selection    Alternative

———————————————–

1    /bin/more

2    /usr/bin/pg

*+        3    /usr/bin/less

4    /usr/bin/w3m

5    /usr/bin/most


Press enter to keep the default[*], or type selection number:

in this case you need to select 5.

for example :

admin@smartproteam~$man most

output displayed like this

most


Highlight a word with color using grep command

Highlight a word with color using grep command

Example

admin@smartrpoteam~$grep –color=auto -i man m

grepwithcolor

installing IntelliJ IDEA on ubuntu

To Install IntelliJ IDEA 8.1 on ubuntu

Following are the steps :

1.first you need install java for you need to run below command on terminal.

admin@smartproteam~$ sudo apt-get install sun-java6-jdk

2.Now you need to download IntelliJ IDEA from below source

click here to download

3.Unpack the idea-8.1.3.tar.gz with tar xfz

admin@smartproteam~$ tax xfz  idea-8.1.3.tar.gz

after extracting rename the file to idea-8 to make it simple

4.now copy idea-8 file to /usr/lib/

admin@smartproteam~$ sudo idea-8 -R /usr/lib

Now you need to configure the JDK_HOME and path for IDEA

5first you need to edit /etc/environment by running below command

admin@smartproteam~$ sudo gedit /etc/environment

add below lines to /etc/environment

export JDK_HOME=”/usr/lib/jvm/java-6-sun/”

add /usr/lib/idea-8/bin to this path

PATH=”/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/lib/idea-8/bin”

after setting above once logout and login

6.now run below idea.sh to launch the IntelliJ IDEA like below

admin@smartproteam~$ idea.sh

now you can launch the Intellij


unable to delete trash file from trash in ubuntu

if you can’t  delete a file from trash here is the solution.

run the command on terminal :

admin@smartproteam$ nautilus /home/smartproteam/.local/share/Trash/files/

nautilus windows opens like below

trash

Now select the file and delete.