Basic commands to get around the Synology Box using the CLI: Difference between revisions

From wiki
Jump to navigation Jump to search
imported>Trolli
m (added check devices)
imported>Johayek
mNo edit summary
 
(44 intermediate revisions by 11 users not shown)
Line 2: Line 2:


==File Management==
==File Management==
===To edit a text file (using vi)===
For info on how to use vi see [[Linux VI Editor|Basic commands for Linux vi Editor]]
{| border="0" cellpadding="0" style="text-align:left"
|-
|<pre>vi /location_of_file/file_name</pre>
|-
|}
===To go to a directory===
===To go to a directory===
{| border="0" cellpadding="0" style="text-align:left"
{| border="0" cellpadding="0" style="text-align:left"
Line 16: Line 24:
|}
|}


===List Directory===
===List contents of Directory===
{| border="0" cellpadding="0" style="text-align:left"
{| border="0" cellpadding="0" style="text-align:left"
|-
|-
|<pre>dir</pre>
|<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>
|-
|-
|}
|}
Line 66: Line 88:
|}
|}


===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==
==System Management==
Line 101: Line 161:
|-
|-
|<pre>top</pre>
|<pre>top</pre>
|-
|}
===Report disk space usage===
{| border="0" cellpadding="0" style="text-align:left"
|-
|<pre>df</pre>
|-
|-
|}
|}
Line 107: Line 174:
{| border="0" cellpadding="0" style="text-align:left"
{| border="0" cellpadding="0" style="text-align:left"
|-
|-
|<pre>ps –ef</pre>
|<pre>ps</pre>
|-
|-
|}
|}


===Install program===
===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"
{| border="0" cellpadding="0" style="text-align:left"
|-
|-
Line 118: Line 202:
|}
|}


===Uninstall programs===
===Uninstall a ipkg program package===
{| border="0" cellpadding="0" style="text-align:left"
{| border="0" cellpadding="0" style="text-align:left"
|-
|-
|<pre>ipkg remove file name</pre>
|<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==
==System Information==
Line 153: Line 315:
|-
|-
|<pre>cat /proc/filesystems</pre>
|<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>
|-
|-
|}
|}
Line 163: Line 332:
|}
|}


===Check Devices===
===Check RAID Devices===
{| border="0" cellpadding="0" style="text-align:left"
{| border="0" cellpadding="0" style="text-align:left"
|-
|-
|<pre>cat /proc/mdstat</pre>
|<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>
|-
|-
|}
|}
Line 177: Line 365:
|-
|-
|}
|}
[[Category:SynologyWiki]]
[[Category:ToBeExported]]

Latest revision as of 17:37, 31 January 2015

File Management[edit]

To edit a text file (using vi)[edit]

For info on how to use vi see Basic commands for Linux vi Editor

vi /location_of_file/file_name

To go to a directory[edit]

cd /directoryName

Make a directory[edit]

mkdir /directoryName

List contents of Directory[edit]

dir

Count the number of files in the current Directory and its sub-directories[edit]

find . -type f | wc -l

Check size of Directory and sub-directories[edit]

du -ah /path/to/dir

Find a file[edit]

find / -name fileName

Delete a file[edit]

rm fileName

Delete a directory and its content[edit]

rm -r directoryName
  • Note: Use this command with great care

Move or Rename a file[edit]

mv /sourceDirectory/sourceFile /destination

Copy a file[edit]

cp /sourceDirectory/sourceFile /destination

Copy groups of files[edit]

cp /sourceDirectory/*.* /destination

Copy a directory and any sub directories[edit]

cp -r -p /sourceDirectory /destinationpath

Create a uncompressed tar (.tar) archive[edit]

To create a uncompressed (.tar) archive of all files directories and subdirectories in the current directory:

tar -cvf archivefilename.tar *

Create a compressed tar (.tgz) archive[edit]

To create a compressed (.tgz) archive of all files directories and subdirectories in the current directory:

tar -cvzf archivefilename.tgz *

Unpack .tar archives[edit]

For uncompressed .tar archives:

tar xvf file.tar

Unpack .tar.gz archives[edit]

For gzip compressed .tar.gz archives:

tar xvzf file.tar.gz

System Management[edit]

Reboot the Synology box[edit]

reboot

Shutdown the Synology box[edit]

poweroff

Stop a process[edit]

kill processID

Stop a program[edit]

killall programName

Display most current processes running[edit]

top

Report disk space usage[edit]

df

Show all current processes[edit]

ps

Show currently open ports and their status[edit]

netstat -an

Change Logged in user[edit]

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"

su – xxx

Install a ipkg program package[edit]

Note: This assumes you have already installed ipkg itself.

ipkg install fileName

Uninstall a ipkg program package[edit]

ipkg remove filename

Restart Services[edit]

apache[edit]

/usr/syno/etc/rc.d/S97apache-user.sh restart

appletalk[edit]

/usr/syno/etc/rc.d/S81atalk.sh restart

cron[edit]

/usr/syno/etc/rc.d/S04crond.sh stop
/usr/syno/etc/rc.d/S04crond.sh start

ftp[edit]

/usr/syno/etc/rc.d/S99ftpd.sh restart

index[edit]

/usr/syno/etc/rc.d/S66synoindexd.sh restart

itunes[edit]

/usr/syno/etc/rc.d/S99itunes.sh restart

mysql[edit]

/usr/syno/etc/rc.d/S21mysql.sh restart

nfs[edit]

/usr/syno/etc/rc.d/S83nfsd.sh restart

postgresql[edit]

/usr/syno/etc/rc.d/S20pgsql.sh restart

samba[edit]

/usr/syno/etc/rc.d/S80samba.sh restart

SSH[edit]

/usr/syno/etc.defaults/rc.d/S95sshd.sh restart

System Information[edit]

Check system memory info[edit]

cat /proc/meminfo

Check CPU Info[edit]

cat /proc/cpuinfo

Check Interrupts in use[edit]

cat /proc/interrupts

Check File Systems in use[edit]

cat /proc/filesystems

Comprehensive information on the file system format[edit]

tune2fs -l /dev/hda3

Check Linux Version[edit]

cat /proc/version

Check RAID Devices[edit]

cat /proc/mdstat

Check Enviroment Variables[edit]

env

Check what physical and logical disks/partitions you have[edit]

For multibay NASs and more info
cat /proc/diskstats

or for all NAS types

cat /proc/partitions

or for similar but different info

fdisk -l

Miscellaneous[edit]

Clear terminal screen[edit]

clear