Editing Terminal

Warning: You are not logged in. Your IP address will be recorded in this page's edit history.
The edit can be undone. Please check the comparison below to verify that this is what you want to do, and then save the changes below to finish undoing the edit.
Latest revision Your text
Line 6: Line 6:
# Navigate to the application menu
# Navigate to the application menu
-
#* If using a firmware release older than [[Maemo 5/PR1.2|PR1.2]], navigate to ‘More...’
+
# Navigate to ‘More...’
# Tap ‘X Terminal’
# Tap ‘X Terminal’
-
Alternatively, use the Ctrl+Shift+X key combination even without opening the application menu.
+
=== N810 ===
-
 
+
-
=== N800 and N810 ===
+
# Click the command button on the main page
# Click the command button on the main page
# Select ‘Utilities’
# Select ‘Utilities’
# Select ‘X Terminal’
# Select ‘X Terminal’
-
 
-
=== 770 ===
 
-
Terminal is not installed by default on the 770. You need to install it from the Application manager first. After that it will be available in the same menu as on the N8X0.
 
== Using the terminal ==
== Using the terminal ==
'''Before you start, backup your data'''
'''Before you start, backup your data'''
-
So long as your data is backed up, then you can start to try out the terminal without any fears of losing any data. This page does not cover gaining '[[Root access|root]]' on your device so you should come to no harm. If you are gaining root, then it would best to not only have a backup before you start tinkering, but also to familiarise yourself with how to reflash your device in extreme cases where you need to get back to where you started.
+
So long as your data is backed up, then you can start to try out the terminal without any fears of losing any data. This page does not cover gaining 'root' on your device so you should come to no harm. If you are gaining root, then it would best to not only have a backup before you start tinkering, but also to familiarise yourself with how to reflash your device in extreme cases where you need to get back to where you started.  
-
 
+
-
But don't be afraid of the terminal and command line, it can be a fast and powerful tool when used correctly and non-destructive commands will not harm your device or your data.
+
'''Understand what a command does before you type it'''
'''Understand what a command does before you type it'''
-
Fundamentally you should understand what a command does before typing it in and pressing enter. If you have a linux installed on your desktop PC, there you can normally type the command with the parameter <code>--help</code> to get a list of options, i.e. <code>ls --help</code>, or look up manual pages if installed, with the most helpful linux command <code>man</code> for "manual", like:
+
Fundamentally you should understand what a command does before typing it in and pressing enter. If you have a linux desktop distribution, like Ubuntu, you can normally type the command with the parameter <code>--help</code> to get a list of options, i.e. <code>ls --help</code>, or look up manual pages if installed, with:
  man ls [enter]
  man ls [enter]
-
or
+
to find out what the commands are and their options. However you can't do this on the tablets though as the tablets use cut down embedded commands, (BusyBox - I think?), so look at [http://ss64.com/bash Linux commands] or [http://www.busybox.net/downloads/BusyBox.html Busybox list of Linux commands and options for each one]
-
+
-
man man [enter]
+
-
 
+
-
to find out what a command does and what are and the options it allows.  
+
-
 
+
-
However on maemo the default shell is busybox which has lots of commands like <code>ls</code> built in, and most of them are crippled in functionality so don't support a really helpful --help function. Also the <code>man</code> command is not available on standard maemo. So maemo NITs are basically a hostile environment for beginners to learn about linux.
+
-
 
+
-
There are ways to mitigate this:
+
-
* install man. The pkg is available e.g. here:[http://maemo.org/packages/view/man-db-n900/] and also in your application manager when you got the extras-devel catalog enabled.
+
-
* install bash (version 3 or 4), a proper fullsize shell though without many builtins. (http://maemo.org/packages/view/bash3/ http://maemo.org/packages/view/bash4/, again also in your application manager, from extras catalog.
+
-
* install proper original tools to replace the crippled ones of busybox, when you  already installed bash. Refer to e.g. [[User:Joerg_rw/tools]]
+
-
 
+
-
WARNING: You might feel like getting rid of supposedly useless busybox when you did the above suggested installation of bash and tools. ''DO NOT uninstall busybox'', it's needed for maemo bootup!
+
-
 
+
-
If you're reluctant to do all of the above (installing man package mandb-N900 is strongly recommended anyway), you may look up general linux cmdline help here: [http://ss64.com/bash Linux commands], and details about crippled busybox here: [http://www.busybox.net/downloads/BusyBox.html list of Busybox Linux commands and options for each one]. Man pages online you'll find at [http://manpages.courier-mta.org/manpageindex.html], further links are listed at [http://tldp.org/manpages/man.html].
+
-
 
+
-
You find more links that give you easy as well as ambitious starts on linux shell here: [http://tldp.org/LDP/Bash-Beginners-Guide/html/sect_01_01.html Bash-Beginners-Guide] [http://tldp.org/LDP/abs/html/why-shell.html "Shell Programming!"] [http://tldp.org/LDP/Bash-Beginners-Guide/html/sect_01_01.html Common shell programs] [http://www.faqs.org/docs/bashman/bashref_toc.html#SEC_Contents Bash reference] [http://tldp.org/HOWTO/Bash-Prog-Intro-HOWTO.html BASH Programming - Introduction HOW-TO] and generally under http://tldp.org/
+
=== Basics ===
=== Basics ===
-
 
-
One of the most useful yet unknown to beginners: <TAB> completes anything at any moment, If there are ambiguities, <TAB> will complete only the unambiguous part. Two times <TAB> shows all alternatives when there are ambiguities.
 
-
 
-
Try <TAB><TAB> on an empty line to get a list of all commands that are "known" to the shell (will not find commands that are not in $PATH and so would need full pathname to invoke them)
 
-
 
-
==== Basic commands ====
 
Some example commands, all here are non-destructive. Press enter after each command to execute it.
Some example commands, all here are non-destructive. Press enter after each command to execute it.
Line 106: Line 76:
  ~ $ uname -s > /dev/shm/os; cat /dev/shm/os
  ~ $ uname -s > /dev/shm/os; cat /dev/shm/os
-
 
-
==== Tab autocompletion ====
 
-
 
-
In the bottom of the X terminal you find the "tab-key" (it does not exist on the hardware keyboard. The tab-key will autocomplete commands/directory/files when pressed. If you want to see what is in a specific directory you could double-tab. The tab function is a very good way and should be a habit. It not only makes using the terminal faster. It also makes sure you spelt everything correctly.
 
-
ls /home/opt/themes/sun[tab]
 
-
will finish the word as "<code>sunset</code>".
 
-
ls /home/opt/[tab][tab]
 
-
shows you what is in the <code>opt</code> folder, for example the "<code>themes</code>" folder
 
-
 
-
Another good tip is "ctrl+c". You will find Ctrl-key on the keyboard. Together with "c" it will cancel (interrupt) any previously given command (NOTE: can also be used in DOS terminals)
 
-
[Ctrl-key] c
 
-
For example, if you write "<code>find /</code>" it will start listing all the files on the N900. If you press ctrl+c it will stop.
 
=== Managing Files ===
=== Managing Files ===
-
==== Listing files ====
 
To list files in a directory type ls and hit enter, so
To list files in a directory type ls and hit enter, so
Line 138: Line 95:
  ~ $ ls -l /media/mmc1/*.mp3
  ~ $ ls -l /media/mmc1/*.mp3
-
==== Copying files ====
 
To copy files use cp, so  
To copy files use cp, so  
Line 145: Line 101:
This would make a copy of file and call it file2. Note that "file2" can be a whole other path (like <code>/home/user/MyDocs/afolder/file2</code>).  If file2 already exists it will be overwritten.
This would make a copy of file and call it file2. Note that "file2" can be a whole other path (like <code>/home/user/MyDocs/afolder/file2</code>).  If file2 already exists it will be overwritten.
-
You can also copy multiple files in one go, like so:
+
To change directory use <code>cd</code>, so
-
  ~ $ cp file1 file2 file3 /the/destination
+
  ~ $ cd MyDocs
-
Where the destination must be a directory.
+
To go back a level on a directory
 +
 
 +
~/MyDocs $ cd ..
 +
 
 +
To go back two levels on a directory
 +
 
 +
~ $ cd ../..
 +
 
 +
To go back three... I think you get the idea
 +
 
 +
By the way, the bit before the $, tells you the directory you are in. The symbol <code>~</code> means your home directory, however to find out which directory you are in
 +
 
 +
~ $ pwd
 +
 
 +
<code>pwd</code> stands for present working directory
 +
 
 +
To create a directory, use <code>mkdir</code>
 +
 
 +
mkdir mydirectory
-
==== Moving files ====
 
To move files use <code>mv</code>
To move files use <code>mv</code>
Line 167: Line 140:
The dot at the end of the command means the current directory.
The dot at the end of the command means the current directory.
-
 
-
You can also move multiple files in one go, like so:
 
-
 
-
~ $ mv file1 file2 file3 /the/destination
 
-
 
-
==== Removing files ====
 
To delete a file, use the <code>rm</code> command:
To delete a file, use the <code>rm</code> command:
Line 181: Line 148:
  ~ $ rm -r directory
  ~ $ rm -r directory
-
 
-
Be careful when you use the recursive delete, it will remove everything under the given directory without asking you for a confirmation.
 
-
 
-
==== Directories ====
 
-
 
-
To change directory use <code>cd</code>, so
 
-
 
-
~ $ cd MyDocs
 
-
 
-
To go back a level on a directory
 
-
 
-
~/MyDocs $ cd ..
 
-
 
-
To go back two levels on a directory
 
-
 
-
~ $ cd ../..
 
-
 
-
To go back three... I think you get the idea
 
-
 
-
By the way, the bit before the $, tells you the directory you are in. The symbol <code>~</code> means your home directory, however to find out which directory you are in
 
-
 
-
~ $ pwd
 
-
 
-
<code>pwd</code> stands for present working directory
 
-
 
-
To create a directory, use <code>mkdir</code>
 
-
 
-
mkdir mydirectory
 
-
 
-
And to remove an empty directory, use <code>rmdir</code>
 
-
 
-
rmdir mydirectory
 
=== Directory structure ===
=== Directory structure ===
Line 265: Line 200:
  ~ $ du -m
  ~ $ du -m
-
 
-
To show disk (memory cards, etc.) partitions and their space
 
-
 
-
~ $ df -h
 
-
 
-
To show only rootfs partition
 
-
~ $ df -h /
 
-
 
-
=== Show a list of installed packages ===
 
-
 
-
Show a list of all your programmes installed including those not visible in the Application Manager"
 
-
 
-
dpkg -l
 
=== Piping ===
=== Piping ===
Line 288: Line 210:
<code>du -m</code> lists files in megabytes then pipes it to sort to sort it in order of megabytes, largest first, then the more command shows you one page of the screen at a time, pressing enter to show more pages.
<code>du -m</code> lists files in megabytes then pipes it to sort to sort it in order of megabytes, largest first, then the more command shows you one page of the screen at a time, pressing enter to show more pages.
 +
 +
To show disk (memory cards, etc.) partitions and their space
 +
 +
~ $ df -h
Show Linux Kernel messages:
Show Linux Kernel messages:
Line 302: Line 228:
  ps
  ps
  awk
  awk
-
 
-
=== Networking ===
 
-
 
-
The user PATH does not include /sbin for some reason by default on NITs, which is annoying as you need to type in <code>/sbin/ifconfig</code> when normally just <code>ifconfig</code> would be sufficient. You can create a symlink to <code>/usr/bin</code> to make things easier:
 
-
 
-
~ $ ln -s /sbin/ifconfig /usr/bin/ifconfig
 
-
 
-
Example use of <code>grep</code>, which outputs the entire line matching the pattern, in this case "inet addr" which is piped into it from the output of <code>ifconfig</code>:
 
-
 
-
~ $ ifconfig | grep "inet addr"
 
-
 
-
This advanced example pipes from <code>ifconfig</code> to <code>grep</code> to <code>awk</code> and finally to <code>cut</code> to output the clean IP address which can then be fed into something else if desired:
 
-
 
-
~ $ ifconfig | grep "inet addr" | awk '{ print $2 }' | cut -d : -f2
 
=== Writing a shell function ===
=== Writing a shell function ===
Line 335: Line 247:
=== Debian package management ===
=== Debian package management ===
-
Update local metadata detailing what apps are available in the [[repository|repositories]]. This is important so apt-get can find the latest software:
+
Search [[repository|repositories]] for packages by keyword
-
apt-get update
+
-
 
+
-
<s>Upgrade any installed apps with newer versions (the <code>-y</code> is optional and just avoids it prompting you as to whether or not to proceed):
+
-
apt-get upgrade -y </s> DEPRECATED!
+
-
 
+
-
Remove any downloaded package archives. Once the package is installed the downloaded file is no longer needed. The Application Manager does this automatically but if you are using "apt-get" you'll have to do it manually:
+
-
apt-get clean
+
-
 
+
-
The same as "<code>apt-get clean</code>" but only remove package archives which are obsolete (no longer in repsitories). Having run "<code>apt-get clean</code>" it is pointless to run this command:
+
-
apt-get autoclean
+
-
 
+
-
<s>Remove any packages which are no longer needed. These are applications/libraries which were automatically installed because of dependencies but are no longer required:
+
-
apt-get autoremove
+
-
</s> DEPRECATED! May remove essential pkgs, see http://talk.maemo.org/showthread.php?t=70875
+
-
 
+
-
Install any missing dependencies (which should fix the broken packages issue I had):
+
-
apt-get -f install
+
-
 
+
-
Search repositories for packages by keyword:
+
  ~ $ apt-cache search nano
  ~ $ apt-cache search nano
Line 362: Line 255:
  nano - nano editor
  nano - nano editor
-
Install the <code>nano</code> package (an easy to use CLI text editor):
+
Install the <code>nano</code> package (an easy to use CLI text editor).
  ~ $ apt-get install nano
  ~ $ apt-get install nano
Line 372: Line 265:
Install a locally-stored Debian package:
Install a locally-stored Debian package:
-
  ~ $ dpkg -i nano_2.0.6_armel.deb
+
  ~ $ dpkg -i nano_2.0.6_armel.deb'''
-
+
-
To extract the .deb file for any reason
+
-
~ $ dpkg -x nano_2.0.6_armel.deb /path/to/extraction/directory
+
-
 
+
-
To extract the control file from the .deb file
+
-
~ $ dpkg-deb -e nano_2.0.6_armel.deb
+
-
then you will find the control file named as "control" in "/home/user" if you used "sudo gainroot" to gain root access or in "/root" if you used "root" command to gain root access
+
== Further reading ==
== Further reading ==

Learn more about Contributing to the wiki.


Please note that all contributions to maemo.org wiki may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see maemo.org wiki:Copyrights for details). Do not submit copyrighted work without permission!


Cancel | Editing help (opens in new window)