Upgrade Software and Install the Emacs Text Editor

One of the first things I do after a fresh OS installation, and something that you should do often, is upgrade the software with the latest patches. To do this, run the following commands on the Raspberry Pi:


ubuntu@ubuntu:~$ sudo apt update

ubuntu@ubuntu:~$ sudo apt upgrade


The sudo command means "run the given command as the Super User". The apt command is the software application manager that can download any requested open-source packages from Ubuntu servers on the web, along with any dependent software packages that the requested packages may need. The update option checks with the Ubuntu servers to see which newer packages are available to replace the existing packages on your Raspberry Pi. The upgrade command installs these newer packages and removes the older versions. Note that you will be prompted for your new 'ubuntu' user password when you first run the sudo, to make sure you are you. You will also be asked if it is ok the install these new packages.

The next step is to install a text editor, so you can edit files from the terminal window. Vi is a common text editor that is typically installed by default on all Linux distributions, but I like to use emacs because it has a lot of support for developers. If you are running a desktop environment then you can use development software like eclipse or even simple graphical text editors like nedit, but it's always good to know how to edit text in a terminal window, so I recommend trying out emacs. To install emacs, run sudo apt install emacs in your ubuntu login on the Raspberry Pi and follow the prompts.


A quick emacs tutorial

Here is a very quick tutorial on emacs. Run the following command: emacs -nw hello.txt. The '-nw' tells emacs not to try and open a separate graphical window. The 'hello.txt' is the name of a new file that you will create in the local directory. Type 'Hello Dean!' in the emacs window, and hit 'return'. Then type 'Ctrl-x' followed by 'Ctrl-s' (Ctrl-x means hold down the 'Ctrl' key and press the 'x' key). The 'Ctrl-x' action will move the focus from the editing window to the bottom control bar, and the 'Ctrl-s' action tells emacs to save the file. Now that you have saved the file, you can exit by typing 'Ctrl-x' followed by 'Ctrl-c'. Congratulations, you've just written your first text file in emacs!