Usefull linux commands/tricks

tags = []

These are some sort of notes to myself, this list will be constantly updated.

Sort directories by size (human readable size):

1
# du --max-depth=1 -h |sort -hr

Set tabsize to 4 in vim:

1
:set tabstop=4

Show failed login attempts on your machine:

1
# lastb -F

Print the most recent login of all users and of a given user:

1
2
# lastlog
lastlog -u USERNAME
1
2
$ curl -d "param1=value1&param2=value2" http://example.com/
$ curl -X POST -d @static http://example.com/

Return current SSID

1
iwconfig wlan0 | awk -F':' '/ ESSID/ {print $2}' | tr -d '"'

Force a reboot:

1
2
# echo 1 > /proc/sys/kernel/sysrq
# echo b > /proc/sysrq-trigger

Force a shutdown:

1
2
# echo 1 > /proc/sys/kernel/sysrq
# echo o > /proc/sysrq-trigger
1
find . -maxdepth 1 -type d -exec basename {} \;|xargs -L 1 -I '{}' chown {}:{} {}

Print text at LINE_NUMBER in a huge file

1
awk 'NR >= LINE_NUMBER && NR <= LINE_NUMBER' data.txt
Go Top