Terminal Activity: Difference between revisions
(→Common Terminal Commands: remove keyboard shortcuts from here, rephrase fedora, lowercase heading) |
|||
(38 intermediate revisions by 13 users not shown) | |||
Line 12: | Line 12: | ||
[[Image:Activity-terminal.svg|85px]] The [[Terminal]] activity grants access to the XO's [[Linux]] command line. |
[[Image:Activity-terminal.svg|85px]] The [[Terminal]] activity grants access to the XO's [[Linux]] command line. |
||
The Terminal is an Activity that allows you to control your XO directly from a command line, similar to the Terminal program in Mac OS X or the Command Prompt in Microsoft Windows. The Terminal allows you to do far more with your XO than running Sugar activities. But it is also possible to delete your data, |
The Terminal is an Activity that allows you to control your XO directly from a command line, similar to the Terminal program in Mac OS X or the Command Prompt in Microsoft Windows. The Terminal allows you to do far more with your XO than running Sugar activities. But '''BEWARE''' it is also possible to delete your data, so be careful. And if you become the [[root]] user, you have full control of the computer and can destroy all software! |
||
'''BEWARE: If you become user "root" by executing "[[su -l]] " you have full control — you can destroy all software!''' |
|||
See the [http://en.flossmanuals.net/terminal Terminal manual]. |
|||
== Starting Terminal == |
== Starting Terminal == |
||
The Terminal Activity is usually not marked as a favorite, so it does not appear in the Home View Favorites view. |
|||
The Terminal Activity is found in the Activities taskbar at the bottom of your [http://laptop.org/laptop/start/homeview.shtml Home View]. You may need to scroll through the Activities taskbar by using the right arrow icon at the bottom of your screen ([[Image:Frame-scroll-right.gif|25px]]) to find the [[Image:Activity-terminal.svg|35px]] icon. |
|||
In the Home View, press ctrl-2 to select the List view, search for Terminal, and click on it to start. |
|||
You might also mark it as a favorite if you like. |
|||
===Starting a console=== |
===Starting a console=== |
||
Line 25: | Line 28: | ||
== Common '''Terminal''' commands == |
== Common '''Terminal''' commands == |
||
When you start Terminal, it runs the [[wikipedia:bash|Bash]] "shell" program that interprets keystrokes and commands. Its main job is to allow you to run other programs, for example: |
|||
* [[Sugar-Control-Panel|sugar-control-panel]] - Change [[Sugar-Control-Panel#nickname|nickname]], [[Sugar-Control-Panel#Color|XO Color]], [[Sugar-Control-Panel#Time|time zone]] and other options |
|||
* [[ifconfig]] - View [[Wifi Connectivity|Wireless Network connections]] |
|||
* [[nano]] for editing text files directly. If you want to edit text files in Sugar, use [[Write]]. |
* [[nano]] for editing text files directly. If you want to edit text files in Sugar, use [[Write]]. |
||
* [[yum]] for automatically installing new software. |
* [[yum]] for automatically installing new software. |
||
Line 34: | Line 35: | ||
There are hundreds of Linux commands available in the Terminal, [[Linux software]] describes some more of them. |
There are hundreds of Linux commands available in the Terminal, [[Linux software]] describes some more of them. |
||
The OLPC system software on the XO is a slimmed-down version of [Fedora]]. |
The OLPC system software on the XO is a slimmed-down version of [[Fedora]] and so its command-line programs come from Fedora. Many command-line programs from Fedora are not available but experienced users can add them using [[yum]] or [[rpm]]. |
||
== |
=== Users and super-user === |
||
Initially Terminal begins as the default user (usually "olpc"). Some programs require that you run them as the [[root]] "super-user. You can prepend <tt>[[sudo]]</tt> to some of these, or press the #_ icon in the Activity menu to become root, or enter <tt>[[su -l]]</tt> to become root. The root user has awesome destructive power, do not run commands as root unless you have to. |
|||
It '''IS''' possible insert text in the Terminal Activity without having to use a pen and paper. All you have to do is highlight the text you want to insert. Then, go back to the Terminal Activity, and on the two buttons below the XO Touch Pad, you click right in the center of the two and that's it! |
|||
== Copy and paste in Terminal == |
|||
=== Paste script === |
|||
Several options: |
|||
You can create a script that pastes text from the clipboard into Terminal. |
|||
* Use the Edit menu, which is underneath the scissors icon, |
|||
* Press Shift+Ctrl+C to copy, Shift+Ctrl+V to paste, |
|||
* Plug a three-button USB mouse into a port and use the middle mouse button to paste, |
|||
* Click both buttons below the track pad (or click directly between them) to paste. |
|||
* Configure a bluetooth mouse on an XO-4 and use the middle mouse button to paste, |
|||
You can select text in Terminal's window and use the mouse or track pad methods to duplicate it without first copying it to the clipboard. |
|||
Open a terminal and create a new file named ''paste'' in the home directory, this can be done with nano for example. |
|||
== Copy from Wiki and Paste in Terminal == |
|||
nano paste |
|||
Many Wiki pages provide commands that are to be pasted into Terminal. For example: |
|||
In the file enter the following |
|||
echo this is a test |
|||
echo hello world |
|||
What you should do is: |
|||
* Start the Terminal activity, |
|||
* Press Alt-Tab to switch to the Browse activity, |
|||
* Use the mouse or touchpad to highlight the text of the commands, |
|||
* Press Ctrl+C to copy, |
|||
* Press Alt-Tab to switch to the Terminal activity, |
|||
* Press Shift+Ctrl+V to paste, |
|||
* Look at the outcome of the commands. |
|||
See also [[Compound_commands#Copy_and_paste|how to copy and paste a compound command]]. |
|||
#!/usr/bin/python |
|||
import pygtk |
|||
import gtk |
|||
cb = gtk.clipboard_get(selection = "PRIMARY") |
|||
print cb.wait_for_text() |
|||
== Other keystroke commands == |
|||
Save and exit, then make the file executable by entering |
|||
[[Keyboard shortcuts]] lists special keys in Sugar. Some of these don't work in Terminal, or require that you press the Shift key as well. |
|||
chmod a+x paste |
|||
==Change font size in the Terminal activity== |
|||
Finally to run the script to paste from the clipboard enter |
|||
To change the font size, click on the eye icon, then click on - or +. |
|||
./paste |
|||
==Change font size in the Terminal Activity== |
|||
Here is how to increase the print size in the terminal: |
|||
* Launch the Terminal activity. |
|||
* Type |
|||
nano ~/.sugar/default/terminalrc |
|||
* Find the line saying |
|||
Font = Monospace 8 |
|||
And change it to |
|||
Font = Monospace 16 |
|||
(or whatever you want—see [[Fonts]] for info on determining available fonts). |
|||
* Press <tt>Control-X</tt> and answer '''Yes''' to save. |
|||
* Stop the terminal activity (the stop-sign icon in the top right-hand corner of the Activity menu) |
|||
* Re-open the terminal activity, the terminal should now be in larger print. |
|||
==The Console== |
==The Console== |
||
Another way to bring up the Linux command prompt is by pressing the Ctrl+Alt+Neighborhood keys at the same time (the Neighborhood view key is represented by a circle with 8 small dots [[Image:Mesh key f1 small.png]]). This will switch to a ''console'' terminal that runs outside the [[Sugar]] UI and X Window System. The console also displays some internal messages during XO operation. |
|||
(Note that many Sugar binding are not available in the console, so commands such as sugar-control-panel will not work there.) |
|||
To return to the X Window System environment, press Ctrl+Alt+Home keys ([[Image:Home key f3 small.png]]). |
|||
There is a second terminal (technically, <tt>/dev/tty2</tt>) outside Sugar that you can switch to by pressing Ctrl+Alt+Group keys ([[Image:Friends key f2 small.png]]). |
|||
===Logging in to the console === |
|||
In "Ship.1" releases (builds 650, 653, and 656), the console may give you a login prompt and require you to login before you can enter commands. |
|||
If so, type ''<tt>root</tt>'' and press the Enter key, |
|||
xo-''NN-NN-NN'' login: '''root''' |
|||
In more recent builds both virtual terminals log you in as root after you first press Enter. |
|||
You are now logged in as the [[root]] user, be careful. |
|||
===Changing font size in the console=== |
|||
To increase the font size in the console, type: |
|||
Another way to bring up the Linux command prompt is by pressing the Ctrl+Alt+F2 keys in sequence. |
|||
setfont sun12x22 |
|||
By design, not all XOs have the F2 legend on the key, see [[Keyboard#Missing_keys]]. |
|||
For a list of other console fonts, look in /lib/kbd/consolefonts/ and type: |
|||
ls /lib/kbd/consolefonts/*.psfu.gz |
|||
(remove the suffix .psfu.gz when used with the 'setfont' command) |
|||
Ctrl-Alt-F2 will switch to a ''console'' terminal that runs outside the [[Sugar]] and [http://en.wikipedia.org/wiki/GNOME GNOME]. |
|||
For a permenant change, edit the line: |
|||
" ro ${ROOTDEV} console=ttyS0,115200 console=tty0 fbcon=font:sun12x22" expand$ to boot-file |
|||
in /boot/olpc.fth and substitute 'sun12x22' with your font choice. |
|||
To return to the [[Sugar]] or [http://en.wikipedia.org/wiki/GNOME GNOME] environment, press Alt+F1. (On releases before 11.2.0, use Alt+F3). |
|||
==Cutting and Pasting== |
|||
===Using build 650=== |
|||
It is not possible to cut and paste from the terminal to other activities. However you can use the the clipboard function (i.e., to cut and paste) to drop text into a terminal if you attach a 3 button USB mouse to your USB port. After you have copied text from the web page(usually Ctl C), switch to the Terminal activity, put your cursor on the command line and click your middle button. Doing that should cause the text to be copied successfully. |
|||
Most Sugar or GNOME commands won't work on the console. |
|||
: Isn't it possible to configure the X Server so that the "double chord" of pressing the left and the right mouse button at the same time, emulate the middle mouse button? But even simpler would be to use the right mouse button for pasting since it is not currently used in the terminal. -- Dov Grobgeld - 2008-01-23 |
|||
===Logging in=== |
|||
Press enter, and the console will log you in as ''root''. |
|||
Also try "CTRL+SHIFT+V" for paste. |
|||
You are now logged in as the [[root]] user, be very careful. |
|||
== Alternative terminal program== |
== Alternative terminal program== |
||
You can install gnome-terminal: |
|||
[[su -l]] |
|||
[[yum]] install gnome-terminal |
|||
You may also switch to the GNOME desktop to use the Terminal program there, in the Applications -> System tools menu. |
|||
NOTE - how do we launch the gnome terminal?? |
|||
== See also == |
|||
you would have to use an existing terminal session to launch a 'gnome terminal' session, until a sugarized version is available. |
|||
=== See Also === |
|||
* [[Linux software]] A brief description of <i>some</i> of the linux software that is installed with Sugar. |
* [[Linux software]] A brief description of <i>some</i> of the linux software that is installed with Sugar. |
||
* [http://www.ss64.com/bash/ BASH Reference] A longer list of commands and programs |
* [http://www.ss64.com/bash/ BASH Reference] A longer list of commands and programs (many are not installed on the XO by default because they aren't needed). |
||
h4y33kj<s>Strike-through text</s> |
Latest revision as of 03:09, 5 December 2013
Image:Support-banner-square.png|173px|community support pages rect 0 0 135 204 [1] rect 135 0 345 204 Support FAQ rect 0 205 135 408 [2]
- Comment : there's some whitespace here:
rect 135 205 345 408 Other support
- maybe desc none is better. testing.
desc none
</imagemap>The Terminal activity grants access to the XO's Linux command line.
The Terminal is an Activity that allows you to control your XO directly from a command line, similar to the Terminal program in Mac OS X or the Command Prompt in Microsoft Windows. The Terminal allows you to do far more with your XO than running Sugar activities. But BEWARE it is also possible to delete your data, so be careful. And if you become the root user, you have full control of the computer and can destroy all software!
See the Terminal manual.
Starting Terminal
The Terminal Activity is usually not marked as a favorite, so it does not appear in the Home View Favorites view.
In the Home View, press ctrl-2 to select the List view, search for Terminal, and click on it to start.
You might also mark it as a favorite if you like.
Starting a console
You can also access a Linux command prompt by switching to the console, instead of starting the Terminal activity.
Common Terminal commands
When you start Terminal, it runs the Bash "shell" program that interprets keystrokes and commands. Its main job is to allow you to run other programs, for example:
- nano for editing text files directly. If you want to edit text files in Sugar, use Write.
- yum for automatically installing new software.
- rpm - another way to automatically install new software
- olpc-logbat - log the activity of the battery system. Useful for assisting developers in debugging battery problems.
There are hundreds of Linux commands available in the Terminal, Linux software describes some more of them. The OLPC system software on the XO is a slimmed-down version of Fedora and so its command-line programs come from Fedora. Many command-line programs from Fedora are not available but experienced users can add them using yum or rpm.
Users and super-user
Initially Terminal begins as the default user (usually "olpc"). Some programs require that you run them as the root "super-user. You can prepend sudo to some of these, or press the #_ icon in the Activity menu to become root, or enter su -l to become root. The root user has awesome destructive power, do not run commands as root unless you have to.
Copy and paste in Terminal
Several options:
- Use the Edit menu, which is underneath the scissors icon,
- Press Shift+Ctrl+C to copy, Shift+Ctrl+V to paste,
- Plug a three-button USB mouse into a port and use the middle mouse button to paste,
- Click both buttons below the track pad (or click directly between them) to paste.
- Configure a bluetooth mouse on an XO-4 and use the middle mouse button to paste,
You can select text in Terminal's window and use the mouse or track pad methods to duplicate it without first copying it to the clipboard.
Copy from Wiki and Paste in Terminal
Many Wiki pages provide commands that are to be pasted into Terminal. For example:
echo this is a test echo hello world
What you should do is:
- Start the Terminal activity,
- Press Alt-Tab to switch to the Browse activity,
- Use the mouse or touchpad to highlight the text of the commands,
- Press Ctrl+C to copy,
- Press Alt-Tab to switch to the Terminal activity,
- Press Shift+Ctrl+V to paste,
- Look at the outcome of the commands.
See also how to copy and paste a compound command.
Other keystroke commands
Keyboard shortcuts lists special keys in Sugar. Some of these don't work in Terminal, or require that you press the Shift key as well.
Change font size in the Terminal activity
To change the font size, click on the eye icon, then click on - or +.
The Console
Another way to bring up the Linux command prompt is by pressing the Ctrl+Alt+F2 keys in sequence.
By design, not all XOs have the F2 legend on the key, see Keyboard#Missing_keys.
Ctrl-Alt-F2 will switch to a console terminal that runs outside the Sugar and GNOME.
To return to the Sugar or GNOME environment, press Alt+F1. (On releases before 11.2.0, use Alt+F3).
Most Sugar or GNOME commands won't work on the console.
Logging in
Press enter, and the console will log you in as root. You are now logged in as the root user, be very careful.
Alternative terminal program
You may also switch to the GNOME desktop to use the Terminal program there, in the Applications -> System tools menu.
See also
- Linux software A brief description of some of the linux software that is installed with Sugar.
- BASH Reference A longer list of commands and programs (many are not installed on the XO by default because they aren't needed).