Various utility command lines
Here I put all the terminal, bash, windows commands that can be useful. It helps me forgetting them
Add recursively files to svn (support spaces):
svn st --ignore-externals | grep ^? | sed 's/? *(.*)/svn add "1"/' | sh
Convert a movie file to flv with ffmpeg:
ffmpeg -i inFile.avi -f flv -y outFile.flv
Find file older than x days:
find * [-maxdepth 0] [-daystart] -mtime +x
Get the listening services on a box (t=tcp, u=udp, n=numeric, l=listening, p=pid):
sudo netstat -plutn
Get the reverse of blocked hosts (with denyhosts for example):
cat /etc/hosts.deny | awk '{print $2}' | xargs -L 1 host
Save the installed package on ubuntu:
dpkg --get-selections > selections.txt
And restore them:
sudo apt-get update && sudo dpkg --set-selections < selections.txt && sudo apt-get dselect-upgrade
Know which Ubuntu version you are running:
lsb_release -a
Upgrade Ubuntu from command line:
sudo do-release-upgrade
Transfer folders with tar and ssh:
tar czf - folder/ | ssh user@domain.com tar xzf - -C destfolder/
Mirror a website with wget:
wget -mk [-e robots=off] http://www.example.com/
Put a ssh public key on a remote host:
cat ~/.ssh/id_dsa.pub | ssh user@website.com 'mkdir -p ~/.ssh && touch ~/.ssh/authorized_keys && cat - >> ~/.ssh/authorized_keys'
Copy only some files from one folder to another:
rsync -a --filter="+ *.EXT" --filter="+ */" --filter="- *" dir1/ dir2
Find all files that have specified bytes at specified position (bytes in hex):
find path/ -maxdepth -type f -name '*.*' -printf %p -exec od -An -j -N -t x1 {} \; | grep "hex1 hex2 hex3" -
Get an archive and unpack it in one go:
wget http://file.tar.gz -O - | tar -xvzf -
Remove empty folders recursively:
find -type d -empty -delete
List all writable files under windows:
dir /A:-D-R /S /B
