Search for Tips & Tricks

Google
 
Showing posts with label Linux. Show all posts
Showing posts with label Linux. Show all posts

Wednesday, February 27, 2008

How to get the screen resolution

# how to get the screen resolution
$ xdpyinfo

How to iterate through output

# use this below script for iteration thorugh the output

for i in *.tar.gz; do echo working on $i; tar xvzf $i ; done

the above example will extract all tar.gz file in current folder.

Thursday, January 24, 2008

How to redirect output to a file and stdout simultaneously

# How to redirect to stdout and a file

grep 2>&1 | tee

e.g.

grep India *.txt 2>&1|tee output.log

Wednesday, January 23, 2008

How to use find command to find and execute

Find can be clubbed with xargs for finding and executing commands.
e.g.

1. Find log fine in /var and delete them

$ find -path /var -name *.log -exec rm {} \;

Tuesday, January 22, 2008

How to mount a cdrom/pendrive on Linux system

For mounting cdrom user the command as su:

mount -t iso9660 -o ro /dev/cdrom /cdrom

For mounting pendrive the command as su:

mount -t vfat /dev/sda1 /mnt/pendrive

How to list file that doesnot contains some string

Llist files that does not contain string 'dat' in file name

$ ls *[!dat]

Sunday, January 20, 2008

How to open remove application on local machine

This can be done using xhost utility:

Step 1. On the local host

Type the following at the command line:

$ xhost +

Step 2. Log on to the remote host

$ telnet

Step 3. On the remote host (through the telnet connection)

Instruct the remote host to display windows on the local host by typing:

$ setenv DISPLAY :0.0
->> user zsh ( shell)
at the command line. (Instead of setenv you may have to use export on
certain shells. in bash shell use DISPLAY=:0.0)

Step 4. Now you can run software from the remote host.

E.g.: when you type $ xterm on the remote host, you should see an
xterm window on the local host.

Step 5. After You Finish

You should remove the remote host from your access control list as follows.
On the local host type:

$ xhost -

How to Extract a single line from a file

$sed -ne 5p help | /bin/bash

The above command will extract 5th Line from the file 'help'