frequent-command-line-hacks

Posted: December 31, 2009 in archlinux, Debian, Freebsd, Slackware
  • Read which processes are writing to the hard drive

    # echo 1 | sudo tee /proc/sys/vm/block_dump

    wait few seconds

    # echo 0 | sudo tee /proc/sys/vm/block_dump

    # dmesg | grep WRITE

  • Detect service and server versions using nmap:

    # nmap -A -T4 -F 192.168.1.1

  • Print the detailed statistics of transferred bytes by the firewall rules

    # sudo iptables -L -nv

  • Convert the bit rate of an MP3

    # lame -b 128 input.mp3 output.mp3

  • Setup wireless network from command line:

    # sudo iwconfig wlan0 essid MY_AP_ESSID
    # sudo iwconfig wlan0 key “12371272BCBCBABC1212”
    # sudo dhclient wlan0

    where wlan0 is the ID of network device.

  • Which process is accessing the CDROM

    # lsof -n | grep /media/cdrom

  • Convert DOS end of line to UNIX end of line

    # sed -e ‘s/\r$//’ inputfile > outputfile

    or

    # tr ‘\r’ ‘\n’ < inputfile > outputfile

  • Get the size of a directory

    # du -sh /home/blabla

  • Change MAC address of a network interface

    # sudo ifconfig wlan0 hw ether AA:AA:BB:BB:CC:DD

  • Change your password in a non-interactive shell (PHP, Python web shells). Edit and paste these lines in to your shell:

    passwd <<+++
    oldpasswd
    newpasswd
    newpasswd
    +++

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