ciphermethod.com

Linux

Which application is using a Linux network port?

by on Feb.01, 2011, under Linux, Networking

Use: netstat -tlnp | grep port

Example using netstat:
[root@trioxin2 jhopkins]# netstat -tlnp | grep 80
tcp 0 0 :::80 :::* LISTEN 4246/httpd

The above example reveals that the httpd process with a PID of 4246 is running on port 80.

To verify, you can run the ps command and grep for the application name or PID:
[root@trioxin2 jhopkins]# ps -ef | grep 4246
root 4246 1 0 13:35 ? 00:00:00 /usr/sbin/httpd
apache 4249 4246 0 13:35 ? 00:00:00 /usr/sbin/httpd
apache 4250 4246 0 13:35 ? 00:00:00 /usr/sbin/httpd
apache 4251 4246 0 13:35 ? 00:00:00 /usr/sbin/httpd
apache 4252 4246 0 13:35 ? 00:00:00 /usr/sbin/httpd
apache 4253 4246 0 13:35 ? 00:00:00 /usr/sbin/httpd
apache 4254 4246 0 13:35 ? 00:00:00 /usr/sbin/httpd
apache 4255 4246 0 13:35 ? 00:00:00 /usr/sbin/httpd
apache 4256 4246 0 13:35 ? 00:00:00 /usr/sbin/httpd

Example using fuser:
# fuser 80/tcp
80/tcp: 3130 7057 11956 11957 11958 26771 26801 30170 32433 32434 32766

# ps -ef | grep 3130
root 3130 1 0 Mar02 ? 00:01:19 /usr/sbin/apache2 -k start
www-data 7057 3130 0 Apr01 ? 00:01:18 /usr/sbin/apache2 -k start
www-data 11956 3130 0 Apr04 ? 00:00:23 /usr/sbin/apache2 -k start
www-data 11957 3130 0 Apr04 ? 00:00:38 /usr/sbin/apache2 -k start
www-data 11958 3130 0 Apr04 ? 00:00:42 /usr/sbin/apache2 -k start
www-data 26771 3130 0 Apr03 ? 00:00:54 /usr/sbin/apache2 -k start
www-data 26801 3130 0 Apr03 ? 00:00:50 /usr/sbin/apache2 -k start

Leave a Comment more...

How To Change MAC Address

by on Nov.11, 2010, under Linux, Networking

f4:43:2f:a3:93:95 = new MAC

# ifconfig eth0 down
# ifconfig eth0 hw ether f4:43:2f:a3:93:95
# ifconfig eth0 up

Leave a Comment more...

Generate Random MAC Address

by on Nov.11, 2010, under Linux, Networking

From a Linux BASH command line:
openssl rand -hex 6 | sed ‘s/\(..\)/\1:/g; s/.$//’

Example:
[neo@trinity ~]$ openssl rand -hex 6 | sed ‘s/\(..\)/\1:/g; s/.$//’
28:97:1c:70:73:4d

Leave a Comment more...

20100913: adddirs.sh

by on Sep.13, 2010, under Linux, Scripts

#!/bin/sh
#20100913 – Add log directories to get total log space

for x in `cat linux.servers`
do
  echo $x:
  R=`ssh $x sudo du -h /var/log | tail -1`
  N=`echo $R | cut -f1 -dM`
sum=$(($COUNT + $N))
  COUNT=$sum
  echo $COUNT $N

  echo
done

Leave a Comment more...

20100421: changelin.sh

by on Apr.21, 2010, under Linux, Scripts

#!/bin/sh
# 20100421 – Created by Jamey Hopkins
echo
echo “Change Users Linux/AIX Password”
echo

if [ “$1” = “” ]
then
echo need server list
echo example: $0 servers.txt
echo
exit
fi

if [ ! -f $1 ]
then
echo “Server list $1 not found.”
echo
exit
fi

echo -n “Enter Users Login: ”
read LOGIN

echo “Enter new password”
echo -n “Password: ”
stty -echo
read PASS1
stty echo
echo
echo “Enter password again”
echo -n “Password: ”
stty -echo
read PASS2
stty echo

echo

if [ “$PASS1” != “$PASS2” ]
then
echo passwords did not match
exit
fi

LIST=$1

echo “$LOGIN:$PASS1” >account.info

for X in `cat $LIST`
do
echo Performing Password Change for $LOGIN on $X
scp ./account.info $X: >/dev/null
ssh $X “cat account.info | sudo /usr/sbin/chpasswd” >/dev/null
ssh $X rm account.info
done

rm account.info

Leave a Comment more...

Looking for something?

Use the form below to search the site:

Still not finding what you're looking for? Drop a comment on a post or contact us so we can take care of it!

But Wait, There's More!

A few highly recommended friends...