$SHELL
Here I collect some commands that I often need but always forget.
Reconstruct standard permissions for directories and files in current directory
for i in `find .`; do [ -d $i ] && chmod 755 $i || chmod 644 $i; done
Find the command line of a program using a specific port
port=22
pid=$(lsof -Pan -i tcp -i udp | grep ":$port"|tr -s " " | cut -d" " -f2)
ps -Afe|grep "$pid"|grep --invert-match grep | sed "s/^\\([^ ]*[ ]*\\)\\{7\\}\\(.*\\)$/\\2/g"
Get the header of a website
curl -sI $URL
Get your current public IP address
curl ip.binfalse.de
Discover running Hosts in a Network
nmap -sP 192.168.1.*
Find large files recursively
find . -type f -size +50M -exec du -h {} \; | sort -n
Find files that have been modified in the past 60 minutes
find . -mmin 60 -type f
Convert encoding of a file
iconv -f utf8 -t utf16 /path/to/file
Unmount all NFS-mounts
umount -a -t nfs
Speed up copying
( cd /olddir ; tar cf - * ) | ( cd /newdir ; tar xvf - )
Merge various PDF files
gs -dNOPAUSE -sDEVICE=pdfwrite -sOUTPUTFILE=output.pdf -dBATCH first.pdf second.pdf
Convert spaces in file names to underscores
rename 'y/ /_/' *
Boot another OS at next startup
echo "savedefault --default=2 --once" | grub --batch; sudo reboot
Convert .flv to .avi
mencoder input.flv -ovc lavc -oac mp3lame -o output.avi
Delete all Flash cookies
find $HOME -name '*.sol' -exec rm {} \\;
Delete all crappy adobe/flash stuff:
rm -rf $HOME/.adobe $HOME/.macromedia
Display some cert infos
openssl s_client -connect google.de:443 2>/dev/null | sed -ne '/-BEGIN CERTIFICATE-/,/-END CERTIFICATE-/p' | openssl x509 -noout -subject -issuer -dates -hash -fingerprint
Of course also applicable for other ports than HTTPS
.
List connected LDAP clients
# Linux
netstat -n inet | awk '/:636/{print $5}' | cut -f1 -d: | sort -u
# Solaris
netstat -n -f inet | awk '/\\.636/{print $2}' | cut -f1-4 -d. | sort -u
If you aren’t using encrypted connections replace 636
with 389
.
Leave a comment
There are multiple options to leave a comment:
- send me an email
- submit a comment through the feedback page (anonymously via TOR)
- Fork this repo at GitHub, add your comment to the _data/comments directory and send me a pull request
- Fill the following form and Staticman will automagically create a pull request for you:
1 comment
Thanks for the command-lines. I’m sure I will use them.