9 great command line 1- liners

fuser [portnumber]/[proto]

find process associated with a port
e.g.
fuser 25/tcp (see which pid is listening on smtp)

du -hc *
Display total Kb/Mb/Gb of a folder and each file

ls -dF `find . -maxdepth 1 \( -perm -1 -o \( -perm -10 -o -perm -100 \) \) -print`
List just the executable files (or directories) in current directory

Does an ‘ls’ on just the files and directories in the current directory with an execute bit turned on. This version will list directories. Just tack on “-type f” to the start of the find to omit listing directories and list only files.

openssl ans1parse -inform DER < [priv key]
Identify a PKCS#8 Private Key

a pkcs8 key will have integer 00 at offset 4 and an rsaEncryption object at offset 9

python -m smtpd -n -c DebuggingServer localhost:1025
This command will start a simple SMTP server listening on port 1025 of localhost. This server simply prints to standard output all email headers and the email body.

chgrp -R [projgroup] ; find /path/to/dir -type d -exec chmod g+s {} \;
Turn /path/to/dir and subdirectories into a project tree

changes group ownership of all files/dirs in /path/to/dir to a project group [projgroup] and then gives the sgid bit to directories in that tree – all subsequently created files will inherit [projgroup]’s gid.

units “2048 bytes” “kibibytes”
easily convert one unit to another

Easily convert units of similar measurement. May also be invoked alone, units.

pkill -f foo (good for fighting viruses)
Be careful when issuing this command, it may kill unwanted processes!

To only search on the process name don’t use the argument -f, pkill foo

stty sane

Reset terminal that has been buggered by binary input or similar

Advertisements

Leave a Reply

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

WordPress.com Logo

You are commenting using your WordPress.com 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 )

Google+ photo

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

Connecting to %s