Categories
Linux

fortune cookies

$ for i in {1..20}; do fortune -w ; sleep 3; clear; done

if you are a slow reader adjust the sleep time accordingly.

Categories
Linux

a bash timer

$ alias timer='export ts=$(date +%s);p='\''$(date -u -d @"$(($(date +%s)-$ts))" +"%H.%M.%S")'\'';watch -n 1 -t banner $p;eval "echo $p"'

Categories
Linux

processes thread of a user

There are options with ps itself for better filter options, than may be doing it with grep, worth a try.

$ ps -LF -u user

Categories
Linux

chown me to who you are

use the other folder permission as reference. Here, changing the permission of all files in folder to the permission similar to the parent folder.

chown –reference=. ./*

Categories
Linux

copy the keys

easier than editing .ssh/authorized_keys file.

ssh-copy-id [email protected]

Categories
Linux

zombie hunting

find the zombie processes.

ps aux | awk ‘$8 == “Z” { print }’

Categories
Linux

apt is awesome

find the package name of the $file from the apt repository.

apt-cache search $file

Categories
Linux

looking for files modified some time back in a dir and its subdir

$ find . -type f -print0 | xargs -0 stat -c’%Y :%y %12s %n’ | sort -nr | cut -d: -f2- | head

Will go through all the files in the directory specified, uses `stat` to print out last modification time, then sorts numerically in reverse, then uses cut to remove the modified epoch timestamp and finally head to only output the last 10 modified files.

Categories
Linux

Check to see what’s running on a particular port

Whats running on this port.

$ sudo netstat -tulpn | grep :portnumber