This tutorial is for Ubuntu 13.04.
It is probably the same for other versions of Ubuntu and (probably) most other Linux distributions, but no guarantee is made.
Detailed instructions for opening a command line / terminal can be found here.
When you work at the command line, from time to time, it may be necessary to edit files.
You can use an editor like
gedit (the GUI based editor that comes with Ubuntu), however, by default, it will not permit you to edit system configuration files (which are likely the files you are trying to edit if you happen to be at the command line).
Starting gedit with Administrator Privileges
Enter the following command to start
gedit with administrator privileges:
Note: when you type your password, nothing will happen on the screen. This is normal. As a security feature, Linux does not echo back any indication of the characters you are typing in.
You should only be prompted to enter a password if you have not used the
sudo command in the last 15 minutes or so.
You can also append the file you wish to open to the command. This will cause
gedit to automatically open the file. For example:
sudo gedit history.log
Note: this will only work if the file is in the current directory. However, if you are at the command line, then you probably have navigated to the directory in question.
Editing with nano
Sometimes, you cannot use
gedit because you have no graphical interface (GUI) – for example, you need to edit some x-server settings because you can’t get a graphical display, so you are exclusively at a command line.
vi or one of its clones (
vile to name some) tend to be the preferred text editor among Unix / Linux geeks – it is not the friendliest for casual (or one-off) users. The other major editor is
emacs, but it is not installed by default in Ubuntu and it is not user friendly either.
nano is a clone of the
nano enter the command:
Note: It will also launch if you type in
gedit you can append the name of the file you want to edit to the command.
nano is a simple editor that allows you to navigate through the text using the arrow keys on your keyboard.
At the bottom of the screen, there are two lines (highlighted in blue) that display a number of common commands.
The caret (
^) symbol means
Ctrl, as in,
Ctrl + X. This means, “while holding down the
Ctrl key, you press the other key as though you intend to type it”.
DO NOT press the Shift key because
Ctrl + Shift + X is different from
Ctrl + X.
It does NOT matter if your Caps Lock is on or off.
The most common commands you are likely to use are:
Ctrl + X) exit the editor
Ctrl + O) save / write the contents of the editor
Ctrl + R) open / read another file
If you decide to browse through the help (
Ctrl + G), then be aware of the following:
Ctrl + ^not
Ctrl + Ctrl
Altkey is used the same way the
Ctrlkey is: it is held down while another key is typed. For example:
M-\means: while holding down the
Altkey, press the
\key as though you intend to type it.
- Some commands have parentheses around them, the parentheses are not to be typed. For example,
Alt + X– the parentheses have nothing to do with it and should be ignored.