My list of useful commands

Hi I just want to share some useful commands with you that I use often in a linux terminal
I will likely update this once in a while, feel free to comment.
Last updated: 2017-02-07

list files sorted last modified last

$ ls -ltrh

I sometimes use this in /var/log to quickly see which files has been written to recently

list files sorted by size smallest first

ls -lSrh

When your're out of space or need space, this is will quickly show you which files you can (move/delete) to get more space

show all icmp traffic on eth0

tcpdump -nti eth0 icmp

I sometimes use to troubleshoot network issues, does the host receive the ping i sent or is it the icmp echo reply that gets stuck somewhere?

comment out a file

sed -i 's/^/#/g' /etc/some/app.conf

this will undo above command

sed -i 's/^#//g' /etc/some/app.conf

Search recursively for a string

grep -RnH "Port 22" /etc/   

if you get too many "Permission denied" messages with this one, then you either need to run this as root or throw them away like this:

grep -RnH "Port 22" /etc/ 2> /dev/null