Editing Basic commands to get around the Synology Box using the CLI

Jump to navigation Jump to search
Warning: You are not logged in. Your IP address will be publicly visible if you make any edits. If you log in or create an account, your edits will be attributed to your username, along with other benefits.

The edit can be undone. Please check the comparison below to verify that this is what you want to do, and then publish the changes below to finish undoing the edit.

Latest revision Your text
Line 1: Line 1:
__TOC__
'''1. Basic commands'''
 
  A. To go to a directory, command: cd /directory name
==File Management==
  B. To make a directory, command: mkdir /directory name
===To edit a text file (using vi)===
  C. Directory list, command: dir
For info on how to use vi see [[Linux VI Editor|Basic commands for Linux vi Editor]]
  D. To find a file, command: find / -name "file name"
{| border="0" cellpadding="0" style="text-align:left"
  E. To delete a file, command: rm file name
|-
  F. To delete directory and its content, command: rm –r directory name
|<pre>vi /location_of_file/file_name</pre>
  G. To move or rename a file, command: mv /directory name/file name /destination directory
|-
  H. To copy a file or files, command: cp /directory name/file name /destination directory
|}
  I. For more than one file, command: cp /directory name/*.* /destination directory
 
  J. To reboot the Synology box, command: reboot
===To go to a directory===
  K. To shutdown the Synology box, command: poweroff
{| border="0" cellpadding="0" style="text-align:left"
  L. Clear terminal screen, command: clear
|-
  M. To stop a process, command: kill process id
|<pre>cd /directoryName</pre>
  N. To stop a program, command: killall program name
|-
  O. Check system memory, command: cat /proc/meminfo or free
|}
  P. Check system CPU, command: cat /proc/cpuinfo
 
  Q. Check for interrupts in use, command: cat /proc/interrupts
===Make a directory===
  R. Check file system being used, command: cat /proc/filesystems
{| border="0" cellpadding="0" style="text-align:left"
  S. Check linux version, command, cat /proc/version
|-
  T. Shows the most current processes running, command: top
|<pre>mkdir /directoryName</pre>
  U. Shows all processes running, command: ps –ef
|-
  V. To install program, command: ipkg install file name
|}
  W. To remove a program, command: ipkg remove file name
 
===List contents of Directory===
{| border="0" cellpadding="0" style="text-align:left"
|-
|<pre>dir</pre>
|-
|}
 
===Count the number of files in the current Directory and its sub-directories===
{| border="0" cellpadding="0" style="text-align:left"
|-
|<pre>find . -type f | wc -l</pre>
|-
|}
 
===Check size of Directory and sub-directories===
{| border="0" cellpadding="0" style="text-align:left"
|-
|<pre>du -ah /path/to/dir</pre>
|-
|}
 
===Find a file===
{| border="0" cellpadding="0" style="text-align:left"
|-
|<pre>find / -name fileName</pre>
|-
|}
 
===Delete a file===
{| border="0" cellpadding="0" style="text-align:left"
|-
|<pre>rm fileName</pre>
|-
|}
 
===Delete a directory and its content===
{| border="0" cellpadding="0" style="text-align:left"
|-
|<pre>rm -r directoryName</pre>
|-
|}
*Note: Use this command with great care
 
===Move or Rename a file===
{| border="0" cellpadding="0" style="text-align:left"
|-
|<pre>mv /sourceDirectory/sourceFile /destination</pre>
|-
|}
 
===Copy a file===
{| border="0" cellpadding="0" style="text-align:left"
|-
|<pre>cp /sourceDirectory/sourceFile /destination</pre>
|-
|}
 
===Copy groups of files===
{| border="0" cellpadding="0" style="text-align:left"
|-
|<pre>cp /sourceDirectory/*.* /destination</pre>
|-
|}
 
===Copy a directory and any sub directories===
{| border="0" cellpadding="0" style="text-align:left"
|-
|<pre>cp -r -p /sourceDirectory /destinationpath</pre>
|-
|}
 
===Create a uncompressed tar (.tar) archive===
To create a uncompressed (.tar) archive of all files directories and subdirectories in the current directory:
{| border="0" cellpadding="0" style="text-align:left"
|-
|<pre>tar -cvf archivefilename.tar *</pre>
|-
|}
 
===Create a compressed tar (.tgz) archive===
To create a compressed (.tgz) archive of all files directories and subdirectories in the current directory:
{| border="0" cellpadding="0" style="text-align:left"
|-
|<pre>tar -cvzf archivefilename.tgz *</pre>
|-
|}
 
===Unpack .tar archives===
For uncompressed .tar archives:
{| border="0" cellpadding="0" style="text-align:left"
|-
|<pre>tar xvf file.tar</pre>
|-
|}
 
===Unpack .tar.gz archives===
For gzip compressed .tar.gz archives:
{| border="0" cellpadding="0" style="text-align:left"
|-
|<pre>tar xvzf file.tar.gz</pre>
|-
|}
 
==System Management==
 
===Reboot the Synology box===
{| border="0" cellpadding="0" style="text-align:left"
|-
|<pre>reboot</pre>
|-
|}
 
===Shutdown the Synology box===
{| border="0" cellpadding="0" style="text-align:left"
|-
|<pre>poweroff</pre>
|-
|}
 
===Stop a process===
{| border="0" cellpadding="0" style="text-align:left"
|-
|<pre>kill processID</pre>
|-
|}
 
===Stop a program===
{| border="0" cellpadding="0" style="text-align:left"
|-
|<pre>killall programName</pre>
|-
|}
 
===Display most current processes running===
{| border="0" cellpadding="0" style="text-align:left"
|-
|<pre>top</pre>
|-
|}
 
===Report disk space usage===
{| border="0" cellpadding="0" style="text-align:left"
|-
|<pre>df</pre>
|-
|}
 
===Show all current processes===
{| border="0" cellpadding="0" style="text-align:left"
|-
|<pre>ps</pre>
|-
|}
 
===Show currently open ports and their status===
{| border="0" cellpadding="0" style="text-align:left"
|-
|<pre>netstat -an</pre>
|-
|}
 
===Change Logged in user===
If you are logged in as root 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 "exit"
 
{| border="0" cellpadding="0" style="text-align:left"
|-
|<pre>su – xxx</pre>
|-
|}
 
===Install a ipkg program package===
Note: This assumes you have already installed ipkg itself.
{| border="0" cellpadding="0" style="text-align:left"
|-
|<pre>ipkg install fileName</pre>
|-
|}
 
===Uninstall a ipkg program package===
{| border="0" cellpadding="0" style="text-align:left"
|-
|<pre>ipkg remove filename</pre>
|-
|}
 
==Restart Services==
 
===apache===
{| border="0" cellpadding="0" style="text-align:left"
|-
|<pre>/usr/syno/etc/rc.d/S97apache-user.sh restart</pre>
|-
|}
 
===appletalk===
{| border="0" cellpadding="0" style="text-align:left"
|-
|<pre>/usr/syno/etc/rc.d/S81atalk.sh restart</pre>
|-
|}
 
===cron===
{| border="0" cellpadding="0" style="text-align:left"
|-
|<pre>/usr/syno/etc/rc.d/S04crond.sh stop
/usr/syno/etc/rc.d/S04crond.sh start</pre>
|}
 
===ftp===
{| border="0" cellpadding="0" style="text-align:left"
|-
|<pre>/usr/syno/etc/rc.d/S99ftpd.sh restart</pre>
|-
|}
 
===index===
{| border="0" cellpadding="0" style="text-align:left"
|-
|<pre>/usr/syno/etc/rc.d/S66synoindexd.sh restart</pre>
|-
|}
 
===itunes===
{| border="0" cellpadding="0" style="text-align:left"
|-
|<pre>/usr/syno/etc/rc.d/S99itunes.sh restart</pre>
|-
|}
 
===mysql===
{| border="0" cellpadding="0" style="text-align:left"
|-
|<pre>/usr/syno/etc/rc.d/S21mysql.sh restart</pre>
|-
|}
 
===nfs===
{| border="0" cellpadding="0" style="text-align:left"
|-
|<pre>/usr/syno/etc/rc.d/S83nfsd.sh restart</pre>
|-
|}
 
===postgresql===
{| border="0" cellpadding="0" style="text-align:left"
|-
|<pre>/usr/syno/etc/rc.d/S20pgsql.sh restart</pre>
|-
|}
 
===samba===
{| border="0" cellpadding="0" style="text-align:left"
|-
|<pre>/usr/syno/etc/rc.d/S80samba.sh restart</pre>
|-
|}
 
===SSH===
{| border="0" cellpadding="0" style="text-align:left"
|-
|<pre>/usr/syno/etc.defaults/rc.d/S95sshd.sh restart</pre>
|-
|}
 
==System Information==
 
===Check system memory info===
{| border="0" cellpadding="0" style="text-align:left"
|-
|<pre>cat /proc/meminfo</pre>
|-
|}
 
===Check CPU Info===
{| border="0" cellpadding="0" style="text-align:left"
|-
|<pre>cat /proc/cpuinfo</pre>
|-
|}
 
===Check Interrupts in use===
{| border="0" cellpadding="0" style="text-align:left"
|-
|<pre>cat /proc/interrupts</pre>
|-
|}
 
===Check File Systems in use===
{| border="0" cellpadding="0" style="text-align:left"
|-
|<pre>cat /proc/filesystems</pre>
|-
|}
 
===Comprehensive information on the file system format===
{| border="0" cellpadding="0" style="text-align:left"
|-
|<pre>tune2fs -l /dev/hda3</pre>
|-
|}
 
===Check Linux Version===
{| border="0" cellpadding="0" style="text-align:left"
|-
|<pre>cat /proc/version</pre>
|-
|}
 
===Check RAID Devices===
{| border="0" cellpadding="0" style="text-align:left"
|-
|<pre>cat /proc/mdstat</pre>
|-
|}
 
===Check Enviroment Variables===
{| border="0" cellpadding="0" style="text-align:left"
|-
|<pre>env</pre>
|-
|}
 
===Check what physical and logical disks/partitions you have===
{| border="0" cellpadding="0" style="text-align:left"
|-
|For multibay NASs and more info
<pre>cat /proc/diskstats</pre>
or for all NAS types
<pre>cat /proc/partitions</pre>
or for similar but different info
<pre>fdisk -l</pre>
|-
|}
 
==Miscellaneous==
===Clear terminal screen===
{| border="0" cellpadding="0" style="text-align:left"
|-
|<pre>clear</pre>
|-
|}
 
[[Category:SynologyWiki]]
[[Category:ToBeExported]]
Please note that all contributions to wiki may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see Wiki:Copyrights for details). Do not submit copyrighted work without permission!
Cancel Editing help (opens in new window)