I was used to have a rsync call in my crontab to perform backup from my laptop to my desktop. My idea was to backup my laptop everyday even if I wasn’t at home, so before the time that the rsync ran I had to make sure that I was connected to my home network via OpenVPN and that my desktop was on. If the day was calm, no problem, but when I was busy at work that meant no backup for that day. I decided to code my own script to solve this problem. #!/bin/bash export DISPLAY=:0 #Vars for remote computer DSTUSR=user DSTROOT=root DSTIP=192.168.1.2 DSTFOLDER=/path/to/destionation/backup/folder/ #Vars for my OpenWrt router LINKSYS=192.168.1.1 LINKSSHPORT=22 LINKUSER=root PCTRL=0 PCTRL2=0 #this part checks if[…]

In order to allow a user to run a single command as root using sudo run the following as root: echo “user ALL= NOPASSWD : /bin/file” >> /etc/sudoers Where user is the specified username and /bin/file if the path to the binary that we are allowing this user to run. If you want to do further changes to the sudoers file it’s recommended to use the command ‘visudo’ to do so.Para poder hacer esta tarea solo tenemos que ejecutar el siguiente comando como root: echo “user ALL= NOPASSWD : /bin/file” >> /etc/sudoers Donde user es el usuario al que le queremos dar permisos y /bin/file es la dirección o path es el archivo binario que le vamos a permitir ejecutar.[…]