Find and shorten file and folder names with a certain length

Recently, I restructured my Synology NAS and encrypted all backup shared folders using AES-256 encryption. Therefore I had to find and shorten all files and folders with a certain character length. In general the activation of shared folder encryption is straightforward: Once encrypted, your data will be protected. However, there is a limitation on the […]

Create a bcrypt hash on commandline

Its easy to create a bcrypt hash  on commandline with this command: $> htpasswd -nbBC 10 USER PASSWORD Just replace the Placeholder USER and PASSWORD with the corresponding values. The Result should be something like that: USER:$2y$10$gfPbhclOrdjmMLEXSc5CTOWP5aBfjl59hhGvjp/qWXf1FfbQKb5ca The part before “:” is the username. The rest is the bcrypt password hash. The -C parameter specifies […]

Remove all files and folders including hidden files on bash

To remove all files and folders including hidden files such .gitignore, .htaccess, .git etc. on bash you can use the following command: $> rm -rf /PATH/TO/FOLDER/{*,.*} Is the same as: $> rm -rf ${DOCROOT}/* $> rm -rf ${DOCROOT}/.* But ever shorter. 😉

Wipe a disk via Linux shell

This is how to wipe a disk via Linux shell: $> sudo shred -v -n2 -z /dev/sdc The command above erases all data on the device /dev/sdc and overrides the data 2 times. Finally every bit is overridden by zeros. So in sum it takes 3 iterations to wipe a disk via Linux shell. n specifies […]

wordpress cron: using wp_mail function

Today I had to solve the problem, that my wordpress cron throws an exception like this when sending an email via wp_mail function inside a cron scheduled event function. PHP Fatal error: Uncaught exception ‘phpmailerException’ with message ‘Invalid address: (setFrom) wordpress@’ in /var/www/clients/client2/web8/web/wp-base/wp-includes/class-phpmailer.php:1023 Stack trace: #0 /var/www/clients/client2/web8/web/wp-base/wp-includes/pluggable.php(352): PHPMailer->setFrom(‘wordpress@’, ‘WordPress’, false) #1 /var/www/clients/client2/web8/web/wp-base/wp-content/plugins/sheldon_misc/admin/class-sheldon_misc-admin.php(183): wp_mail(‘info@ask-sheldon.com….’, ‘Statusmailing i…’, […]

Delete x files from folder in a for i loop

Recently I tried to remove a big bunch of files from one of my raspberry pies where ffmpeg had swamped my SD-card with too many capture images. So I had to delete x files from folder. I just tried: rm -rf *.jpg But that gave me an “unable to execute /bin/rm: Argument list too long” […]

Count search results on Linux shell

Lets imagine you want to search for a term in a file and you want to know, how often it can be found in the file. With this command combination you can count search results on bash: $> less xmlfile.xml | grep SearchmeIfYouCan | wc -l This is how this way to count search results […]

Formatted CSV output on Linux shell

If you want to output a CSV file on Linux shell, you could just open it with less, cat or nano (un-formatted CSV output): $> less mydummyfile.csv $> cat mydummyfile.csv $> nano mydummyfile.csv The problem with this approach is, that you will get an unformatted ugly chunk of characters like that: A much better way is it, […]

SFTP connection via keyfile

You can connect to an SFTP server via keyfile like that: $> sftp -v -o IdentityFile=”/PATH/TO/PUBLICKEYFILE(id_rsa)” -o Port=”10022″ user@host  

Rename files to upper or lower case

To Rename file to upper case or lower case (* == file selector): Convert to lower case file names Convert to upper case