Linux-Fu Part 2

Figured it’s high time for a nerd SysAdmin blog post.  This one will be particularly bland with some commands and tools I use to administer Linux systems.

Ever wanted to get a quick and dirty count of open files by process?

lsof | awk '{ print $1" "$2; }' | sort | uniq -c | sort -n

This is pretty useful when you’re starting to deep dive a system.

Take netstat to the next level and  look for active server network ports so you can tell users you support that their app is running

[root@deadbeef ~]# netstat -ntlp
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address               Foreign Address             State       PID/Program name
tcp        0      0    *                   LISTEN      4083/spread
tcp        0      0*                   LISTEN      4083/spread
tcp        0      0      *                   LISTEN      5138/python   
tcp        0      0       *                   LISTEN      3673/snmpd 
tcp        0      0       *                   LISTEN      4019/sendmail
tcp        0      0        *                   LISTEN      8942/sshd 
tcp        0      0      *                   LISTEN      4019/sendmail

Ever wanted to get dmidecode in a somewhat useful format?

[root@deadbeef ~]# for kw in $(dmidecode -s 2>&1 | sed -n '3,$p'); do echo -en "e[1m${kw}:e[0m "; echo $(dmidecode -s ${kw}); done
bios-vendor: Dell Inc.
bios-version: 2.3.1
bios-release-date: 04/29/2008
system-manufacturer: Dell Inc.
system-product-name: PowerEdge 1950
system-version: Not Specified
baseboard-manufacturer: Dell Inc.
baseboard-product-name: 0H878G
baseboard-version: A01
baseboard-serial-number: ..CN6970284D1596.
baseboard-asset-tag: Not Specified
chassis-manufacturer: Dell Inc.
chassis-version: Not Specified
chassis-asset-tag: Not Specified
processor-manufacturer: Intel Intel
processor-version: Intel(R) Xeon(R) CPU X5460 @ 3.16GHz Not Specified

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s