#!/bin/sh H1=$(printf '\033[7m') H2=$(printf '\033[1m') DM=$(printf '\033[2m') UL=$(printf '\033[4m') IT=$(printf '\033[3m') BL=$(printf '\033[5m') H0=$(printf '\033[0m') overview() { cat < more [file] > e.g., 'cat very-long-file | less' passwd Change user password reboot Restart the device reset Reset the shell prompt if it gets garbled ${H2}Network Tools:${H0} ethtool [-h] Ethernet stats, and low-level MAC/PHY settings traceroute [-h] Trace the route ip packets follow going to a host tcpdump [-h] Display network packet headers in real-time arping [-h] Ping hosts by ARP requests/replies ping [-h] Send ICMP ECHO_REQUEST packets to network hosts netcalc [-h] Calculate IP network settings from a IP address netcat [-h] NetCat - TCP/IP swiss army knife (alias: nc) ifconfig [--help] See/Reconfigure available network interfaces route [--help] Edit the kernel's routing tables ifup | ifdown IFACE Bring up/down interfaces in /etc/network/interfaces ip [link|addr] Manage available network interfaces ip [rule|route] Manage routing tables bridge [link|vlan] Manage bridge ports and VLANs scp Securely copy a file to a remote host file system tftp Copy a file to/from a remote host ftpput Store a local file on a remote machine via FTP ftpget Retrieve a remote file via FTP wget Get a file using HTTP or FTP from a remote host ${H2}Overview Commands${H0} df -h List disk usage (in human readable format) free List memory usage ps List running processes show [arg] Show system status, see 'show help' for more info top Displays CPU usage and top list of running tasks ${H2}Interesting Files${H0} /etc/default/svc Command line args for service 'svc' (see above) /etc/rc.local Local setup, runs after all services have started /etc/network/ Directory of networking setup, see 'help net' ${H2}Example Commands${H0} cd /tmp; wget ftp://192.168.55.43/file && cat file cd /var/log; tftp -p -l messages 192.168.55.43 cat /proc/net/arp edit /etc/network/interfaces ${H2}See Also${H0} help edit Tutorial on VI and Mg editors help net Network set up introduction help net | less Read with less pager, use 'h' for help, 'q' to quit EOF } vi() { cat < Return to command mode with Esc EOF } emacs() { cat < means hold down the Control key while typing the character M- means hold down the Alt key while typing the character If you don't have a Meta/Alt key, you can use Esc instead. Press and release the Esc key and then type . This is equivalent to M-. ${H2}Navigation${H0} Though arrow keys, Home/End, and PgUp/PgDn usually work, using Mg over serial console can sometimes cause these keys to be mismapped by terminal program. C-f Move forward one character (can also use right arrow key) C-b Move backward one character (can also use left arrow key) C-p Move up one line (can also use up arrow key) C-n Move down one line (can also use down arrow key) M-f Move forward one word M-b Move backward one word C-a Move to beginning of line (can also use Home key) C-e Move to end of line (can also use End key) C-v Move forward one page (can also use PgDn/Page Down key) M-v Move backward one page (can also use PgUp/Page Up key) M-< Move to beginning of file M-> Move to end of file C-x g Move to line number ${H2}Editing${H0} All edit commands that kill (cut) text is placed in a kill ring (clipboard). Note: when marking text, there is no visual mark. C-_ Undo, also C-x u M-% Replace word/string in file, from cursor position M-q Reformat paragraph (set fill column with C-x f) C-s Search forward (type C-s again to find next) C-r Reversed search C-Space Set beginning of mark (beginning of selected text) C-x C-x Jump back and forth between mark and cursor position C-x h Mark whole buffer C-w Wipe (cut) region from mark to cursor position M-w Copy region from mark to cursor position C-y Yank (paste) text from kill ring C-k Kill (cut) to end of line M-Backspace Kill (delete) previous word M-d Kill (delete) next word C-d Delete character to the right C-o Open new line at cursor ${H2}General Commands${H0} C-g Abort current command C-l Recenter buffer on current line C-h b List all keybindings M-! Run shell command, output in new buffer C-z Suspend Mg, return to shell, use 'fg' to get back C-x C-f Open file C-x C-i Insert file at cursor position C-x C-s Save file C-x s Save file (interactive) C-x k Kill (close) file C-x C-b List open buffers (files) C-x b Switch to another buffer C-x C-c Exit ${H2}Window Commands${H0} C-x 0 Unsplit, keep other window C-x 1 Unsplit, keep this window C-x 2 Split window in two C-x o Go to other window C-x p Go to previous window C-x n Go to next window C-x ^ Enlarge this split EOF } editor() { case $1 in vi) vi ;; ed* | em* | mg) emacs ;; *) vi emacs cat < master br0 state UP ${UL}group port${H0} link/ether 52:54:00:12:34:56 brd ff:ff:ff:ff:ff:ff ... When running in Qemu or other hardware it may be useful to manually classify certain interfaces as ports. This can be achieved in many ways, here we show two. First /etc/mactab, which is read at boot to rename interfaces according their matching MAC address, one interface per line: e0 52:54:00:12:34:56 e1 52:54:00:12:34:57 e2 52:54:00:12:34:58 e3 52:54:00:12:34:59 Another way is to add something like this to /etc/rc.local: for port in eth0 eth1 eth3 eth4; do ip link set \$port group port done ${H1}Summary ${H0} All persistent networking is set up in /etc/network/interfaces using the program ifupdown-ng. The tools to reconfigure networking at runtime are: ifup [-a] [IFACES] ifdown [-a] [IFACES] When changing the configuration at runtime you usually have to bring the affected interfaces down (ifdown e0 e1 e2 e3), if they were set up with /etc/network/interfaces before. Then do the change, and bring it all up again. Both tools understand dependencies between interfaces, so when a 'ifup -a' command is received it brings up all interfaces: adding links to br0 before adding VLANs, the vlan1 and vlan2 interfaces on top so it of it all. Then finally it can start the DHCP client on vlan1 and set the static IP address on vlan2. ${BL}>>> Be careful with these tools when logged in remotely! <<<${H0} EOF } topic=$1 [ -n "$topic" ] && shift case $topic in ed*) editor $* ;; net*) networking ;; *) overview ;; esac