Archive for October, 2009

Step #1: First, you need to find out process PID (process id)

Use ps command or pidof command to find out process ID (PID). Syntax:
ps aux | grep processname
pidof processname

For example if process name is lighttpd, you can use any one of the following command to obtain process ID:
# ps aux | grep lighttpd
Output:
lighttpd 3486 0.0 0.1 4248 1432 ? S Jul31 0:00 /usr/sbin/lighttpd -f /etc/lighttpd/lighttpd.conf
lighttpd 3492 0.0 0.5 13752 3936 ? Ss Jul31 0:00 /usr/bin/php5-cg

OR use pidof command which is use to find the process ID of a running program:
# pidof lighttpd
Output:
3486
Step #2: kill process using PID (process id)

Above command tell you PID (3486) of lighttpd process. Now kill process using this PID:
# kill 3486

OR
# kill -9 3486

Where,
-9 is special Kill signal, which will kill the process.
killall command examples

DO NOT USE killall command on UNIX system (Linux only command). You can also use killall command. The killall command kill processes by name (no need to find PID):
# killall -9 lighttpd

Kill Firefox process:
# killall -9 firefox-bin

As I said earlier killall on UNIX system does something else. It kills all process and not just specific process. Do not use killall on UNIX system (use kill -9).

Use ps command

Type the following ps command to display all running process
# ps aux | less

Where,
-A: select all processes
a: select all processes on a terminal, including those of other users
x: select processes without controlling ttys

Task: see every process on the system

# ps -A
# ps -e
Task: See every process except those running as root

# ps -U root -u root -N
Task: See process run by user vivek

# ps -u vivek
Task: Use top command

The top program provides a dynamic real-time view of a running system. Type the top at command prompt:
# top

Task: display a tree of processes

pstree shows running processes as a tree. The tree is rooted at either pid or init if pid is omitted. If a user name is specified, all process trees rooted at processes owned by that user are shown.
$ pstree

Task: Print a process tree using ps

# ps -ejH
# ps axjf
Task: Get info about threads

# ps -eLf
# ps axms
Task: Get security info

# ps -eo euser,ruser,suser,fuser,f,comm,label
# ps axZ
# ps -eM
Task: Save Process Snapshot to a file

# top -b -n1 > /tmp/process.log

Or you can email it to yourself:
# top -b -n1 | mail -s ‘Process snapshot’ you@example.com

Task: Lookup process

Use pgrep command. pgrep looks through the currently running processes and lists the process IDs which matches the selection criteria to screen. For example display firefox process id:
$ pgrep firefox

Following command will list the process called sshd which is owned by root user.
$ pgrep -u root sshd
Say hello to htop

htop is interactive process viewer just like top, but allows to scroll the list vertically and horizontally to see all processes and their full command lines. Tasks related to processes (killing, renicing) can be done without entering their PIDs. To install htop type command:
# apt-get install htop

or
# yum install htop

Now type htop to run the command:
# htop

Requirements
PC or router running GNU/Linux
Multiple WAN Connections, either from the same ISP or different ones
A dedicated ethernet adapter for each connection.

Update 2008-05-23: It should be noted that this example requires all involved interfaces to be configured already. It assumes IPs have been assigned without using DHCP, though minor changes could account for that. The interfaces must also be active (not stopped). Thanks for Mickael Maddison pointing out that I hadn’t mentioned that.

Example Setup
In this example, I have a 10MBit Cable connection via Shaw on eth1, and a 6MBit ADSL connection via TELUS on eth2.
eth1 – IP 192.168.254.100 / Gateway 192.168.254.1
eth2 – IP 192.168.1.100 / Gateway 192.168.1.254

Simple Configuration
First, we need to add two lines to /etc/iproute2/rt_tables

1 Shaw
2 TELUS

And then set up the routing for those tables.

# ip route add 192.168.254.0/24 dev eth1 src 192.168.254.100 table Shaw
# ip route add default via 192.168.254.1 table Shaw
# ip route add 192.168.1.0/24 dev eth2 src 192.168.1.100 table TELUS
# ip route add default via 192.168.1.254 table TELUS
# ip rule add from 192.168.254.100 table Shaw
# ip rule add from 192.168.1.100 table TELUS

Set up evenly weighted round-robin routing for the interfaces.

# ip route add default scope global nexthop via 192.168.254.1 dev eth1 weight 1 nexthop via 192.168.1.254 dev eth2 weight 1

Fixes and workarounds
In the event that you receive a RTNETLINK answers: File exists error, replace the previous entry with…

# ip route append default scope global nexthop via 192.168.254.1 dev eth1 weight 1 nexthop via 192.168.1.254 dev eth2 weight 1


Then remove the earlier route:

# ip route del

Alternatively, omiting both

# ip route add default via 192.168.254.1 table Shaw
# ip route add default via 192.168.1.254 table TELUS
should prevent this as well.

Slightly more complex configurations
In addition to the basic setup here, the interfaces can be weighted differently, to favour one over the other (useful if one is a larger pipe, as in my setup here).

# ip route append default scope global nexthop via 192.168.254.1 dev eth1 weight 5 nexthop via 192.168.1.254 dev eth2 weight 3

In the case of IP-bound services (example: a GigaNews account, which does not allow simultaneous connections from different IPs), a static route is simple to configure:

# ip route add 216.196.97.131 via 192.168.254.1

If one of your ISP blocks DNS queries from non-subscribers, then you will need to ensure that your primary DNS server is ISP-agnostic. OpenDNS is a great solution for this. Add the appropriate entries to /etc/resolv.conf

nameserver 208.67.222.222
nameserver 208.67.220.220

Use this script as your one risk..

If you have 2 adsl line or 2 gateways use this script to loadbalance the line.

———–cut here————–

#!/bin/bash

#IPs of the def gateways

IP1=192.168.1.1

IP2=192.168.2.1

REDLOCAL=10.1.1.0/24

IPLOCAL=10.1.1.1

# NICs

IF1=eth0

IF2=eth1

ip rule add from $IP1 lookup T1

ip route add $REDLOCAL via $IPLOCAL table T1

ip route add 0/0 via $IP1 table T1

ip route add from $IP2 lookup T2

ip route add $REDLOCAL via $IPLOCAL table T2

ip route add 0/0 via $IP1 table T1

ip route default equalize nexthop via $IP1 dev $IF1 nexthop via $IP2 dev $IF2

————–cut here ———————

Cool Linux Advertising

Posted: October 16, 2009 in archlinux, Debian, Slackware

GPG key error in deb etch

Posted: October 15, 2009 in Debian

always problem with GPG error in deb etch 4.0

W: GPG error: http://security.debian.org etch/updates Release: The following signatures couldn’t be verified because the public key is not available: NO_PUBKEY 9AA38DCD55BE402B

issued this command

#gpg –key server pgp.uni-mainz.de –recv-keys 9AA38DCD55BE402B

next do:-

#gpg –armor –export 55BE302B | apt-key add –

#aptitude update

that’s all