Tagging-Archive: bash


update ownership for files

To transfer the ownership of files in a directory recursively from a user / group to another, you can use this simple one-liner: find . -user old_user -group old_group -print0 | xargs -0 chown -v -h new_user:new_group I have found it here. There also the individual parameters are explained in […]


bash – remove last char(s) from string 1

The last character of a string is very easy to remove in bash. out=”remove last char!” echo “${out%?}” returns remove last char To remove the last two characters: out=”remove last char!” echo “${out%%??}” returns remove last cha or use out=”remove last char!” echo ${out:0:$((${#out})) – 2} to also get remove […]


Bash – using variables outside a while loop 2

The bash runs every loop (while or for) in a subshell. The values for a variable defined inside such a loop / subshell are not available outside. #!/bin/bash t=0 while read line; do   t=$(( t + 1 )) done < /etc/passwd echo $t Returns 0 for $t but inside the […]


gpg: decryption failed: No secret key 2

When decrypt a gpp-file (gpg-d file.gpg> file) i got the error-message “gpg: decryption failed: No secret key”. It’s funny, the key is certainly there. A simple chmod o + rw $ (tty) has helped. Apparently gpg has inside the su environment a few problems. Sure, you can also set the […]


using ncftp-client for background ftp-transfers

I use for my ftp backups always ncftspooler. It´s a part of NcFTP Clients, which runs as a daemon und moves on request files to ftp-server. The installation is very simple: wget ftp://ftp.ncftp.com/ncftp/ncftp-3.2.5-src.tar.bz2 tar xfj ncftp-3.2.5-src.tar.bz2 cd ncftp-3.2.5 ./configure make make install mkdir /root/.ncftp mkdir /root/.ncftp/spool To start ncftpspool simply […]


rsnapshot remote

To save my data i use locally and remotely besides ftp backups rsnapshot. Thus, the data of the server are backed up every 2 hours on the disc. For a conventional backup it´s not enough – is the disk or the server off, then the backups are gone. But changes […]