Count number of items in list.

items=['a','b','c']
size=len(items)

print size

# 3

python: get mp3 meta info

apt-get install python-mutagen

#!/usr/bin/python
from mutagen.mp3 import MP3
import os

for root, dirs, files in os.walk(‘/mnt/music’):
for name in files:
joined=os.path.join(root, name)
audio=MP3(joined)
if audio.info.bitrate < 128000:
print joined
print audio.info.bitrate

Check for open ports/services on remote machine

$ telnet titan.zipcon.net 22
Trying 63.249.22.50…
Connected to titan.zipcon.net.
Escape character is ‘^]’.
SSH-2.0-OpenSSH_5.1p1 Debian-3ubuntu1

List who is logged in to your linux box

w
14:16:50 up 2 days, 23:54,  4 users,  load average: 0.24, 0.16, 0.07
USER     TTY      FROM              LOGIN@   IDLE   JCPU   PCPU WHAT
jesterj  tty7     :0               Fri14    3days 24:30m  0.30s x-session-manag
jesterj  pts/0    :0.0             14:13    0.00s  0.10s 19.94s gnome-terminal
jesterj  pts/2    :0.0             11:52    2:23   0.20s  0.10s ssh jesterj@pse
jesterj  pts/1    :0.0             11:23    2:34   0.16s  0.06s ssh jesterj@pse

View all open ports with Netstat

$ netstat -nta
Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address           Foreign Address         State
tcp        0      0 0.0.0.0:6024            0.0.0.0:*               LISTEN
tcp        0      0 127.0.0.1:3306          0.0.0.0:*               LISTEN
tcp        0      0 0.0.0.0:22              0.0.0.0:*               LISTEN
tcp        0      0 127.0.0.1:631           0.0.0.0:*               LISTEN
tcp        0      0 127.0.0.1:25            0.0.0.0:*               LISTEN
tcp        0      0 10.139.68.153:42651     10.139.68.39:22         ESTABLISHED
tcp        0      0 10.139.68.153:51346     64.4.34.126:1863        ESTABLISHED
tcp        0      0 10.139.68.153:44434     206.255.61.214:4228     ESTABLISHED
tcp        0      0 10.139.68.153:38705     205.234.235.90:80       ESTABLISHED
tcp        0      0 10.139.68.153:38707     205.234.235.90:80       ESTABLISHED
tcp        0      0 10.139.68.153:40101     64.4.37.39:1863         TIME_WAIT
tcp        0      0 10.139.68.153:38708     205.234.235.90:80       ESTABLISHED
tcp        0      0 10.139.68.153:52217     10.139.10.45:22         ESTABLISHED
tcp        0      0 10.139.68.153:38702     205.234.235.90:80       ESTABLISHED
tcp        0      0 10.139.68.153:38709     205.234.235.90:80       ESTABLISHED
tcp        0      0 10.139.68.153:38710     205.234.235.90:80       ESTABLISHED
tcp6       0      0 :::80                   :::*                    LISTEN
tcp6       0      0 :::22                   :::*                    LISTEN