Synology - Setting a personal VPN with the NAS

Prerequisite: If you do not have a static IP, enable and set the DDNS on the SYNOLOGY NAS.

SETTING THE SYNOLOGY

  • Install the package [VPN Server] in the Synology NAS.
  • In my opinion (and for my needs) it's better to create only one VPN user and give the permision to fruition the VPN enviroment only to him. It's better that the password is very complex.
  • Run it. In the left, from the group [Set up VPN Server], select [OpenVPN].
  • Put a tick in [Enable OpenVPN server].
  • Change the range of the Dinamic IP, if needed.
  • Take note of the port "1194" and the protocol "UPD": it will be needed for setting the port forwarding in the Firewall.
  • Click on [Export configuration] to have a zip archive content the certificate [ca.crt] and the configurations [VPNConfig.ovpn]

SETTING THE FIREWALL

Setting the firewall that's connected to the NAS, creating a rule with this parameter:
    name VPN
    protocol UPD
    local IP address
[the IP of the NAS, it's better to give him a static internal IP]
    local port 1194

        (or range 1194-1194)
    WAN IP address ANY
    WAN port 1194

        (or range 1194-1194)

SETTING OPENVPN IN WINDOWS

From here, download OpenVPN and install it on the PC.
Run OpenVPN GUI as administrator.
Get VPNConfig.ovpn from the zip archive, edit it:
    replace YOUR_SERVER_IP with the public IP of NAS or the hostname registered in the DDNS service of your NAS Synology
    add those lines:
        auth-user-pass auth.txt
        route 0.0.0.0 0.0.0.0 vpn_gateway 500
Put it in C:\Program Files\OpenVPN\config
Ever in C:\Program Files\OpenVPN\config create a file named auth.txt
Edit it adding two lines: in the first one the user name created in Synology and in the second one its password.


CREATE AN AUTOMATIC TASK IN WINDOWS

Create a task in Task Scheduler with these rules:
    At log on, 
    start C:\Program Files\OpenVPN\bin\openvpn-gui.exe
    with those parameters --connect VPNConfig.ovpn

Linux - share DVD-ROM through the LAN

Prerequisite: Samba has to be installed and I suppose that the hostname of your PC is MyPC.

Create a directory in /media
   sudo mkdir /media/DVD
 

Modify /etc/fstab by adding this line:
   /dev/sr0 /media/DVD iso9660 defaults,noauto,ro,user,uid=1000,gid=1000 0 0

   (one line)

Add (or check if it is already there) those lines in /etc/samba/smb.conf
   [DVD-ROM]
      path = /media/DVD
      browseable = yes
      read only = yes
      guest ok = yes
      locking = no
      preexec = /bin/mount /media/DVD
      postexec = /bin/umount /media/DVD
      writable = no

 

Reread /etc/fstab
   sudo mount -a 

   (ignore the errors that appears: it attempts to mount some already mounted devices)

Restart Samba
  sudo service smbd restart

Put a DVD/CD into the drive and check the share:
   in MAC
      Finder > Go > Connect to Server...
         type: smb://MyPC and press enter
         Select Guest as user name
   in Windows
      Open the File Explorer
      type \\MyPC and press enter

Windows - W10 delete Grub settings

Scenario: You have installed W10 beside Linux (Ubuntu or Ubuntu based) but after this job, Grub disappear and you are not longer able to select the S.O. at the boot. 

  • Start with W10
  • Open a DOS prompt with administrator privilege
  • execute this command:
    • bcdedit /set {bootmgr} path \EFI\ubuntu\grubx64.efi
  • Restart your computer with a live Ubuntu distribution
  • Open a terminal (Ctrl Alt T)
  • Regenerate Grub with this command:
    • sudo update-grub

Linux - analize space used by installed packages

With this command you can get a list of installed packages, order by size:
  • dpkg-query --show --showformat='${Package;-50}\t${Installed-Size}\n' | sort -k 2 -n | grep -v deinstall | awk '{printf "%.3f MB \t %s\n", $2/(1024), $1}'

Linux - get rid of all NVIDIA drivers from pc

You can see which NVIDIA packages are installed on your pc, typing
  • dpkg -l | grep -i nvidia
and you can take note of the right package's name to uninstall.

It's not always recommended but you can use this command to remove it all in one shot:
  • sudo apt-get autoremove nvidia*

Linux - Mint doesn't wake up after screen is locked and blank

Be careful, this is only a work around.


This feature is a part of usbcore which is compiled in the kernel.

From https://unix.stackexchange.com/a/175035.


  • Edit
    • /etc/default/grub 
  • Change 
    • GRUB_CMDLINE_LINUX_DEFAULT 
  • Add this option at the end
    • usbcore.autosuspend=-1
  • That's the result 
    • GRUB_CMDLINE_LINUX_DEFAULT="quiet splash usbcore.autosuspend=-1" 
  • Save the file and update grub
    • sudo update-grub 
  • Reboot

    Now, if you check the autosuspend value with 

    • cat /sys/module/usbcore/parameters/autosuspend
    it should display -1.

Linux - set display resolution via terminal

xrandr --output VGA-0 --mode 1024x768 --pos 1680x0 --rotate normal --output LVDS --mode 1680x1050 --pos 0x0 --rotate normal --output S-video --off --output DV

Linux - work on PDF files via terminal

To reduce a huge PDF 
    gs -dNOPAUSE -dBATCH -sDEVICE=pdfwrite -dCompatibilityLevel=1.4 -dPDFSETTINGS=/ebook -sOutputFile=reductedNewFile.pdf hugeOldFile.pdf

To convert to grey scale
 
    convert -colorspace GRAY color.pdf gray.pdfconvert -colorspace GRAY-density 400 -quality 100 color.pdf gray.pdf     convert -colorspace GRAY-density 200 -quality 100 color.pdf gray.pdf     
    convert -colorspace GRAY-density 100 -quality 100 color.pdf gray.pdf

To concatenate jpg in one pdf

     convert *.jpg pictures.pdf    convert -quality 100 -sharpen 0x1.0 *.JPG pdfFile.pdf

To concatenate pdfs in one pdf

     pdftk pdf1.pdf pdf2.pdf pdfN.pdf output newconcatenated.pdf

To split pages
     pdftk myoldfile.pdf cat 1 2 4 5 output mynewfile.pdf

To rotate the first PDF page to 90 degrees clockwise
 
    pdftk in.pdf cat 1east 2-end output out.pdf

Rotate an entire PDF document to 180 degrees
 
    pdftk in.pdf cat 1-endsouth output out.pdf

Linux - to enable a RSync server

1. Enable the rsync (RSYNC_ENABLE=true) in target server (Debian)

nano /etc/default/rsync
change the RSYNC_ENABLE=false to RSYNC_ENABLE=true

2. Create the file /etc/rsyncd.conf

nano /etc/rsyncd.conf
append the following text, then save

pid file = /var/run/rsyncd.pid
lock file = /var/run/rsync.lock
log file = /var/log/rsync.log

[rsync]
path = /rsync [path to the destination directory]
uid = root
gid = root
read only = no
list = yes
auth users = root
secrets file = /etc/rsyncd.secrets

3. Create the rsync share

mkdir /rsync [path to the destination directory]
Create the /etc/rsyncd.secrets
nano /etc/rsyncd.secrets
- append root:password, which is in the form username:password
Limit access to file owner
- chmod 600 /etc/rsyncd.secrets

4. Restart rsync

/etc/init.d/rsync restart