Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
Next revisionBoth sides next revision
docs:guide-user:base-system:user.beginner.cli [2019/06/05 01:47] – [Issue commands] cypherpunksdocs:guide-user:base-system:user.beginner.cli [2021/03/16 02:11] – [Profile customization] comment vgaetera
Line 1: Line 1:
 ====== Command-line interpreter ====== ====== Command-line interpreter ======
 +See also: [[docs:guide-quick-start:sshadministration|SSH access for newcomers]]
 +
 A command-line interpreter is a computer program that reads singular lines of text entered by a user and interprets them in the context of a given operating system or programming/scripting language. The interaction takes place by means of a [[wp>command-line interface]]. Other common, but technically not quite correct, denominations are **console** or **shell**. A command-line interpreter is a computer program that reads singular lines of text entered by a user and interprets them in the context of a given operating system or programming/scripting language. The interaction takes place by means of a [[wp>command-line interface]]. Other common, but technically not quite correct, denominations are **console** or **shell**.
  
Line 5: Line 7:
  
 ===== Start ===== ===== Start =====
-At the end of the boot up process, the **init daemon** is started, this can be [[wp>init]] or [[wp>systemd]] or [[wp>upstart]], etc. OpenWrt currently uses **''[[docs:techref:procd]]''**. Following the boot up scripts located in ''/etc/rd.d'', ''init'' will then start all sorts of programs, amongst them the chosen shell. This listens to keyboard strokes and outputs a more or less colorful command-line interface to the connected display.+At the end of the boot up process, the **init daemon** is started, this can be [[wp>init]] or [[wp>systemd]] or [[wp>upstart]], etc. OpenWrt currently uses **''[[docs:techref:procd]]''**. Following the boot up scripts located in ''/etc/rc.d'', ''init'' will then start all sorts of programs, amongst them the chosen shell. This listens to keyboard strokes and outputs a more or less colorful command-line interface to the connected display.
  
 But most devices you run OpenWrt on, have neither a keyboard nor a display adapter. So we need to access it over the [[docs:techref:hardware:port.serial|serial port]] (=local) or over the Ethernet port (= over the network). But most devices you run OpenWrt on, have neither a keyboard nor a display adapter. So we need to access it over the [[docs:techref:hardware:port.serial|serial port]] (=local) or over the Ethernet port (= over the network).
- 
  
 ===== Network ===== ===== Network =====
Line 30: Line 31:
   * etc.   * etc.
  
-===== Copy & Paste =====+===== Copy & paste =====
 When in PuTTY, you can mark text content with the mouse and, without pressing any key (like [Ctrl]+[c]), it is being automatically stored. You can then insert it the usual way (with [Ctrl]+[v]) in an other windows, e.g. an open firefox. The other way around, you copy text the usual way [Ctrl]+[c]) and then paste it in PuTTY by pressing the [right mouse button]! When in PuTTY, you can mark text content with the mouse and, without pressing any key (like [Ctrl]+[c]), it is being automatically stored. You can then insert it the usual way (with [Ctrl]+[v]) in an other windows, e.g. an open firefox. The other way around, you copy text the usual way [Ctrl]+[c]) and then paste it in PuTTY by pressing the [right mouse button]!
  
 ==== Numpad in PuTTY while using Vi ==== ==== Numpad in PuTTY while using Vi ====
 In PuTTY goto //"Terminal"// => //"Features"// and check //"Disable application keypad mode"//. In PuTTY goto //"Terminal"// => //"Features"// and check //"Disable application keypad mode"//.
- 
  
 ===== Issue commands ===== ===== Issue commands =====
Line 67: Line 67:
 **''Tip''** In firefox, you can use [[https://kb.mozillazine.org/Using_keyword_searches|keywords]] to simplify the usage. Create a new bookmark, use ''https://man.cx/?page=%s'' as address and ''man'' as keyword. **''Tip''** In firefox, you can use [[https://kb.mozillazine.org/Using_keyword_searches|keywords]] to simplify the usage. Create a new bookmark, use ''https://man.cx/?page=%s'' as address and ''man'' as keyword.
  
-===== editing files =====+===== Editing files =====
 To edit a file you need an editor, to edit a text file, you would use a text editor. To edit a file you need an editor, to edit a text file, you would use a text editor.
  
Line 76: Line 76:
   * ''vi'' starts out in command mode   * ''vi'' starts out in command mode
  
-=== starting vi ===+=== Starting vi ===
 Start with ''vi'' or ''vi /etc/config/network'' or ''vi firewall.user'' if you are already in the same directory. Start with ''vi'' or ''vi /etc/config/network'' or ''vi firewall.user'' if you are already in the same directory.
  
-=== editing ===+=== Editing ===
 In order to edit the file, you have to be in //insert mode//. Press [i] or [a]. In order to edit the file, you have to be in //insert mode//. Press [i] or [a].
  
-=== exiting vi ===+=== Exiting vi ===
 In order to get out of vi, you have to be in //command mode//. Press [Esc] (the escape key). Then issue one of the following commands: In order to get out of vi, you have to be in //command mode//. Press [Esc] (the escape key). Then issue one of the following commands:
   * '':w'' to write the current file to disc, this will overwrite the old file   * '':w'' to write the current file to disc, this will overwrite the old file
Line 89: Line 89:
   * '':%s/string1/string2/g'' replace string1 with string2 in the whole file   * '':%s/string1/string2/g'' replace string1 with string2 in the whole file
  
-=== configuring vi ===+=== Configuring vi ===
 Vi can be configured in //command mode// by setting certain variables: Vi can be configured in //command mode// by setting certain variables:
   * '':set ai'' use auto indentation (sometimes annoying default)   * '':set ai'' use auto indentation (sometimes annoying default)
   * '':set noai'' NO auto indentation   * '':set noai'' NO auto indentation
  
-=== alternative text editors ===+=== Alternative text editors ===
 If you do not like ''vi'', try ''joe'', ''mg'', ''nano'', ''vim'', ''vim-full'', ''vim-help'', ''vim-runtime'', ''zile'' If you do not like ''vi'', try ''joe'', ''mg'', ''nano'', ''vim'', ''vim-full'', ''vim-help'', ''vim-runtime'', ''zile''
   * ''[[wp>Vim (text editor)|vim]]''   * ''[[wp>Vim (text editor)|vim]]''
Line 120: Line 120:
 </code> </code>
  
 +===== Profile customization =====
 +User profile customization example.
  
-===== File Managers ===== +<code bash> 
-You may also want to try ''[[wp>Midnight Commander|mc]]'' or ''[[wp>Demos Commander|deco]]''+# Configure profile 
 +mkdir -p /etc/profile.d 
 +cat << "EOF" > /etc/profile.d/custom.sh 
 +export EDITOR="nano" 
 +export PAGER="less" 
 +alias diff="diff --color=auto" 
 +alias grep="grep --color=auto" 
 +alias ip="ip -color=auto" 
 +EOF 
 +/etc/profile 
 +</code>
  
 +===== File managers =====
 +You may also want to try ''[[wp>Midnight Commander|mc]]'' or ''[[wp>Demos Commander|deco]]''.
  
 ===== Use GUIs ===== ===== Use GUIs =====
  • Last modified: 2021/09/09 02:29
  • by vgaetera