command line - Schnipsel

Sunday, April 15. 2012

Kleinigkeiten, die ich immer wieder nachsuchen muss: 

Recursively rename all files containing "dings" into "bums"
for i in `find .` ; do mv $i `echo $i | sed 's/dings/bums/'` ; done 

Recursively list all files '.forward' containing string 'bin'
find -type f -name '.forward' -exec grep -H -n 'bin' {} \;

in eine Logdatei protokollieren, was ein Programm so treibt:
strace -e trace=open -o logfile.log ./xyz

umount /dev/sdc1 scheitert, weil irgendeine Datei offen ist, wer hat sie?  
fuser -m /dev/sdc1

Recursively chmod only directories
find . -type d -exec chmod 755 {} \;

Recursively chmod only files
find . -type f -exec chmod 644 {} \;

Recursively chmod only files with extension .php
find . -type f -name '*.php' -exec chmod 644 {} \;

Recursively find all files > some size
find . -type f -size +10000000k -exec ls -lh {} \;

Recursively find all files > some size named like something and delete
find . -type f -size +100000k -name access.log -exec rm -i {} \;

Password generator
openssl rand -base64 32|head -c 12;echo 

View the contents of a certificate signing request (csr)
openssl req -text -noout -in host.csr
View x509 certificate details
openssl x509 -in filename.crt -noout -text 
View the fingerprint to verify ssh goes to the right machine directly
ssh-keygen -l -f /etc/ssh/ssh_host_rsa_key

alle an einem best Datum geaenderten Dateien auflisten:
ls -AlturR --time-style=long-iso  | grep ^.*2004\-03\-19.2.* >/home/dp/katalog_040319_2x:xx:xx.txt 

Haeufigkeit bestimmter Eintraege in messages nach Tagen sortiert ausgeben
grep DPT=1434 /var/log/messages >/var/log/SQL.slammer.txt
for i in 24 25 26 27 28; do j=`grep Jan\ $i SQL.slammer.txt -c`;echo $i, $j;done

user passwd fuer geschuetztes web-verzeichnis mit .htaccess anlegen
htpasswd -b /usr/local/httpd/.htpasswd user pass 

haessliches XML lesbar formatieren
xmllint –format ugly.xml –output pretty.xml


KDE clipboard history aus cli löschen
qdbus org.kde.klipper /klipper clearClipboardHistory







Trackback specific URI for this entry
    No Trackbacks


    No comments

Add Comment

Enclosing asterisks marks text as bold (*word*), underscore are made via _word_.
Standard emoticons like :-) and ;-) are converted to images.
E-Mail addresses will not be displayed and will only be used for E-Mail notifications.
To leave a comment you must approve it via e-mail, which will be sent to your address after submission.

To prevent automated Bots from commentspamming, please enter the string you see in the image below in the appropriate input box. Your comment will only be submitted if the strings match. Please ensure that your browser supports and accepts cookies, or your comment cannot be verified correctly.