Wednesday, January 30, 2008

add alias in .bashrc

To avoid typing long commands with there arguments.
here .bashrc minimizes ones burden of typing at CLI.

$vi /home/user/.bashrc

##add following alias into .bashrc file
alias runing='ps -ef | grep -i $1'
alias email='ssh -l username servername'

$source .bashrc

$type runing

runing is aliased to `ps -ef | grep -i $1'

$runing bash

alien - Convert or install an alien binary package

alien is a program that converts between Red Hat rpm, Debian deb, Stam‐
pede slp, Slackware tgz, and Solaris pkg file formats. If you want to
use a package from another linux distribution than the one you have
installed on your system, you can use alien to convert it to your pre‐
ferred package format and install it. It also supports LSB packages.

Here are some examples of the use of alien:

alien --to-deb package.rpm
Convert the package.rpm into a package.deb

alien --to-rpm package.deb
Convert the package.deb into a package.rpm

alien -i package.rpm
Convert the package.rpm into a package.deb (converting to a .deb
package is default, so you need not specify --to-deb), and install
the generated package.

alien --to-deb --to-rpm --to-tgz --to-slp foo.deb bar.rpm baz.tgz
Creates 9 new packages. When it is done, foo bar and baz are avail‐
able in all 4 package formats.

Wallpapoz tool enables your Gnome desktop to have different wallpapers

Install & Run Daemon


$sudo dpkg -i wallpapoz_0.4.1-1~getdeb1_all.deb


$/usr/bin/daemon_wallpapoz &

$ps -ef | grep -i wallpapoz | grep -v grep

check daemon is running in background.

More Information

Tuesday, January 29, 2008

tr - translate or delete characters

translate upper to lower or delete characters

localhost$echo UUU | tr [:upper:] [:lower:]

localhost$tr [:upper:] [:lower:] < file

localhost$cat file | tr [:upper:] [:lower:]

localhost$cat file | tr [:upper:] [:lower:] > tmpfile

run-parts : run scripts or programs in a directory

I kept updating my cron to automate some routine tasks. however noticed many a things in cron are not giving results to my expectation. Was kept suspecting cron is not working or got corrupted.But found errors in crontab entries using run-parts .

here we see how cron and run-scripts works

Cron daemon to execute and scheduled commands.
At start it search in cron spool area: /var/spool/cron/ and After that cron.{d,hourly,daily,monthly} and log in /var/log/cron.

Cron Related commands

Usage: /etc/init.d/cron {start|stop|restart|reload|force-reload}

usage: crontab [-u user] file
crontab [-u user] { -e | -l | -r }
(default operation is replace, per 1003.2)
-e (edit user's crontab)
-l (list user's crontab)
-r (delete user's crontab)

run-parts runs all the executable files named within constraints described below, found in directory directory.Other files and directories are silently ignored.

Usage: run-parts [OPTION]... DIRECTORY
--test print script names which would run, but don't run them.
--list print names of all valid files (can not be used with
-v, --verbose print script names before running them.
--report print script names if they produce output.
--reverse reverse execution order of scripts.
--exit-on-error exit as soon as a script returns with a non-zero exit
--lsbsysinit validate filenames based on LSB sysinit specs.
-u, --umask=UMASK sets umask to UMASK (octal), default is 022.
-a, --arg=ARGUMENT pass ARGUMENT to scripts, use once for each argument.
-V, --version output version information and exit.
-h, --help display this help and exit.

example :

#run-parts --list /etc/cron.hourly ( list files to executed by run-parts )
#run-parts --test /etc/cron.hourly ( list and test files inside directory )
#run-parts /etc/cron.hourly ( executes files and there output to stdout )

Monday, January 14, 2008

Cisco 3725

telnet router.domain
give passwd
give enable passwd
Get #
# sh runn ;To show the running config
# sh conf ;To show the config

To add acl to Internet ( here Internet is access list name for inbond traffic)

# conf t
ip access-list extended internet
permit tcp any host eq 25

permit ssh from 159.133.12 net to 49 subnet

permit tcp eq 22
no deny ip any any
deny ip any any
ctrl z

to write the config to flash
# wr mem

To add acl to Externet ( Externet is access list name for outbond traffic)

# conf t
ip access-list extended externet
deny tcp host any eq port no

deny port 422 to 159.133.12 net from 49 subnet of tifr

deny tcp eq 422
no permit ip any any
permit ip any any

ctrl z

to write the config to flash
# wr mem
# sh int fastethernet 0/1

to see tx load and rx load and crc

Friday, January 11, 2008

tips for new Ubuntu users

1.Ubuntu Tweak Software to Change Hidden Desktop Settings

$ cd /tmp; wget
$ sudo dpkg -i ubuntu-tweak_0.2.4-ubuntu2_all.deb
$ ubuntu-tweak &

2.gconf-editor - an editor for the GConf configuration system

$ gconf-editor &

Wednesday, January 9, 2008

Linux Iptables Limit the number of incoming tcp connection / syn-flood attacks

step 1:

Enable iptables in 3,4 & 5 run level

/sbin/chkconfig iptables --list

/sbin/chkconfig iptables on

/sbin/service iptables status

/sbin/service iptables start

step 2:
Basics of iptables

/sbin/iptables -L

/sbin/iptables -vL

/sbin/iptables -nL

/sbin/iptables -t nat -L

/sbin/iptables -F

step 2:
#run this script
# incoming syn-flood protection

iptables -N SYN_FLOOD
iptables -A INPUT -p tcp --syn -j SYN_FLOOD
iptables -A SYN_FLOOD -m limit --limit 1/s --limit-burst 3 -j RETURN
iptables -A SYN_FLOOD -j DROP

#Limiting the incoming icmp ping request:

iptables -A INPUT -p icmp -m limit --limit 1/s --limit-burst 1 -j ACCEPT
iptables -A INPUT -p icmp -m limit --limit 1/s --limit-burst 1 -j LOG --log-prefix PING-DROP:
iptables -A INPUT -p icmp -j DROP
iptables -A OUTPUT -p icmp -j ACCEPT

* -N : create user chain.
* -A : append chain rule
* INPUT : INPUT table handles inbond (traffic from inside to outside) traffic
* OUTPUT : OUTPUT table handles outbond (traffic from inside to outside) traffic
* LOG : write log with prefix PING-DROP in file /var/log/syslog
* --syn : Only match TCP packets with the SYN bit set and the ACK,RST and
FIN bits cleared. Such packets are used to request TCP connec‐
tion initiation.
* ‐‐limit rate: Maximum average matching rate: specified as a number, with an optional ‘/second’, ‘/minute’, ‘/hour’, or ‘/day’ suffix; the default is 3/hour.

* ‐‐limit‐burst number:
Maximum initial number of packets to match: this number gets recharged by one every time the limit specified above is not reached, up to this number; the default is 5.

* ACCEPT :means to let the packet through.

* DROP : means to drop the packet on the floor.

* QUEUE : means to pass the packet to userspace.

means stop traversing this chain and resume at the next rule in the previous
(calling) chain. If the end of a built-in chain is reached or a rule
in a built-in chain with target RETURN is matched, the target specified
by the chain policy determines the fate of the packet.

Thursday, January 3, 2008

extract RAR archives in Ubuntu

Like other archives, RAR files are data containers, they store one or several files in the compressed form. After you downloaded RAR file from Internet, you need to unpack its contents in order to use it.

after downloading RAR acrchive on my Desktop, went to unpack it with unrar-free .
unrar-free failed to extract .rar archives. Was thought may RAR archive got corrupted. In that way tried to unpack many RAR archives and failed to do so.

Finally a unrar worked.

here goes steps to unpack RAR with unrar

Install unrar using apt-get

#apt-get install unrar

Test Archives

#unrar t compressfiles.rar

Extract files to current directory

#unrar e compressfiles.rar