Installing new software and updating the system

In this section, we will show you how you can install new software on your computer and how to update your CentOS 7 system.

First, let's show all the currently installed RPM packages on the system. Type yum list installed:

In the installation chapter in Chapter 1, Introduction to Linux, we already demonstrated how you can do a full system update using the yum command, which will update all of the RPM packages that are already included in the minimal installation, and also all the packages we have installed afterwards.

To get a list of all the updates currently available for all the software packages already installed on your system, type the following command to see what's new: yum check update:

Here, all the RPM software packages are listed with the new version of the updates you can install. All updates must be done using the root user. So first log in as root. To update only a single ROM software package, such as the vim-minimal package, which was presented in the list of available software updates, use yum update and then incorporate the name of the package; for example, vim-minimal. Type yes when asked to update the software package, and type yes again to confirm the importing of the GBG key:

As we can see, the vim-minimal package has been successfully updated to the latest version. As we have already learned in Chapter 1Introduction to Linux, in this book, just type yum update to do a full system update of all the packages currently installed on your system. Now let's press the N key to cancel the download and installation of the updates of all the packages. Most yum commands need some kind of confirmation by the user; for example, to confirm the update of software packages. If you are absolutely sure that you will answer yes to any question, you can further automate the yum command of your choosing by providing the -y flag. This works on almost any command. This will perform the yum action of your choosing without further confirmation by the user.

Please note that there is a big ongoing debate as to whether you need to restart your system after packages have been updated. The consensus is that normally this is not needed, but, if the kernel or glibc software packages have been updated, you should do it. Of course, you should really do it for security reasons.

We can also see that the reboot is necessary when we compare the currently installed kernel with the currently running kernel in the system:

The currently running kernel ends with 514.el7. The currently installed latest kernel ends with 514.21, so we are currently not running the latest kernel. So let's reboot the system. After rebooting has finished and you are logged in as the root user back to the system, type the uname -r command again, and now we can see that we are now running the latest kernel, so rebooting was necessary in this instance:

Now, to search in your package repositories using a keyword (for example, Apache2 Web Server), use the yum search command and then the keyword. This will print out a list of all the software packages matching the keyword; in our example, apache, in the package name or in the package description:

If you want to get more information about one of the package names (for example, the HTTP package name), you can use the yum info subcommand.

Another really useful feature is if you know the name of a file or command included in an RPM package, but actually don't know the name of the RPM package where this command or file is from, you can use the yum whatprovides command, prefixing the command or file you are searching for with an */:

In this example, we are searching for all the package names that include files or commands named ifconfig. As we can see, we have one hit in the net-tools RPM package where a binary or command exists in /bin/ifconfig.

Now, to install a software package, use the yum install command, providing the package name as an argument. Here, in this example, we install the Apache HTTP server package:

Another interesting command is the rpm -ql command followed by the name of the installed software package to get a list of all the files and their exact location in the filesystem that has been installed by this software package. To remove a software package, you can use the yum remove command and then the name of the software package you want to remove.

In Chapter 4, Working with the Command Line, we showed you how to use a third-party repository, called epl, to install software such as htop, and iotop because they are not available from the official CentOS 7 repositories. For example, if you search for the htop package, it's not available from official sources:

So let's install the epl repository, as it is available from default package sources. As you can see, the epl repository can be installed using the epl-release RPM package:

Use the following command to see if the epl repository has been successfully installed by retrieving a list of all the available repositories in the system.

We can now find the htop package, as it is part of epl. Installing other repositories is not so easy, since no RPM packages are available from the official sources, but most third-party repositories can be installed by downloading an external RPM. You will most likely find the repositories on a web page. For example, for the famous remi repository, you can first download the official remi repository RPM package from the official remi website:

Next, install this downloaded remi repository RPM using the rpm command with the capital Uvh option:

Then, you need to enable the remi repository by editing the remi yum config file. First, open the remi.repo file in your /etc/yum.repos.d folder. Here, in this file, go to the section remi, then go down to the keyword enabled and change it from 0 to 1:

Now save the file. Then you can use your newly installed third-party repository after updating your repositories software packages list. To recheck if the third-party repositories have been installed correctly, you can also use the yum repolist command again: