Synology DSM (terminal) service control

DSM 6

Webuserinterface, Synology recommended:

Control Panel, Task Scheduler, Create Scheduled Task, Stop/Start Service

Terminal command:

ssh <admin account>@server

sudo -i

synoservicecfg --list

synoservicecfg --hard-stop <service>

synoservicecfg -stop <service>

synoservicecfg --hard-start <service>

synoservicecfg -start <service>

synoservice –status

synoservice –restart <service>

synoservicectl –restart <service>

Apache webserver:

stop pkg-apache22

start pkg-apache22

reload pkg-apache22


restart DSM Webapplication:

restart synoscgi


DSM 7

Terminal command:

ssh <admin account>@server

sudo -i

To list installed packages, try: synopkg list --name and hit Enter.
To stop a package, try: synopkg stop <package name> and hit Enter (EG synopkg stop USBCopy).
To start a package, try: synopkg start <package name> and hit Enter.
To restart a package (stops a package, then starts it), try: synopkg restart <package name> and hit Enter.

 

Restart HybridShare

synopkg restart HybridShare

 

 

 

 

 

Synology Wake on LAN

Synology Wake on LAN

Wake on Lan can be configured to wake up computers on the local network. The computer is directly connected to the same switch as the Synology NAS and wake on lan is supported by both the switch and the computers you are trying to wake.

Configuration:

 

  • Turn on Wake-on-LAN in the BIOS of the computer you want to wake
  • Change the Windows settings

 

 

 

  • Open control panel on the Synology NAS, task scheduler
  • Create Scheduled Task, user-defined script
  • User, root and schedule to run the task, do not repeat

 

 

  • Change the MAC address with the MAC address of your network card. Turn on Notification and select send run details by email

  • Run task and check email for details

If you need help please contact us.

 

Synology Drive Server Recommended Number of Hosted Files

Synology Drive Server Recommended Number of Hosted Files

Run the following command to find the amount of files indexed.

for v in `find /volume* -maxdepth 0`;do for cs in `find “$v/@synologydrive” -maxdepth 0`;do for v in `find “$cs/@sync/view” -name view-db.sqlite`;do sudo sqlite3 “$v” “select count(*) from node_table”;done;done;done|awk ‘{s+=$1} END {print “Total Count: “s}’

 

Synology SMB setting

Synology SMB setting

 

SSH connection:

for example admin@server

sudo -i

vi /etc/samba/smb.conf

Under global section:

server signing=mandatory
client signing=mandatory

min protocol=SMB2
max protocol=SMB3

The SMB connection with macOS can be checked with the following commands in a terminal session.

Does the SMB-server offers any shares;

smbutil lookup <servername>

Is there a SMB connection (smbfs);

mount

Which version SMB is used (SMB_version);

smbutil statshares -a

The SMB connection with Windows 10 can be checked with the following command in a terminal session.

net use

check which version SMB is used (SMB_version);

PowerShell:

Get-SmbConnection

Get-SmbConnection | Select-Object -Property *

Synology UPS NUT

Synology UPS NUT

Synology UPS NUT (network UPS Tools), connecting a Synology NAS to an UPS prevents dataloss or hardware failure in case of a power failure. It is also possible to turn off other network devices in case off a power failure. Synology has implemented NUT: http://networkupstools.org

 

Synology UPS NUT

Used configuration Synology UPS NUT:

Synology NAS connected via Dataport to APC Back-UPS ES 700.

Synology DSM 6.1 en 6.2

The configuration files on the Synology NAS  are found here:

/usr/syno/etc/ups, which you can access via a terminal

upsd.conf

upsd.users

ups.conf

After changing the file you can reload the configuration:

upsd -c reload

Settings via the Synology GUI
GUI, control panel, Hardware & Power, General

restart automatically after a power failure

GUI, control panel, Hardware & Power,UPS

Select Enable Network UPS Server, Permitted Disk Station Devices.

Select the devices who are allowed to connect.

To get UPS status information from another device and user:

you have to be in the upsd.users file and be in the list of permitted disk station devices, (control panel, Hardware & Power, UPS)

run the following command to check UPS information and status from another device:

upsc <name ups, see NAS /usr/syno/etc/ups/ups.conf>@<ip address NAS>

for example upsc ups@192.168.1.10

To change a value for example for testing:

upsrw -s battery.charge.low=<new value> -u <user, defined in upsd.conf NAS> -p <password user in upsd.conf> <name ups, see NAS /usr/syno/etc/ups/ups.conf>@<ip address NAS>

To install a nut client on a Mac:

I used Fink Project;  http://www.finkproject.org to install Fink Project.

To install nut on your Mac:

fink install nut

The configuration files:

/sw/etc/nut

upsmon.conf:

RUN_AS_USER root

MONITOR <name ups, see synology ups.conf>@<ip address> 1 <user, see synology upsd.users> <password, see synology upsd.users> slave

MINSUPPLIES 1

SHUTDOWNCMD "/sbin/shutdown -u -h +0"

NOTIFYCMD /sw/sbin/upssched

POLLFREQ 5

POLLFREQALERT 5

HOSTSYNC 15

DEADTIME 15

POWERDOWNFLAG /etc/killpower

NOTIFYFLAG ONLINE EXEC
NOTIFYFLAG ONBATT SYSLOG+EXEC
NOTIFYFLAG LOWBATT EXEC
NOTIFYFLAG NOCOMM EXEC
NOTIFYFLAG COMMBAD IGNORE
NOTIFYFLAG COMMOK IGNORE
NOTIFYFLAG SHUTDOWN IGNORE
NOTIFYFLAG FSD EXEC
NOTIFYFLAG NOPARENT SYSLOG

RBWARNTIME 43200

NOCOMMWARNTIME 300

FINALDELAY 5

upssched.conf

CMDSCRIPT /sw/bin/upssched-cmd

PIPEFN /sw/var/run/ups/upssched/upssched.pipe

LOCKFN /sw/var/run/ups/upssched/upssched.lock

AT ONBATT <name ups, see synology ups.conf>@<ip address> EXECUTE on-battery

/sw/bin/upssched-cmd:

case $1 in
upsgone)
logger -t upssched-cmd "The UPS has been gone for awhile"
;;

on-battery)
osascript -e 'tell app "System Events" to display dialog "Power failure. Save your work" giving up after 20 buttons {"OK"} default button 1 with icon caution'
;;

*)
logger -t upssched-cmd "Unrecognized command: $1"
;;
esac

To start upsmon manually: 

sudo upsmon -D (/sw/sbin/upsmon)

-D       Raise the debugging level. upsmon will run in the foreground and

prints information on stdout about the monitoring process. Use this

multiple times for more details.

upsmon -c stop ( stop monitoring and exit)

upsmon -c reload ( reread upsmon.conf) 

To start upsmon automatically on a macOS Sierra :

/Library/LaunchDaemons

-rw-r--r--   1 root  wheel   org.networkupstools.upsmon.plist

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>org.networkupstools.upsmon</string>
<key>RunAtLoad</key>
<true/>
<key>ProgramArguments</key>
<array>
<string>/sw/sbin/upsmon</string>
<string>-D</string> <!-- "-D" keeps upsmon from going into the background -->
</array>
<key>KeepAlive</key>
<true/>
<key>SuccessfulExit</key>
<false/> <!-- Do not respawn at shutdown time -->
</dict>
</plist>

To load manually:

sudo launchctl load /Library/LaunchDaemons/org.networkupstools.upsmon.plist

system.log:

com.apple.xpc.launchd[1] (org.networkupstools.upsmon): Unknown key for Boolean: SuccessfulExit
com.apple.xpc.launchd[1] (org.networkupstools.upsmon): This service is defined to be constantly running and is inherently inefficient.

To see if it is running:

sudo launchctl list|fgrep -v com.app

PID     Status  Label

<PID> 0 org.networkupstools.upsmon

ps -ef |grep upsmon

0 88 1 0 9:52AM 0:00.01 /sw/sbin/upsmon -D
0 167 88 0 9:52AM  0:00.50 /sw/sbin/upsmon -D

To install a nut client on Linux CentOS 6.9 :

Download the binary package of Feodora EPEL6, nut-client

Install on Linux machine with rpm command:

for example: rpm -ivh nut-client-2.6.5-2.el6.x86_64.rpm

make a user nutmon and at to group nut:

adduser nutmon

passwd nutmon

usermod -a -G nut nutmon

groups nut

Config files:

/etc/ups/

check nut group read rights upsmon.conf

upsmon.conf:

RUN_AS_USER nutmon

MONITOR <name ups, see synology ups.conf>@<ip address> 1 <user, see synology upsd.users> <password, see synology upsd.users> slave

MINSUPPLIES 1

SHUTDOWNCMD "/sbin/shutdown -h +0"

POLLFREQ 5

POLLFREQALERT 5

HOSTSYNC 15

DEADTIME 15

POWERDOWNFLAG /etc/killpower

RBWARNTIME 43200

NOCOMMWARNTIME 300

FINALDELAY 5

To run upsmon at startup:

chkconfig --list ups

chkconfig ups on

to check upsmon running:

service ups status

ps -ef |grep upsmon:

root          2271     1    0 Jul08 ?          00:00:00 /usr/sbin/upsmon

nutmon    2273  2271  0 Jul08 ?          00:00:09 /usr/sbin/upsmon

To start en stop upsmon:

service ups start

service ups stop

The nut client on Ubuntu 20.04 :

Check permission on Synology NAS to connect to network UPS server

Synology GUI, control panel, Hardware & Power,UPS

Select Enable Network UPS Server, Permitted Disk Station Devices.

Select the devices which are allowed to connect.

On Linux computer via the terminal.

  • Sudo apt install nut-client
  • Check permission on Synology NAS to connect to network UPS server

sudo upsc <user>@<synology server>

for example upsc ups@192.168.1.10

  • sudo adduser nutmon
  • sudo usermod -a -G nut nutmon
  • cd /etc/nut
  • sudo vi upsmon.conf:

RUN_AS_USER nutmon

MONITOR <name UPS>@<synology nas server> 1 <user> <password> slave

"slave" means this system shuts down immediately when power goes critical.

<powervalue> is an integer - the number of power supplies that this UPS

# feeds on this system.  Most computers only have one power supply, so this

# is normally set to 1.  You need a pretty big or special box to have any

# other value here.

For example:

MONITOR ups@192.168.1.10 1 monuser password slave

MINSUPPLIES 1

SHUTDOWNCMD "/sbin/shutdown -h +0"

POLLFREQ 5

POLLFREQALERT 5

HOSTSYNC 15

DEADTIME 15

POWERDOWNFLAG /etc/killpower

RBWARNTIME 43200

NOCOMMWARNTIME 300

FINALDELAY 5

  • sudo vi nut.conf

MODE=netclient

  • sudo systemctl enable nut-client
  • sudo systemctl start nut-client
  • sudo systemctl status nut-client

 

Need help. Klik hier to contact Diktio Solutions.

Synology Terminal Commands

Synology Terminal Commands

Synology Terminal Commando laat meerdere commando's zien die uitgevoerd kunnen worden na het maken van een ssh verbinding met de Synology NAS. Ssh moet wel eerst ingeschakeld worden op de Synology NAS om verbinding te kunnen maken.

Synology Terminal Commando

 

 

 

 

 

 

 

start terminal via ssh

ssh user@host

sudo -i

Geef nogmaals het wachtwoord op, hierna kunnen commando's uitgevoerd worden.

Check Network traffic and Bandwidth on Synology NAS.

synogear install

iftop

Synology Terminal commando check open port en programma:

netstat -natpu

-a, --all                display all sockets (default: connected)

-n, --numeric        don't resolve names

-p, --programs      display PID/Program name for sockets

-t                         display only TCP connections

-u.                       display only UDP connections

Synology check network performance

ifconfig

ethtool -S eth0

ethtool -g eth0

netstat -s -p TCP

Synology display activity like pid, processor, memory and

htop

Synology geheugengebruik

free -h

Check Space Usage

cd /volume1

du -h -d1

 

Synology reset Two-Factor Authentication

Synology reset 2FA with SSH enabled

Synology reset 2FA explains how to reset 2FA when SSH is still enabled. The commando’s are run via a terminal session and SSH has to be enabled on the Synology NAS server. In case there is only one administrator on the NAS to reset 2FA and this user has exceeded all standard 5 emergency codes then it is still possible to reset 2FA when SSH is turned on.

Synology terminal session

You have to make sure that SSH is enabled on the Synology NAS. This can be done from the control panel under Terminal & SNMP. For Windows you can use PuTTY to connect via SSH.

Terminal command:

ssh <admin user>@server

sudo -i

cd /usr/syno/etc/preference/

choose the user which 2FA you want to reset.

cd <user>

rm google_authenticator

 

Synology rsync synchronisation terminal

Synology rsync synchronisation terminal

Synology rsync synchronisation terminal explains the steps to synchronise two shared folders via the rsync protocol. The rsync commando's are executed in a terminal session that's why SSH must be enabled on the Synology NAS. Be careful running the terminal commands because files and folders can be deleted, running the commands is at your own risk. 

 

Synology rsync synchronisation terminal

Synology rsync synchronisation terminal access

You have to make sure that SSH is enabled on the Synology NAS. This can be done from the control panel under Terminal & SNMP. For Windows you can use PuTTY to connect via SSH.

Terminal command:

ssh <admin user>@server

sudo -i

Turn on rsync on the Synology NAS-servers

To turn on rsync on the Synology NAS open control panel, file services, enable rsync service. Both Synology NAS-servers should have the rsync service running otherwise the Synology rsync synchronisation terminal commands don't run.

Identify both folders for Synology rsync synchronisation

Choose which folder on the source Synology NAS you want to synchronise to the other Synology NAS server which will be the destination. When the folder on the destination doesn't exits it will be created but not seen in the control panel as a shared folder. You can make it a shared folder afterwards and the synchronised data will not be overwritten. It is also possible to create first the shared folder on the destination NAS before the synchronisation. The advantage here is that the folder is created with the correct settings like permissions.

Hyper Backup and the difference with Synology rsync synchronisation terminal commands

With Hyper Backup you can create a rsync copy (single-version). The disadvantage from this way is that a subfolders are created under the destination shared folder and not directly inside the shared destination folder. The rsync job will create a backup folder and is not suitable for this purpose.

Shared Folder Sync and the difference with Synology rsync synchronisation terminal commands

When you have already on the destination, shared folders with identical names as the source shared folders, the folders at destination will be renamed! When the folders don't exists on the destination the will be created. When you already have a shared folder on the destination and the data is quit large, deleting the folder will take more time than to synchronise only the differences. After the creating of the shared folder at the destination you cannot access the files without changing the permissions. Also changing the files/folders at the destination after changing the permissions will not result in synchronising the source folders to the destination, running a full synchronisation does the job.

Synology rsync synchronisation terminal commands

Let me start by saying to be careful how you proceed with the following commands because they will overwrite and delete files and folder!  So test first and check if the command is doing as expected.

Run the following Synology rsync synchronisation terminal commands at your own risk and first test before usage!!!!

Name Source Synology NAS server: server01

Name Destination Synology NAS server: server02

Shared folder on server01: test test

Shared folder on server02: test test

start terminal session on server01 or server02:

Terminal command:

ssh <admin user>@<servername>

sudo -i

command is run from server01 or server02:

Assumed volume1

Purpose: make source shared folder the same on the destination NAS.

Delete files/folders within the destination shared folder to make sure that the destination shared folder is the same as the source shared folder.

Running the Synology rsync synchronisation terminal command

Run the following Synology rsync synchronisation terminal commands at your own risk and first test before usage!!!!

from server 02:

rsync -avhz --delete <admin user>@server01:"'/volume1/test test/'" "/volume1/test test/"

from server 01:

rsync -avhz --delete "/volume1/test test/" <admin user>@server02:"'/volume1/test test/'"

-a, --archive               archive mode; equals -rlptgoD (no -H,-A,-X)

-v, --verbose               increase verbosity

-h human readable

-z, --compress              compress file data during the transfer

-r, --recursive             recurse into directories

-l, --links                 copy symlinks as symlinks

-p, --perms                 preserve permissions

-t, --times                 preserve modification times

-o, --owner                 preserve owner (super-user only)

-g, --group                 preserve group

     --devices               preserve device files (super-user only)

     --specials              preserve special files

-D                          same as --devices --specials

--delete delete files in the destination.

Synology scp commands

Synology scp command

Synology scp command via the terminal explains the steps to secure copy a folder to another NAS folder via the scp command. The scp command is executed in a terminal session that's why SSH must be enabled on the Synology NAS. Be careful running the terminal commands because files and folders can be deleted, running the commands is at your own risk. 

 

Synology scp command

Synology scp command terminal access

You have to make sure that SSH is enabled on the Synology NAS. This can be done from the control panel under Terminal & SNMP. For Windows you can use PuTTY to connect via SSH.

Terminal command:

ssh <admin user>@server

sudo -i

Identify both folders:

Choose which folder on the source Synology NAS you want to copy to the other Synology NAS server which will be the destination. If the destination folder doesn't exists you can create it before the copy.

Synology scp command

Let me start by saying to be careful how you proceed with the following commands because they will overwrite and delete files and folder!  So test first and check if the command is doing as expected.

Run the following scp command at your own risk and first test before usage!!!!

Name Source Synology NAS server: server01

Name Destination Synology NAS server: server02

Shared folder on server01: test test

Shared folder on server02: test test

start terminal session on server02:

Terminal command:

ssh <admin user>@server01

sudo -i

command is run from server01:

Assumed volume1

Purpose: make source shared folder the same on the destination NAS.

Secure copy files/folders within the source shared folder to the destination folder. Also copy hidden files.

Running the Synology scp command

Run the following scp command at your own risk and first test before usage!!!!

cd /volume1

pwd

scp -rp  test\ test/.  <admin user>@server02:"'/volume1/test test/'"

-r      Recursively copy entire directories. Note that scp follows symbolic links encountered in the tree traversal

-p     Preserves modification times, access times, and modes from the original file.

.       Will copy also hidden files.

Synology Change Connection

Synology change connection

Synology change connection shows how to change the connection without a new synchronisation. Sometimes you cannot change the connection because it is grayed out and you have to unlink first and make a new connection.

 

Synology change connection

 

Synology change connection settings Cloud Station ShareSync:

 

1. Use Chrome to login DSM and launch Cloud Station ShareSync to start editing the connection of the task.

2. Enable the Developer Tools:

3. Go to the Console tab:

4. Input the following command and hit enter:

document.querySelector(“.syno-dscc-create-wizard input[name=address]”).disabled = false;

5. Now it’s possible to edit the server address even it’s still greyed out:

 

6. Once it’s done, click on “Apply” to confirm and Cloud Station ShareSync would start connecting to the newly specified server address:

 

 

1 2 3