Installing Software and Intro to Vim

In the Linux world, the process of installing software is as follows: your computer first downloads the software from a server, then it installs it on your computer. The server in question is a server maintained by the people who maintain your distribution. Each Linux distribution has its own software server. For example, the people behind Ubuntu have a server from which you can install software. They ensure that the software in their server is malware-free and secure. You don't have to worry about accidentally installing malicious software if you use your distribution's server. There is a special name for this type of ‘server’, it's called a repository.

By default, Ubuntu comes with an application that you can use to install software. Search for “Software” in the applications menu to find it. It provides a GUI interface to search for and install software from the Ubuntu repository. However, you can also use the command line to install software. The command for installing, removing, and updating software on Ubuntu is called apt.

apt

Before we get into installing software, let's update the software on our computer. There is a handy command that updates all the software on your computer at once! Simply type in the first 2 lines shown below. It will prompt you for your password (enter the password you use to login). You will notice that there is no visual feedback while entering your password. This is normal.

sudo apt update
sudo apt upgrade

Notice that we are prepending our command with sudo. I will explain why later. After running the first 2 commands (seperately) in a terminal, all your software (on Ubuntu, not Windows) will be up-to-date. The first command fetches the list of new software from the repository. The second one actually upgrades the software on your computer to a newer version. You need to run both commands (the first before the second) to update your software. Linux does not update your computer automatically (unlike Windows), so you will have to update it manually, from time to time. Either issue these 2 commands, or use the graphical program mentionned before (it will remind you to update when updates are available, so don't worry).

The next 3 commands allow you to install and remove software on your computer. Simply replace <package> with the name of the software you want to install or remove. The word ‘package’ just refers to the bundle of files that make up the software. You can just think of it as the name of the software or program. For example, sudo apt install vim, will install a program called vim. We will use this program later, so go ahead and install it now.

sudo apt install <package>
sudo apt remove <package>
sudo apt purge <package>

sudo apt remove <package> does exactly what you think it does: it uninstalls the program. sudo apt purge <package>, however, is slightly different. It uninstalls the program, and also deletes all of its configuration files. If you use the sudo apt remove command, then ff you install the package again later, your configuration files from before will be intact, wheras with purge, they won't. Realistically, you will use remove most of the time, and purge is only useful if you accidentally messed up the software's configuration files, or you want to install a fresh version of it.

sudo

Notice that we put sudo in front of the apt command. sudo is a command that let's you run other commands as the root user. The root user is just the default user that comes with Linux. Just like how you created a user account when you installed Linux, the root user (account) also exists (here, ‘user’ is synonymous to what you might think of as an ‘account’ on your computer). However, you cannot login as the root user, which is why you don't see it as an option on the login screen. The reason it exists is that regular users (like the one you created during installation), by default, don't have permissions to do some things on Linux. There are some files that you cannot write to, there are some commands that you cannot run, etc. (Sidenote: This is due to the historical use of Linux on large mainframe computers, that had multiple users. But to us, it means that there are some things that you cannot do, but the root user, can) apt is one such command that regular users cannot use. The sudo command helps us with this. It runs whatever command that follows it as a root user. So, it's as if the root user had run that command. Thus, by using the sudo apt update command, you, as a regular user, will be able to run the apt command.

As you already found out, running sudo apt update will prompt you for your password. This is a security feature, so that when you are running a command as the root user (who has the power to do anything on your computer), the computer will make sure that its really you who is entering the command. The sudo command can also be used with any command, but it's only useful if a regular user cannot issue the command (try entering apt update, without the ‘sudo’, and see what happens).

vim

Vim is a text editor that works in the terminal. It edits plain text files, just like notepad does on Windows. However, it is more complex, and has a steep learning curve. We will learn more about vim in later lessons, but if you missed this week's lesson, you can enter the following command, which will walk you through the basics of vim:

vimtutor

Just for reference, to use vim you simply type in vim in a terminal, followed by the filename you wish to edit.

vim myFile

If you don't enter a filename, you can still enter text and edit it like a regular file, but to save your edits you will need to specify a filename while exiting vim, like so: :wq filename. If that doesn't make sense to you, go do vimtutor first.

And If you want, look up a vim tutorial or youtube video for more info.