Wednesday, March 18, 2009

scheduling a task to mail one file as attachment

use crontab -e to edit the crontab

and then write the below line ( modify the time and date as per your need)

25 20 */15 * */5 mail -s "testing mail for usera " usera@gmail.com < /etc/sysconfignetwork-scripts/ifcfg-eth0

Friday, March 13, 2009

vi editor tricks

R replace mode
ESC normal mode
CTRL-g show filename, current location in the file and status
SHIFT-g goto the end of file

:set ic search ignore cases
de delete to the end of word
dw delete to the end of word+space
d$ delete to the end of line
d^ delete to the begin of line

CTRL-R redo the last command

:r filename insert the contents of the file
:!command execute external command

Saturday, March 7, 2009

IP SCANNING in Linux

No need to use any ip scanner software to scan ips in your network.

Just sse nmap.

nmap -sP 192.168.10.1-255 > prakash.txt

Thursday, March 5, 2009

just for me

awk '{print $1}' /root/test

this command will print the first column from this file. Type print $2 to print second column


for i in `cat /root/test`;do cp /log/asterisk/monitor/monitor/$i /root/records/;done


this command will read names of files from the file /root/test and copy these files from /var/log/asterisk/monitor/monitor directory to the /root/records file

Friday, February 13, 2009

Modify output of historycommand

just write the below command

export HISTCONTROL='!ignorespace'
export HISTTIMEFORMAT=’%F %T '

Friday, January 30, 2009

replace a string from name off all files in a directory.

To replace a particular string from the name of all files in a
directory follow the below steps

  • create a file script.sh and change its permission to 644
  • write the below thing in the script
here in the below example we are replacing the string in with all from
all files in the directory.

for f in *-in.wav; do mv "$f" "${f%-in.wav}-all.wav"; done

Tuesday, January 20, 2009

Searching a particular string from unknown file or to search a file from the known string of that file

grep string_to_Search * -Rn

note:- the string here (a sentence or word) is the one which is there in some unknown file and you want to know the name of that file.

Thursday, January 8, 2009

HIDING SSH CONNECTION

use the below command to hide your ssh connection

ssh -T user@host /bin/bash/ -i