Terminal

(Just adding some stuff while waiting. Feel free to delete, amend whatever you feel is appropriate.)
(showing commands in white boxes for clearer reading)
Line 1: Line 1:
This page is for beginners to Linux that would like to try the terminal. Below are some basic commands you can use in the terminal app to get you started.  
This page is for beginners to Linux that would like to try the terminal. Below are some basic commands you can use in the terminal app to get you started.  
-
'''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' 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.  
+
'''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' 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.  
'''Understand what a command does before you type it'''
'''Understand what a command does before you type it'''
Line 10: Line 11:
The terminal should open with a  
The terminal should open with a  
-
~ #
+
~ #
To exit the terminal at any time type, exit and enter, so
To exit the terminal at any time type, exit and enter, so
-
~# exit [enter]
+
~# exit [enter]
To list files in a directory type ls and hit enter, so
To list files in a directory type ls and hit enter, so
-
~# ls [enter]
+
~# ls [enter]
To list files in a directory with permissions, owners, time, the use the long format with ls, which is ls -l enter
To list files in a directory with permissions, owners, time, the use the long format with ls, which is ls -l enter
-
~# ls -l [enter]
+
~# ls -l [enter]
To list hidden files and directories
To list hidden files and directories
-
~# ls -la [enter]
+
~# ls -la [enter]
Show disk usage in megabytes
Show disk usage in megabytes
-
~# du -m [enter]
+
~# du -m [enter]
You can do fancy things and link commands together with what is called a pipe (this symbol: | ). What the pipe does is that it takes one program's output and gives it to another as input.
You can do fancy things and link commands together with what is called a pipe (this symbol: | ). What the pipe does is that it takes one program's output and gives it to another as input.
Line 36: Line 37:
So using du with the sort command you can list files and sort in order of megabytes,
So using du with the sort command you can list files and sort in order of megabytes,
-
~# du -m | sort -r -n | more [enter]
+
~# du -m | sort -r -n | more [enter]
du -m list 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 the next page.
du -m list 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 the next page.
Line 42: Line 43:
To copy files use cp, so  
To copy files use cp, so  
-
~# cp file file2 [enter]
+
~# cp file file2 [enter]
This would make a copy of file and call it file2. Note that "file2" can be a whole other path (like /home/user/MyDocs/afolder/file2)
This would make a copy of file and call it file2. Note that "file2" can be a whole other path (like /home/user/MyDocs/afolder/file2)
Line 48: Line 49:
To change directory use cd, so
To change directory use cd, so
-
~# cd MyDocs/ [enter]
+
~# cd MyDocs/ [enter]
To go back a level on a directory
To go back a level on a directory
-
~# cd ../ [enter]
+
~# cd ../ [enter]
To go back two levels on a directory
To go back two levels on a directory
-
~# cd ../../ [enter]
+
~# cd ../../ [enter]
To go back three... I think you get the idea
To go back three... I think you get the idea
Line 62: Line 63:
To find out which directory you are in
To find out which directory you are in
-
~# pwd [enter]
+
~# pwd [enter]
pwd stands for present working directory
pwd stands for present working directory
Line 68: Line 69:
To create a directory, use mkdir
To create a directory, use mkdir
-
mkdir mydirectory/ [enter]
+
mkdir mydirectory/ [enter]
To move files use mv
To move files use mv
-
~# mv file2 mydirectory/file2 [enter]
+
~# mv file2 mydirectory/file2 [enter]
moving file2 to mydirectory/ directory
moving file2 to mydirectory/ directory
Line 78: Line 79:
You can also use mv to rename a file
You can also use mv to rename a file
-
~#mv file newname
+
~#mv file newname
But what happens if I want to copy stuff into the directory I am already in do I have to type out the whole direcotry tree again. Well you can but it is much simpler to do the following:
But what happens if I want to copy stuff into the directory I am already in do I have to type out the whole direcotry tree again. Well you can but it is much simpler to do the following:
-
~#mv smydirectory/file .
+
~#mv smydirectory/file .
The dot at the end of the command means the current directory.
The dot at the end of the command means the current directory.
One thing to note is the directory structure on the N810. When you open the terminal on the N810 you are in the directory /home/user Equivalent to MyDocuments in Windows. The top level directory like C: drive on Windows is a / known as a root directory. Try and stay in the /home/user directory at first, or look at your memory cards which is in the directory /media.  
One thing to note is the directory structure on the N810. When you open the terminal on the N810 you are in the directory /home/user Equivalent to MyDocuments in Windows. The top level directory like C: drive on Windows is a / known as a root directory. Try and stay in the /home/user directory at first, or look at your memory cards which is in the directory /media.  
-
 
Again to reiterate make sure you backup your data before tinkering and when you want to try a new command, make sure you understand what it does first.
Again to reiterate make sure you backup your data before tinkering and when you want to try a new command, make sure you understand what it does first.
'''!!Page is still under contruction!!'''
'''!!Page is still under contruction!!'''

Revision as of 17:58, 5 December 2009

This page is for beginners to Linux that would like to try the terminal. Below are some basic commands you can use in the terminal app to get you started.

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' 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.

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 desktop distribution, like Ubuntu, you can normally type the command with the parameter --help to get a list of options, i.e. ls --help, or look up manual pages if installed, with man ls [enter] 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 Linux commands or Busybox list of Linux commands and options for each one

Some example commands, all here are non-destructive.

The terminal should open with a

~ #

To exit the terminal at any time type, exit and enter, so

~# exit [enter]

To list files in a directory type ls and hit enter, so

~# ls [enter]

To list files in a directory with permissions, owners, time, the use the long format with ls, which is ls -l enter

~# ls -l [enter]

To list hidden files and directories

~# ls -la [enter]

Show disk usage in megabytes

~# du -m [enter]

You can do fancy things and link commands together with what is called a pipe (this symbol: | ). What the pipe does is that it takes one program's output and gives it to another as input.

So using du with the sort command you can list files and sort in order of megabytes,

~# du -m | sort -r -n | more [enter]

du -m list 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 the next page.

To copy files use cp, so

~# cp file file2 [enter]

This would make a copy of file and call it file2. Note that "file2" can be a whole other path (like /home/user/MyDocs/afolder/file2)

To change directory use cd, so

~# cd MyDocs/ [enter]

To go back a level on a directory

~# cd ../ [enter]

To go back two levels on a directory

~# cd ../../ [enter]

To go back three... I think you get the idea

To find out which directory you are in

~# pwd [enter]

pwd stands for present working directory

To create a directory, use mkdir

mkdir mydirectory/ [enter]

To move files use mv

~# mv file2 mydirectory/file2 [enter]

moving file2 to mydirectory/ directory

You can also use mv to rename a file

~#mv file newname

But what happens if I want to copy stuff into the directory I am already in do I have to type out the whole direcotry tree again. Well you can but it is much simpler to do the following:

~#mv smydirectory/file .

The dot at the end of the command means the current directory.

One thing to note is the directory structure on the N810. When you open the terminal on the N810 you are in the directory /home/user Equivalent to MyDocuments in Windows. The top level directory like C: drive on Windows is a / known as a root directory. Try and stay in the /home/user directory at first, or look at your memory cards which is in the directory /media.

Again to reiterate make sure you backup your data before tinkering and when you want to try a new command, make sure you understand what it does first.

!!Page is still under contruction!!