A Linux command line is a text interface to your Synology NAS. Often referred to as the shell, terminal, console, prompt or various other names, it can give the appearance of being complex and confusing to use. This little guide will teach you some basic command lines for your DSM 7, to become familiar with SSH. Let’s assume there’s no prior knowledge, but by the end I hope youāll feel a bit more comfortable the next time you’re faced with some instructions that begin with “Open a terminal” and log into your NAS. Note: DSM is a Linux operating system for Synology DiskStation and RackStation products.
STEP 1
Please Support My work by Making a Donation.
STEP 2
Follow my step by step guide on How to SSH into a Synology NAS or you can use the Task Scheduler (Example here) after that, try some basic command lines below.
Note: Be careful! Use only the command lines you need.
To edit a text file (using vi)
vi /location_of_file/file_nameTo go to a directory
cd /directoryNameTo make a directory
mkdir /directoryNameList contents of directory
dirCount the number of files in the current directory and its sub-directories
find . -type f | wc -lCheck size of directory and sub-directories
du -ah /path/to/dirFind a file
find / -name fileNameDelete a file
rm fileNameDelete a directory and its content
rm -r directoryNameMove or Rename a file
mv /sourceDirectory/sourceFile /destinationCopy a file
cp /sourceDirectory/sourceFile /destinationCopy groups of files
cp /sourceDirectory/*.* /destinationCopy a directory and any sub-directories
cp -r -p /sourceDirectory /destinationpathCreate an uncompressed tar (.tar) archive
To create an uncompressed (.tar) archive of all files, directories and subdirectories in the current directory:
tar -cvf archivefilename.tar *Create a compressed tar (.tgz) archive
To create a compressed (.tgz) archive of all files, directories and subdirectories in the current directory:
tar -cvzf archivefilename.tgz *Unpack .tar archives
For uncompressed .tar archives
tar xvf file.tarUnpack .tar.gz archives
For gzip compressed .tar.gz archives
tar xvzf file.tar.gzReboot your Synology NAS deviceĀ
rebootShutdown your Synology NAS device
poweroffStop a process on your Synology NAS
kill processIDStop a program on your Synology NAS
killall programNameDisplay most current processes running on your Synology NAS
topReport disk space usage on your Synology NAS
dfShow all current DSM processes
psShow currently open ports and their status on your Synology NAS
netstat -anChange Logged in user on your Synology NAS
If you are logged in as root/admin you can open a new shell as if you just logged in as another user, substitute xxx with the user name. To return to root session use the command line “exit”.
su ā xxxInstall an IPKG program package
Note: Install IPKG.
ipkg install fileNameUninstall an IPKG program package
ipkg remove filenameApache
/usr/syno/etc/rc.d/S97apache-user.sh restartAppletalk
/usr/syno/etc/rc.d/S81atalk.sh restartCron and Crond
/usr/syno/etc/rc.d/S04crond.sh stop
/usr/syno/etc/rc.d/S04crond.sh start
systemctl restart crond
systemctl restart synoscheduler
FTP
/usr/syno/etc/rc.d/S99ftpd.sh restartIndex
/usr/syno/etc/rc.d/S66synoindexd.sh restartItunes
/usr/syno/etc/rc.d/S99itunes.sh restartMySQL
/usr/syno/etc/rc.d/S21mysql.sh restartNFS
/usr/syno/etc/rc.d/S83nfsd.sh restartPostgresql
/usr/syno/etc/rc.d/S20pgsql.sh restartSamba
/usr/syno/etc/rc.d/S80samba.sh restartSSH
/usr/syno/bin/synosystemctl restart sshd.serviceSSH
/usr/syno/bin/synosystemctl stop sshd.serviceSSH
/usr/syno/bin/synosystemctl disable sshd.serviceSSH
/usr/syno/bin/synosystemctl enable sshd.serviceSSH
/usr/syno/bin/synosystemctl start sshd.serviceCheck system memory info
cat /proc/meminfoCheck CPU Info
cat /proc/cpuinfoCheck Interrupts in use
cat /proc/interruptsCheck the current File Systems in use
cat /proc/filesystemsComprehensive information on the file system format
tune2fs -l /dev/hda3Check the Linux Version of your DSM
cat /proc/versionCheck RAID Devices
cat /proc/mdstatCheck Environment Variables
envCheck what physical and logical disks/partitions you have in a multi-bay NAS
cat /proc/diskstatsor for all NAS types
cat /proc/partitionsor for similar, but different info
fdisk -lMiscellaneous for DSM 7
Clear terminal screen
clearNote: The command line above also works perfectly with DSM 6.2.4
This post was updated on Wednesday / February 19th, 2025 at 1:44 PM
