{{keywords>mybook world edition ssh shell putty winscp bash}}
====== Shell Tips and Tricks ======
===== Requirements =====
To apply the fallowing patches you need to access the device throw SSH and to have root privileges
- **[[ssh|Start SSH server]]** -- Access the Admin web interface to enable the SSH support.
- Connect to the device using a ssh client (Putty) and log as a normal user.
- Change the user in **root**.
$ su -
export PATH=\
/bin:\
/sbin:\
/usr/bin:\
/usr/sbin:\
/usr/bin/X11:\
/usr/local/bin:\
/opt/bin
* edit **/root/.bashrc** to change PATH for **root**.
export PATH=\
/bin:\
/sbin:\
/usr/bin:\
/usr/sbin:\
/usr/bin/X11:\
/usr/local/bin:\
/opt/bin
===== Install Midnight Commander =====
* Update local feed list.
# ipkg update
* Search for mc package.
# ipkg list mc
mc - 4.6.1-3 - Midnight Commander File Manager
Successfully terminated.
* Download and install the package.
# ipkg list mc
===== Edit Files with mc =====
* Start Midnight Commander.
# mc
* Navigate in the files system using arrow keys and ENTER.
* Move the cursor on the desired file and press F4.
* This will open internal editor.
* To save changes press F2.
* To exit press ESC.
===== Edit Files with vi =====
**vi** is a text editor (program) that can be used to create and modify text files.
* Create a new blank file
# vi new_file
* Open existing file
# vi existing_file
* By default vi enters the **command-mode**.
* The **command-mode** is used to perform actions on the file
* The **insert-text-mode** is used to edit file's text contents
* To enter **insert-text-mode** press **i**.
* To exit **insert-text-mode** and enter **command-mode** press ESC.
* To exit vi and save the file, in **command-mode** type **ZZ**.
* To find the first instance of a string type **/string_to_search**
* To delete a single character press **x**
* To delete a whole line type **dd**
^Command ^ Description ^
| h | move cursor one character to left |
| j | move cursor one line down |
| k | move cursor one line up |
| l | move cursor one character to right |
| w | move cursor one word to right |
| b | move cursor one word to left |
| 0 | move cursor to beginning of line |
| $ | move cursor to end of line |
| nG | move cursor to line n |
| CTRL-f | scroll forward one screen |
| CTRL-b | scroll backward one screen |
^ ^^
| i | insert to left of current cursor position (end with ESC) |
| a | append to right of current cursor position (end with ESC) |
| dw | delete current word (end with ESC) |
| cw | change current word (end with ESC) |
| r | change current character |
| ~ | change case (upper-, lower-) of current character |
^ ^^
| dd | delete current line |
| D | delete portion of current line to right of the cursor |
| x | delete current character |
| ma | mark currrent position |
| d`a | delete everything from the marked position to here |
| `a | go back to the marked position |
| p | dump out at current place your last deletion (paste) |
^ ^^
| u | undo the last command |
| . | repeat the last command |
^ ^^
| J | combine (join) next line with this one |
^ ^^
| :w | write file to disk, stay in vi |
| :q! | quit VI, do not write file to disk, |
| ZZ | write file to disk, quit vi |
^ ^^
| :r filename | read in a copy of the specified file to the current buffer |
^ ^^
| /string | search forward for string (end with Enter) |
| ?string | search backward for string (end with Enter) |
| n | repeat the last search (``next search'') |
^ ^^
| :s/s1/s2 | replace (substitute) (the first) s1 in this line by s2 |
| :lr/s/s1/s2/g | replace all instances of s1 in the line range lr by s2 |
| :map k s | map the key k to a string of vi commands s (see below) |
| :abb s1 s2 | expand the string s1 in append/insert mode to a string s2 |
An advanced tutorial can be found at: [[http://www.groovyweb.uklinux.net/?category=linux&page_name=how%20to%20use%20vi|An Extremely Quick and Simple Introduction to the Vi Text ]] by Norm Matloff
===== Manage Files with WinSCP =====
[[http://winscp.net/|WinSCP]] is an open source SFTP client and FTP client for Windows. Its main function is the secure file transfer between a local and a remote computer. Beyond this, %%WinSCP%% offers basic file manager functionality. It uses Secure Shell (SSH) and supports, in addition to Secure FTP, also legacy SCP protocol.
==== Features ====
* Graphical user interface. * Translated into several languages. * Integration with Windows (drag&drop, URL, shortcut icons). * U3 support. * All common operations with files. * Support for SFTP and SCP protocols over SSH-1 and SSH-2 and plain old FTP protocol. * Batch file scripting and command-line interface. * Directory synchronization in several semi or fully automatic ways. * Integrated text editor. * Support for SSH password, keyboard-interactive, public key and Kerberos (GSS) authentication. * Integrates with Pageant (%%PuTTY%% authentication agent) for full support of public key authentication with SSH. * Windows Explorer-like and Norton Commander-like interfaces. * Optionally stores session information. * Optionally supports standalone operation using a configuration file in place of registry entries, suitable for operation from removable media. Official website, [[http://winscp.net/eng/docs/introduction|Introducing WinSCP]]==== Configuration ==== * Open %%WinSCP%% program. * Check **Advanced options** checkbox if not checked. * Access **Session => Stored Sessions**. * Press **New** button. * Fill the connection form: ^ %%WinSCP%% login ^^ | Host Name: DEVICE_NAME | Port Number: 22 | | Username: USERNAME | Password: PASSWORD | | Private Key File: || ^ ^^ | File Protocol: SCP || (where DEVICE_NAME may by the IP or the NAME of your MYBOOK). * Press **Save** button to save connection data.