Changes

42,169 bytes added ,  10:10, 9 June 2020
Created page with "__TOC__ ==Summary== In this topic we will cover the basic CLI / SSH commands for beginners. It will help users manage and troubleshoot RUTxxx, RUTXxx, TRB14X devices. Note:..."
__TOC__
==Summary==
In this topic we will cover the basic CLI / SSH commands for beginners. It will help users manage and troubleshoot RUTxxx, RUTXxx, TRB14X devices.

Note: With almost every command, ‘--help’ option shows usage summary for that command. The commands have the following syntax:

''$command options arguments''

==Command table==

This section provides a list of basic CLI / SSH commands and options.

{| class="wikitable"
|+ style="text-align: left;" |CLI commands
! style="width: 100px; background: black; color: white;" |Command
! style="width: 340px; background: black; color: white;" |Syntax
! style="width: 1200px; background: black; color: white;" |Description
|-
! style="text-align: left; vertical-align: top;" |File commands
| style="text-align: left; vertical-align: top;" |
| style="text-align: left; vertical-align: top;" |
|-
! style="text-align: left; vertical-align: top;" |''pwd''
| style="text-align: left; vertical-align: top;" |pwd
| style="text-align: left; vertical-align: top;" |Show current working directory.
|-
! style="text-align: left; vertical-align: top;" |''cd''
| style="text-align: left; vertical-align: top;" |cd </path-to-directory>
| style="text-align: left; vertical-align: top;" |Change the current working directory to the directory provided as argument. If no argument is given to ''cd'', it changes the directory to the user's home directory.
|-
! style="text-align: left; vertical-align: top;" |''ls''
| style="text-align: left; vertical-align: top;" |ls <files-or-directories>
| style="text-align: left; vertical-align: top;" |List files or directories. Example: ''ls /etc/config/''
|-
! style="text-align: left; vertical-align: top;" |''mkdir''
| style="text-align: left; vertical-align: top;" |mkdir <dir1>
| style="text-align: left; vertical-align: top;" |Creating a directory “dir1”.
|-
! style="text-align: left; vertical-align: top;" |''touch''
| style="text-align: left; vertical-align: top;" |touch <file1>
| style="text-align: left; vertical-align: top;" |Create empty file “file1”.
|-
! style="text-align: left; vertical-align: top;" |''cp''
| style="text-align: left; vertical-align: top;" |cp <file1> <file2>
| style="text-align: left; vertical-align: top;" |Copy the contents of “file1” to “file2”.
|-
! style="text-align: left; vertical-align: top;" |''cp -r''
| style="text-align: left; vertical-align: top;" |cp –r <dir1> <dir2>
| style="text-align: left; vertical-align: top;" |Copy “dir1” to “dir2”; creates “dir2” if not present.
|-
! style="text-align: left; vertical-align: top;" |''mv''
| style="text-align: left; vertical-align: top;" |mv <file1> <file2>
| style="text-align: left; vertical-align: top;" |Move files or directories.
|-
! style="text-align: left; vertical-align: top;" |''rm''
| style="text-align: left; vertical-align: top;" |rm <file1>
| style="text-align: left; vertical-align: top;" |Deleting the file “file1”.
|-
! style="text-align: left; vertical-align: top;" |''rm -r''
| style="text-align: left; vertical-align: top;" |rm –r <dir1>
| style="text-align: left; vertical-align: top;" |Deleting the directory “dir1”.
|-
! style="text-align: left; vertical-align: top;" |''cat''
| style="text-align: left; vertical-align: top;" |cat <file1>
| style="text-align: left; vertical-align: top;" |To view the contents of a “file1”. Example: ''cat /etc/config/system''
|-
! style="text-align: left; vertical-align: top;" |''vi''
| style="text-align: left; vertical-align: top;" |vi <file1>
| style="text-align: left; vertical-align: top;" |Open a file with ''vi'' for editing. Press ‘i’, to enter INSERT mode, and start editing file. Press Esc to exit INSERT mode. Press ‘:x’ and 'Enter'. Changes will be saved.
|-
! style="text-align: left; vertical-align: top;" |Search commands
| style="text-align: left; vertical-align: top;" |
| style="text-align: left; vertical-align: top;" |
|-
! style="text-align: left; vertical-align: top;" |''grep''
| style="text-align: left; vertical-align: top;" |grep <pattern> <file>
| style="text-align: left; vertical-align: top;" |The ''grep'' command searches for a pattern in a file. Example to grep only version info from system file: ''grep version /etc/config/system''
|-
! style="text-align: left; vertical-align: top;" |''find''
| style="text-align: left; vertical-align: top;" |find <path> -name <"pattern">
| style="text-align: left; vertical-align: top;" |Find files or directories in specified directory that start with "pattern". Example: ''find / -name "modbus"''
|-
! style="text-align: left; vertical-align: top;" |Piping commands
| style="text-align: left; vertical-align: top;" |
| style="text-align: left; vertical-align: top;" |
|-
! style="text-align: left; vertical-align: top;" | |
| style="text-align: left; vertical-align: top;" |<nowiki><command1> | <command2> ...</nowiki>
| style="text-align: left; vertical-align: top;" |Pipe is a command that lets you use two or more commands such that output of one command serves as input to the next. Example, how to see only dhcp info from logread file: ''logread''<nowiki> |</nowiki>''grep dhcp''
|-
! style="text-align: left; vertical-align: top;" |Process commands
| style="text-align: left; vertical-align: top;" |
| style="text-align: left; vertical-align: top;" |
|-
! style="text-align: left; vertical-align: top;" |''ps''
| style="text-align: left; vertical-align: top;" |ps
| style="text-align: left; vertical-align: top;" |Show the currently working processes.
|-
! style="text-align: left; vertical-align: top;" |''kill''
| style="text-align: left; vertical-align: top;" |kill <pid>
| style="text-align: left; vertical-align: top;" |Kill the process with given pid. Pid – is process ID, you can see it executing ''ps'' command. Kill -9 <pid> - force kill process pid.
|-
! style="text-align: left; vertical-align: top;" |''top''
| style="text-align: left; vertical-align: top;" |top
| style="text-align: left; vertical-align: top;" |Display all running process.
|-
! style="text-align: left; vertical-align: top;" |''free''
| style="text-align: left; vertical-align: top;" |free -h
| style="text-align: left; vertical-align: top;" |Command is used to display amount of free and used RAM in the system, also prints the swap space stats.
|-
! style="text-align: left; vertical-align: top;" |System commands
| style="text-align: left; vertical-align: top;" |
| style="text-align: left; vertical-align: top;" |
|-
! style="text-align: left; vertical-align: top;" |''df''
| style="text-align: left; vertical-align: top;" |df -h
| style="text-align: left; vertical-align: top;" |Show the disk usage.
|-
! style="text-align: left; vertical-align: top;" |''uname''
| style="text-align: left; vertical-align: top;" |uname -a
| style="text-align: left; vertical-align: top;" |Show kernel information.
|-
! style="text-align: left; vertical-align: top;" |''-''
| style="text-align: left; vertical-align: top;" |cat /proc/cpuinfo
| style="text-align: left; vertical-align: top;" |CPU information.
|-
! style="text-align: left; vertical-align: top;" |''-''
| style="text-align: left; vertical-align: top;" |cat /proc/version
| style="text-align: left; vertical-align: top;" |CPU version.
|-
! style="text-align: left; vertical-align: top;" |Network commands
| style="text-align: left; vertical-align: top;" |
| style="text-align: left; vertical-align: top;" |
|-
! style="text-align: left; vertical-align: top;" |''ping''
| style="text-align: left; vertical-align: top;" |ping <host>
| style="text-align: left; vertical-align: top;" |Ping host and output results. Example: ''ping 8.8.8.8''
|-
! style="text-align: left; vertical-align: top;" |''route''
| style="text-align: left; vertical-align: top;" |route -n
| style="text-align: left; vertical-align: top;" |To see IP routing tables.
|-
! style="text-align: left; vertical-align: top;" |''traceroute''
| style="text-align: left; vertical-align: top;" |traceroute <domain>
| style="text-align: left; vertical-align: top;" |Displaying the route (path) and measuring transit delays of packets takes to destination. Example: ''traceroute teltonika-networks.com''
|-
! style="text-align: left; vertical-align: top;" |''tcpdump''
| style="text-align: left; vertical-align: top;" |tcpdump <-option1> <-option2> ...
| style="text-align: left; vertical-align: top;" |To display packets being transmitted or received over a network interface. Example: ''tcpdump -n port 80 –I eth0''
|-
! style="text-align: left; vertical-align: top;" |''netstat''
| style="text-align: left; vertical-align: top;" |netstat <-option1> <-option2> ...
| style="text-align: left; vertical-align: top;" |The ''netstat'' is a command used to check the network statistics of the system. It delivers basic statistics on all network activities and informs users on which ports and addresses the corresponding connections (TCP, UDP) are running and which ports are open for tasks.
|-
! style="text-align: left; vertical-align: top;" |''-''
| style="text-align: left; vertical-align: top;" |<nowiki>ip route |grep default</nowiki>
| style="text-align: left; vertical-align: top;" |To view default gateway.
|-
! style="text-align: left; vertical-align: top;" |''-''
| style="text-align: left; vertical-align: top;" |cat /tmp/resolv.conf.auto
| style="text-align: left; vertical-align: top;" |To view DNS address.
|-
! style="text-align: left; vertical-align: top;" |''ifconfig''
| style="text-align: left; vertical-align: top;" |ifconfig
| style="text-align: left; vertical-align: top;" |Displays the status of the system's active interfaces.
|-
! style="text-align: left; vertical-align: top;" |''-''
| style="text-align: left; vertical-align: top;" |/etc/init.d/<script name>
| style="text-align: left; vertical-align: top;" |Start/stop/restart running scripts. Example: ''/etc/init.d/firewall restart''
|-
! style="text-align: left; vertical-align: top;" |''iperf3''
| style="text-align: left; vertical-align: top;" |<nowiki>iperf <-s|-c host> <options></nowiki>
| style="text-align: left; vertical-align: top;" |It is a tool to measure the bandwidth and the quality of a network link. It is additional package. First it should be installed on device: ''opkg install iperf3''

Syntax examples for server: ''iperf3 -s -p 5000''; for client: ''iperf3 -c IPADDRESS -p 5000 -t 10''
|-
! style="text-align: left; vertical-align: top;" |Installation commands
| style="text-align: left; vertical-align: top;" |
| style="text-align: left; vertical-align: top;" |
|-
! style="text-align: left; vertical-align: top;" |''opkg''
| style="text-align: left; vertical-align: top;" |opkg <options> sub-command <arguments>
| style="text-align: left; vertical-align: top;" |The opkg utility is the lightweight package manager used for downloading and installing pre-made packages from package repositories. See examples on: [https://wiki.teltonika-networks.com/view/Basic_CLI_Commands_for_RUT_devices#Installation_commands Installation_commands]
|-
! style="text-align: left; vertical-align: top;" |Extra commands
| style="text-align: left; vertical-align: top;" |
| style="text-align: left; vertical-align: top;" |
|-
! style="text-align: left; vertical-align: top;" |''gsmctl''
| style="text-align: left; vertical-align: top;" |gsmctl
| style="text-align: left; vertical-align: top;" |Can request information from or perform operations on an router’s module. More information on Teltonika wiki: [https://wiki.teltonika-networks.com/view/Gsmctl_commands Gsmctl_commands]
|-
! style="text-align: left; vertical-align: top;" |''reboot''
| style="text-align: left; vertical-align: top;" |reboot
| style="text-align: left; vertical-align: top;" |To reboot the device immediately.
|-
! style="text-align: left; vertical-align: top;" |''logread''
| style="text-align: left; vertical-align: top;" |logread -f
| style="text-align: left; vertical-align: top;" |Show log output on screen. Example: ''<nowiki>logread –f |grep DHCP</nowiki>''
|-
|}

==Examples==

===File commands===
----
1. '''pwd''' command shows current working directory:
...
root@Teltonika:~# pwd
/root
...
----
2. '''cd''' command is used to change the current working directory to the directory provided as argument.

Example: when you're on your Home directory, you need to go to the /etc/config directory, use '''cd /etc/config''':
...
root@Teltonika:~# cd /etc/config/
root@Teltonika:/etc/config#
...
----
3. '''ls''' command is used to list files or directories.

Example: use '''ls /etc/config''' to list contents of the "/etc/config" folder:
...
root@Teltonika:~# ls /etc/config/
auto_update events_reporting load_balancing multiwan pptpd rpcd stunnel
blocklist eventslog_report logtrigger network privoxy rut_fota system
call_utils firewall luci ntpclient profiles sim_idle_protection
cli fstab mdcollectd ntpserver qos sim_switch ucitrack
coovachilli gps modbus openvpn quagga simcard uhttpd
data_limit hostblock modbus_data_sender operctl racoon smpp_config vrrpd
ddns hotspot_scheduler modbus_master_alarms output_control radius sms_gateway
ddos hwinfo modbus_tcp_master overview reregister sms_utils wireless
dhcp ioman modbusgateway periodic_reboot rms_connect_mqtt smscollect xl2tpd
dropbear kmod_man mosquitto ping_reboot rms_connect_timer static_arp
etherwake landingpage mqtt_pub portscan rms_mqtt strongswan
...
----
4. '''mkdir''' command is used to create a directory.

Example: use '''mkdir /etc/Example_dir''' to make a new directory named "Example_dir":
...
root@Teltonika:~# mkdir /etc/Example_dir
root@Teltonika:~# ls /etc/
Example_dir chilli.conf fstab ipsec.d package_restore.sh rc.common stunnel
...
----
5. '''touch''' command is used to create empty file.

Example: use '''touch /etc/Example_dir/Example_file1.txt''' to create a blank txt file under the "/etc/Example_dir" directory:
...
root@Teltonika:~# touch /etc/Example_dir/Example_file1.txt
root@Teltonika:~# ls /etc/Example_dir/
Example_file1.txt
...
----
6. '''cat''' command is used to get inside contents of a file.

Example: use '''cat /etc/config/ping_reboot''' to get the inside contents of "ping_reboot" file in your screen:
...
root@Teltonika:~# cat /etc/config/ping_reboot
config ping_reboot
option enable '0'
option action '1'
option time '5'
option host '8.8.8.8'
option retry '2'
option fail_counter '0'
option packet_size '56'
option time_out '5'
option interface '1'
option stop_action '0'
...
----
7. '''cp''' command is used to copy the contents of “file1” to “file2”.

Example: use '''cp Example_file1.txt Example_file2.txt''', to copy content of file "Example_file1.txt" to "Example_file2.txt":
...
root@Teltonika:/etc/Example_dir# cp Example_file1.txt Example_file2.txt
root@Teltonika:/etc/Example_dir# ls
Example_file1.txt Example_file2.txt
root@Teltonika:/etc/Example_dir# cat Example_file2.txt
"Sample text !!!"
...
----
8. '''cp -r''' command is used to copy “dir1” to “dir2”; creates “dir2” if not present.

Example: use '''cp -r Example_dir Example_dir2''', to copy directory "Example_dir":
...
root@Teltonika:/etc# cp -r Example_dir Example_dir2
root@Teltonika:/etc# ls
Example_dir chilli freeradius2 ipsec.conf opkg.conf rc.button
Example_dir2 chilli.conf fstab ipsec.d package_restore.sh rc.common stunnel
...
----
9. '''rm''' command is used to delete the file.

Example: use '''rm /etc/Example_dir2/Example_file1.txt''', to delete file "Example_file1":
...
root@Teltonika:~# rm /etc/Example_dir2/Example_file1.txt
root@Teltonika:~# ls /etc/Example_dir2/
Example_file2.txt
...
----
10. '''rm -r''' command is used delete the directory.

Example: use '''rm -r /etc/Example_dir''', to delete directory "Example_dir":
...
root@Teltonika:~# rm -r /etc/Example_dir
root@Teltonika:~# ls /etc/
Example_dir2 chilli.conf fstab ipsec.d package_restore.sh rc.common stunnel
...
----
11. '''mv''' command is used to move files or directories.

Example: use '''mv /etc/Example_new /etc/Example_dir2/''', to move directory "Example_new" to directory "Example_dir2":
...
root@Teltonika:~# mv /etc/Example_new /etc/Example_dir2/
root@Teltonika:~# ls /etc/Example_dir2/
Example_new
...
----
12. '''vi''' command is used to edit files.

Example: use '''vi /etc/Example_dir2/Example_file2.txt''', to edit file "Example_file2.txt". Press ‘i’, to enter INSERT mode, it will let you edit. Press Esc to exit INSERT mode. Press ‘:x’ and 'Enter' to save changes:
...
root@Teltonika:~# vi /etc/Example_dir2/Example_file2.txt
...
----

===Process management commands===
----

1. '''ps''' command shows the currently working processes:
...
root@Teltonika:~# ps
PID USER VSZ STAT COMMAND
1 root 1596 S /sbin/procd
2 root 0 SW [kthreadd]
3 root 0 SW [ksoftirqd/0]
5 root 0 SW< [kworker/0:0H]
7 root 0 SW< [khelper]
28 root 0 SW< [writeback]
29 root 0 SW< [bioset]
30 root 0 SW< [kblockd]
31 root 0 SW [kworker/0:1]
32 root 0 SW [kswapd0]
33 root 0 SW [fsnotify_mark]
35 root 0 SW [spi0]
254 root 0 SW< [deferwq]
329 root 0 SWN [jffs2_gcd_mtd5]
494 root 1244 S /sbin/ubusd
570 root 0 SW< [ipv6_addrconf]
...
----
2. '''kill''' command is used to kill the process with given pid.

Example, use '''kill 570''' to stop process ID - 570 [ipv6_addrconf]
...
root@Teltonika:~# kill 570
...
----
3. '''top''' command shows all running process:
...
root@Teltonika:~# top
Mem: 49948K used, 11068K free, 188K shrd, 6764K buff, 16836K cached
CPU: 0% usr 9% sys 0% nic 81% idle 0% io 0% irq 9% sirq
Load average: 0.02 0.06 0.07 1/59 19825
PID PPID USER STAT VSZ %VSZ %CPU COMMAND
19825 13212 root R 1524 2% 9% top
5989 1 root S 7572 12% 0% /usr/sbin/rms_mqtt
4466 1 root S 7088 12% 0% /usr/bin/mwan
3862 1 root S 4400 7% 0% /usr/bin/mdcollectd start
2102 1 root S 4260 7% 0% /usr/sbin/uhttpd -f -h /www -r Teltonika -x /cgi-bin -u /ubus -t 600 -T 30 -k 20 -A 1 -n 3 -N 100
5376 1 root S 4024 7% 0% /usr/sbin/openvpn --syslog openvpn(client_cln) --cd /var/etc --config openvpn-client_cln.conf
1594 1 root S 3056 5% 0% /usr/sbin/gsmd -p /dev/modem_cmd -s 115200 -m auto
1466 1 root S 2504 4% 0% /usr/bin/eventslogd
1035 1 root S 2132 3% 0% /sbin/rpcd
3902 1 root S 2036 3% 0% /usr/sbin/port_event_checker
3021 1 root S 2004 3% 0% /usr/sbin/wpa_supplicant -B -s -P /var/run/wpa_supplicant-wlan0.pid -D nl80211 -i wlan0
2910 1 root S 1996 3% 0% /usr/sbin/hostapd -s -P /var/run/wifi-phy0.pid -B /var/run/hostapd-phy0.conf
1279 1 root S 1784 3% 0% /sbin/netifd
1 0 root S 1596 3% 0% /sbin/procd
4035 1 root S 1580 3% 0% /bin/sh /sbin/fix_sta_ap.sh
...
----
4. '''free -h''' command is used to display amount of free and used RAM in the system, also prints the swap space stats:
...
root@Teltonika:~# free -h
total used free shared buff/cache available
Mem: 61016 26992 10420 188 23604 34964
Swap: 0 0 0
...
----

===System commands===
----
1. '''df -h''' command shows the disk space usage:
...
root@Teltonika:~# df -h
Filesystem Size Used Available Use% Mounted on
rootfs 2.4M 640.0K 1.8M 26% /
/dev/root 11.8M 11.8M 0 100% /rom
tmpfs 29.8M 188.0K 29.6M 1% /tmp
/dev/mtdblock5 2.4M 640.0K 1.8M 26% /overlay
overlayfs:/overlay 2.4M 640.0K 1.8M 26% /
tmpfs 512.0K 0 512.0K 0% /dev
/dev/mtdblock7 576.0K 336.0K 240.0K 58% /mnt/mtdblock7
...
----
2. '''uname -a''' command shows kernel information:
...
root@Teltonika:~# uname -a
Linux Teltonika 3.18.44 #1 Tue Mar 24 13:53:40 UTC 2020 mips GNU/Linux
...
----
3. '''cat /proc/cpuinfo ''' command shows CPU information:
...
root@Teltonika:~# cat /proc/cpuinfo
system type : Atheros AR9330 rev 1
machine : Teltonika RUT200
processor : 0
cpu model : MIPS 24Kc V7.4
BogoMIPS : 265.42
wait instruction : yes
microsecond timers : yes
tlb_entries : 16
extra interrupt vector : yes
hardware watchpoint : yes, count: 4, address/irw mask: [0x0ffc, 0x0ffc, 0x0ffb, 0x0ffb]
isa : mips1 mips2 mips32r1 mips32r2
ASEs implemented : mips16
shadow register sets : 1
kscratch registers : 0
package : 0
core : 0
VCED exceptions : not available
VCEI exceptions : not available
...
----
4. '''cat /proc/version''' command shows CPU version:
...
root@Teltonika:~# cat /proc/version
Linux version 3.18.44 (app@runner-DsCEGNRx-project-7-concurrent-0) (gcc version 4.8.3 (OpenWrt/Linaro GCC 4.8-2014.04 unknown) ) #1
...
----

===Installation commands===
----

The opkg utility is the lightweight package manager used for downloading and installing pre-made packages from package repositories. For more information visit: https://openwrt.org/docs/guide-user/additional-software/opkg

----

1. '''opkg update''' command updates list of available packages:
...
root@Teltonika:~# opkg update
Downloading <nowiki>http://downloads.openwrt.org/chaos_calmer/15.05.1/ar71xx/generic/packages/base/Packages.gz.</nowiki>
Updated list of available packages in /var/opkg-lists/chaos_calmer_base.
Downloading <nowiki>http://downloads.openwrt.org/chaos_calmer/15.05.1/ar71xx/generic/packages/packages/Packages.gz.</nowiki>
Updated list of available packages in /var/opkg-lists/chaos_calmer_packages.
Downloading <nowiki>http://downloads.openwrt.org/chaos_calmer/15.05.1/ar71xx/generic/packages/luci/Packages.gz.</nowiki>
Updated list of available packages in /var/opkg-lists/chaos_calmer_luci.
...
----

2. '''opkg list''' command lists available packages.

Example: use '''opkg list |grep iperf3''' to list tool "iperf3" info:
...
root@Teltonika:~# opkg list |grep iperf3
iperf3 - 3.0.11-1 - Iperf is a modern alternative for measuring TCP and UDP bandwidth performance, allowing the tuning of various parameters.
...
----

3. '''opkg install <paskage name>''' command installs packages.

Example: use '''opkg install iperf3''' to install package "iperf3":
...
root@Teltonika:~# opkg install iperf3
Installing iperf3 (3.0.11-1) to root...
Downloading <nowiki>http://downloads.openwrt.org/chaos_calmer/15.05.1/ar71xx/generic/packages/base/iperf3_3.0.11-1_ar71xx.ipk.</nowiki>
Configuring iperf3.
...
----

4. '''opkg upgrade <paskage name>''' command upgrades packages.

Example: use '''opkg upgrade iperf3''' to upgrade package "iperf3":
...
root@Teltonika:~# opkg upgrade iperf3
Installing iperf3 (3.0.11-1) to root...
Downloading <nowiki>http://downloads.openwrt.org/chaos_calmer/15.05.1/ar71xx/generic/packages/base/iperf3_3.0.11-1_ar71xx.ipk.</nowiki>
Configuring iperf3.
...
----

3. '''opkg remove <paskage name>''' command removes packages.

Example: use '''opkg remove iperf3''' to remove package "iperf3":
...
root@Teltonika:~# opkg remove iperf3
Removing package iperf3 from root...
...
----
===Networking commands===
----

1. '''ifconfig''' command shows all network interface information. Some basic use could be like checking which network interfaces are connected and their respective MAC or IP address.

Example: use '''ifconfig''' to see network interfaces:
...
root@Teltonika:~# ifconfig
br-lan Link encap:Ethernet HWaddr 00:1E:42:26:2B:F0
inet addr:192.168.1.1 Bcast:192.168.1.255 Mask:255.255.255.0
inet6 addr: fe80::21e:42ff:fe26:2bf0/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:3726 errors:0 dropped:0 overruns:0 frame:0
TX packets:2924 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:451598 (441.0 KiB) TX bytes:991568 (968.3 KiB)
eth0 Link encap:Ethernet HWaddr 00:1E:42:26:2B:F0
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:3737 errors:0 dropped:11 overruns:0 frame:0
TX packets:2917 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:504422 (492.5 KiB) TX bytes:990758 (967.5 KiB)
Interrupt:5
lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
inet6 addr: ::1/128 Scope:Host
UP LOOPBACK RUNNING MTU:65536 Metric:1
RX packets:76 errors:0 dropped:0 overruns:0 frame:0
TX packets:76 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:6963 (6.7 KiB) TX bytes:6963 (6.7 KiB)
wlan0 Link encap:Ethernet HWaddr 00:1E:42:26:2B:F2
inet addr:192.168.88.197 Bcast:192.168.88.255 Mask:255.255.255.0
inet6 addr: fe80::21e:42ff:fe26:2bf2/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:34007 errors:0 dropped:146 overruns:0 frame:0
TX packets:4360 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:5610523 (5.3 MiB) TX bytes:523881 (511.6 KiB)
wlan0-1 Link encap:Ethernet HWaddr 02:1E:42:26:2B:F2
inet6 addr: fe80::1e:42ff:fe26:2bf2/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:728 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:0 (0.0 B) TX bytes:239145 (233.5 KiB)
wwan0 Link encap:Ethernet HWaddr 12:2A:38:D0:1D:21
inet6 addr: fe80::102a:38ff:fed0:1d21/64 Scope:Link
UP BROADCAST RUNNING NOARP MULTICAST MTU:1500 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:1494 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:0 (0.0 B) TX bytes:55434 (54.1 KiB)
...
----

2. '''ip route |grep default''' command used to view default gateway:
...
root@Teltonika:~# ip route |grep default
default via 84.15.163.16 dev wwan0 metric 1
...
----

3. '''cat /tmp/resolv.conf.auto''' command used to view DNS addresses:
...
root@Teltonika:~# cat /tmp/resolv.conf.auto
# Interface ppp_4
nameserver 213.226.131.131
nameserver 193.219.88.36
...
----

4. '''ping''' command used to test connectivity between hosts:

Use '''ping''' to see all options:
...
root@Teltonika:~# ping
BusyBox v1.30.1 () multi-call binary.
Usage: ping [OPTIONS] HOST
Send ICMP ECHO_REQUEST packets to network hosts
-4,-6 Force IP or IPv6 name resolution
-c CNT Send only CNT pings
-s SIZE Send SIZE data bytes in packets (default 56)
-i SECS Interval
-A Ping as soon as reply is recevied
-t TTL Set TTL
-I IFACE/IP Source interface or IP address
-W SEC Seconds to wait for the first response (default 10)
(after all -c CNT packets are sent)
-w SEC Seconds until ping exits (default:infinite)
(can exit earlier with -c CNT)
-q Quiet, only display output at start
and when finished
-p HEXBYTE Pattern to use for payload
...

Example: use '''ping -I 192.168.1.1 192.168.1.111''' to ping host 192.168.1.111 frew LAN interface 192.168.1.1:
...
root@Teltonika:~# ping -I 192.168.1.1 192.168.1.111
PING 192.168.1.111 (192.168.1.111) from 192.168.1.1: 56 data bytes
64 bytes from 192.168.1.111: seq=0 ttl=128 time=0.893 ms
64 bytes from 192.168.1.111: seq=1 ttl=128 time=0.839 ms
64 bytes from 192.168.1.111: seq=2 ttl=128 time=1.067 ms
64 bytes from 192.168.1.111: seq=3 ttl=128 time=0.781 ms
...

----

5. '''route''' command used to see IP routing tables.

Example: use '''route -n''' to see routing tables and don't resolve names:
...
root@Teltonika:~# route -n
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
0.0.0.0 84.15.163.16 0.0.0.0 UG 1 0 0 wwan0
84.15.163.0 0.0.0.0 255.255.255.224 U 0 0 0 wwan0
84.15.163.16 0.0.0.0 255.255.255.255 UH 0 0 0 wwan0
192.168.1.0 0.0.0.0 255.255.255.0 U 0 0 0 br-lan
...
----

6. '''traceroute''' command used to view the route (path) and measuring transit delays of packets takes to destination.

Use '''traceroute''' to see all options:
...
root@Teltonika:~# traceroute
BusyBox v1.30.1 () multi-call binary.
Usage: traceroute [-FIlnrv] [-f 1ST_TTL] [-m MAXTTL] [-q PROBES] [-p PORT]
[-t TOS] [-w WAIT_SEC] [-s SRC_IP] [-i IFACE]
[-z PAUSE_MSEC] HOST [BYTES]
Trace the route to HOST

-F Set don't fragment bit
-l Display TTL value of the returned packet
-n Print numeric addresses
-r Bypass routing tables, send directly to HOST
-v Verbose
-f N First number of hops (default 1)
-m N Max number of hops
-q N Number of probes per hop (default 3)
-p N Base UDP port number used in probes
(default 33434)
-s IP Source address
-i IFACE Source interface
-t N Type-of-service in probe packets (default 0)
-w SEC Time to wait for a response (default 3)
-g IP Loose source route gateway (8 max)
...

Example: use '''traceroute teltonika-networks.com -n''' to see path to destination teltonika-networks.com:
...
root@Teltonika:~# traceroute teltonika-networks.com -n
traceroute to teltonika-networks.com (13.32.43.40), 30 hops max, 38 byte packets
1 * * *
2 10.225.72.9 48.441 ms 28.459 ms 40.557 ms
3 10.224.72.9 28.655 ms 27.577 ms 24.268 ms
4 10.224.72.20 26.963 ms 28.636 ms 28.579 ms
5 84.15.10.245 33.991 ms 27.176 ms 39.612 ms
6 213.252.227.173 28.585 ms 29.742 ms 213.252.224.217 33.504 ms
7 213.252.227.250 28.838 ms 213.252.224.250 33.806 ms 213.252.227.250 27.663 ms
8 213.252.224.254 28.347 ms 34.179 ms 28.548 ms
...
----

7. '''tcpdump''' is command-line packets sniffer tool which is used to capture or filter TCP/IP packets that received or transferred over a network on a specific interface.

Use '''tcpdump -h''' to see all options:
...
root@Teltonika:~# tcpdump -h
tcpdump version 4.9.2
libpcap version 1.8.1
Usage: tcpdump [-aAbdDefhHIJKlLnNOpqStuUvxX#] [ -B size ] [ -c count ]
[ -C file_size ] [ -E algo:secret ] [ -F file ] [ -G seconds ]
[ -i interface ] [ -j tstamptype ] [ -M secret ] [ --number ]
[ -Q in|out|inout ]
[ -r file ] [ -s snaplen ] [ --time-stamp-precision precision ]
[ --immediate-mode ] [ -T type ] [ --version ] [ -V file ]
[ -w file ] [ -W filecount ] [ -y datalinktype ] [ -z postrotate-command ]
[ -Z user ] [ expression ]
...

Example: use '''tcpdump -D''' to display available interfaces:
...
root@Teltonika:~# tcpdump -D
1.eth0 [Up, Running]
2.wwan0 [Up, Running]
3.br-lan [Up, Running]
4.wlan0 [Up, Running]
5.any (Pseudo-device that captures on all interfaces) [Up, Running]
6.lo [Up, Running, Loopback]
...

Example: use '''tcpdump -n -i wwan0''' to capture IP address packets from mobile interface:
...
root@Teltonika:~# tcpdump -n -i wwan0
tcpdump: verbose output suppressed, use -v or -vv for full protocol decode
listening on wwan0, link-type EN10MB (Ethernet), capture size 262144 bytes
16:40:16.620564 IP 41.36.236.201.56037 > 84.15.163.15.23: Flags [S], seq 1410310927, win 33462, length 0
16:40:16.620887 IP 84.15.163.15.23 > 41.36.236.201.56037: Flags [R.], seq 0, ack 1410310928, win 0, length 0
16:40:19.732046 IP 84.15.163.15 > 8.8.4.4: ICMP echo request, id 522, seq 0, length 17
16:40:19.795429 IP 8.8.4.4 > 84.15.163.15: ICMP echo reply, id 522, seq 0, length 17
16:40:24.796440 IP 84.15.163.15 > 8.8.4.4: ICMP echo request, id 523, seq 0, length 17
16:40:24.863184 IP 8.8.4.4 > 84.15.163.15: ICMP echo reply, id 523, seq 0, length 17
...

Example: use '''tcpdump host 192.168.1.111 and icmp -i any -n''' to capture only icmp packets from 192.168.1.111 on any interface:
...
root@Teltonika:~# tcpdump host 192.168.1.111 and icmp -i any -n
tcpdump: verbose output suppressed, use -v or -vv for full protocol decode
listening on any, link-type LINUX_SLL (Linux cooked), capture size 262144 bytes
16:42:46.122094 IP 192.168.1.111 > 192.168.1.1: ICMP echo request, id 1, seq 48, length 40
16:42:46.122142 IP 192.168.1.111 > 192.168.1.1: ICMP echo request, id 1, seq 48, length 40
16:42:46.122458 IP 192.168.1.1 > 192.168.1.111: ICMP echo reply, id 1, seq 48, length 40
16:42:46.122493 IP 192.168.1.1 > 192.168.1.111: ICMP echo reply, id 1, seq 48, length 40
...
----

8. '''netstat [-ral] [-tuwx] [-enWp]''' command used to check the network statistics.

Example: use '''netstat -h''' to see all options:
...
root@Teltonika:~# netstat -h
netstat: invalid option -- h
BusyBox v1.30.1 () multi-call binary.
Usage: netstat [-ral] [-tuwx] [-enWp]
Display networking information
-r Routing table
-a All sockets
-l Listening sockets
Else: connected sockets
-t TCP sockets
-u UDP sockets
-w Raw sockets
-x Unix sockets
Else: all socket types
-e Other/more information
-n Don't resolve names
-W Wide display
-p Show PID/program name for sockets
...

Example: use '''netstat -n -p -t''' to see established connection for TCP socket, not resolving names and showing PID/program:
...
root@Teltonika:~# netstat -n -p -t
Active Internet connections (w/o servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 192.168.1.1:22 192.168.1.111:55826 ESTABLISHED 13199/dropbear
tcp 0 0 192.168.1.1:22 192.168.1.111:55824 ESTABLISHED 13169/dropbear
tcp 0 0 84.15.163.15:56982 18.196.62.30:15010 ESTABLISHED 5989/rms_mqtt
...
----

9. '''iperf3''' is a tool to measure the bandwidth and the quality of a network link.

First it should be installed on device. Use command '''opkg install iperf3''':
...
root@Teltonika:~# opkg install iperf3
Installing iperf3 (3.0.11-1) to root...
Downloading <nowiki>http://downloads.openwrt.org/chaos_calmer/15.05.1/ar71xx/generic/packages/base/iperf3_3.0.11-1_ar71xx.ipk.</nowiki>
Configuring iperf3.
...

Use '''iperf3 -h''' to see all options:
...
root@Teltonika:~# iperf3 -h
Usage: iperf [-s|-c host] [options]
iperf [-h|--help] [-v|--version]
Server or Client:
-p, --port # server port to listen on/connect to
-f, --format [kmgKMG] format to report: Kbits, Mbits, KBytes, MBytes
-i, --interval # seconds between periodic bandwidth reports
-F, --file name xmit/recv the specified file
-A, --affinity n/n,m set CPU affinity
-B, --bind <host> bind to a specific interface
-V, --verbose more detailed output
-J, --json output in JSON format
-d, --debug emit debugging output
-v, --version show version information and quit
-h, --help show this message and quit
Server specific:
-s, --server run in server mode
-D, --daemon run the server as a daemon
-1, --one-off handle one client connection then exit
Client specific:
-c, --client <host> run in client mode, connecting to <host>
-u, --udp use UDP rather than TCP
-b, --bandwidth #[KMG][/#] target bandwidth in bits/sec (0 for unlimited)
(default 1 Mbit/sec for UDP, unlimited for TCP)
(optional slash and packet count for burst mode)
-t, --time # time in seconds to transmit for (default 10 secs)
-n, --bytes #[KMG] number of bytes to transmit (instead of -t)
-k, --blockcount #[KMG] number of blocks (packets) to transmit (instead of -t or -n)
-l, --len #[KMG] length of buffer to read or write
(default 128 KB for TCP, 8 KB for UDP)
-P, --parallel # number of parallel client streams to run
-R, --reverse run in reverse mode (server sends, client receives)
-w, --window #[KMG] set window size / socket buffer size
-C, --linux-congestion <algo> set TCP congestion control algorithm (Linux only)
-M, --set-mss # set TCP maximum segment size (MTU - 40 bytes)
-N, --nodelay set TCP no delay, disabling Nagle's Algorithm
-4, --version4 only use IPv4
-6, --version6 only use IPv6
-S, --tos N set the IP 'type of service'
-L, --flowlabel N set the IPv6 flow label (only supported on Linux)
-Z, --zerocopy use a 'zero copy' method of sending data
-O, --omit N omit the first n seconds
-T, --title str prefix every output line with this string
--get-server-output get results from server
[KMG] indicates options that support a K/M/G suffix for kilo-, mega-, or giga-
iperf3 homepage at: <nowiki>http://software.es.net/iperf/</nowiki>
Report bugs to: <nowiki>https://github.com/esnet/iperf</nowiki>
...


Use '''iperf3 -s -p 5000''' to enable iperf3 server listening on port 5000 on device1:
...
root@Teltonika:~# iperf3 -s -p 5000
-----------------------------------------------------------
Server listening on 5000
-----------------------------------------------------------
...

Use '''iperf3 -c IPADDRESS -p 5000 -t 5''' to launch iperf3 client on device2:
...
root@Teltonika:~# iperf3 -c 192.168.1.111 -p 5000 -t 10
Connecting to host 192.168.1.111, port 5000
[ 4] local 192.168.1.1 port 45060 connected to 192.168.1.111 port 5000
[ ID] Interval Transfer Bandwidth Retr Cwnd
[ 4] 0.00-1.12 sec 8.75 MBytes 65.7 Mbits/sec 0 28.5 KBytes
[ 4] 1.12-2.11 sec 6.93 MBytes 58.7 Mbits/sec 1 29.9 KBytes
[ 4] 2.11-3.09 sec 7.50 MBytes 64.4 Mbits/sec 0 31.4 KBytes
[ 4] 3.09-4.09 sec 8.27 MBytes 68.7 Mbits/sec 1 31.4 KBytes
[ 4] 4.09-5.07 sec 7.85 MBytes 67.6 Mbits/sec 0 34.2 KBytes
- - - - - - - - - - - - - - - - - - - - - - - - -
[ ID] Interval Transfer Bandwidth Retr
[ 4] 0.00-10.08 sec 78.7 MBytes 65.5 Mbits/sec 3 sender
[ 4] 0.00-10.08 sec 78.7 MBytes 65.5 Mbits/sec receiver
iperf Done.
...
----

===Search commands===
----

1. '''grep <pattern> <file>''' command searches for a pattern in a file.

Example: use '''grep version /etc/config/system''' to see only version in file "system":
...
root@Teltonika:~# grep version /etc/config/system
option device_fw_version 'RUT2XX_R_00.01.12'
...
----

2. '''find <path> -name <"pattern">''' command finds files or directories in specified directory that start with "pattern".

Example: use '''find / -name "modbus"''' to find file or directory in root that start with "modbus":
...
root@Teltonika:~# find / -name "modbus"
/etc/config/modbus
/overlay/upper/etc/config/modbus
/rom/etc/config/modbus
...
----

===Piping commands===
----

1. '''|''' pipe is command that lets you use two or more commands such that output of one command serves as input to the next.

Example: use '''logread |grep dhcp''' to see only dhcp info on logread file:
...
root@Teltonika:~# logread |grep dhcp
Fri Apr 3 18:58:40 2020 daemon.info dnsmasq-dhcp[2945]: DHCP, IP range 192.168.1.100 -- 192.168.1.249, lease time 12h
Fri Apr 3 18:58:40 2020 daemon.info dnsmasq-dhcp[2945]: read /etc/ethers - 0 addresses
Fri Apr 3 18:58:43 2020 daemon.notice netifd: wan3 (3120): udhcpc: started, v1.30.1
Fri Apr 3 18:58:44 2020 daemon.notice netifd: wan3 (3120): udhcpc: sending discover
Fri Apr 3 18:58:47 2020 daemon.notice netifd: wan3 (3120): udhcpc: sending discover
Fri Apr 3 18:58:47 2020 daemon.notice netifd: wan3 (3120): udhcpc: sending select for 192.168.88.197
Fri Apr 3 18:58:47 2020 daemon.notice netifd: wan3 (3120): udhcpc: lease of 192.168.88.197 obtained, lease time 86400
...
----

[[Category:FAQ]]

Navigation menu