Ubuntu Linux Commands and Uninstallation

PUBLISHED 1 AUGUST 2019

Author: InvisibleUser Team

In the last article, we have explained why you should go for an Ubuntu-based distro if you are a Linux beginner. Now let us help you get started. In this chapter, we will only introduce some very basic Linux commands. They are used to install software, update the system in various ways and search for packages. Those are the commands you will need on your first day of using Linux. For more advanced configuration options, please visit the official Ubuntu documentation . Ubuntu commands also work on its derivatives.


Basic Commands and Usage

For a newcomer to Ubuntu-based systems, we recommend installing software with the software centre. Should you not find an application, you can download it from the website of the developer most of the time and install it with the dpkg package manager for DEB files. Alternatively, download the more user-friendly, graphical Synaptic package manager from the software centre and use that. If all other options do not work, you can use the Linux command line. The most useful commands are (name is the name of the package):

  • Searching for packages: apt-cache search name
  • Installation: sudo apt-get install name
  • Uninstallation: sudo apt-get remove name
  • Look for updates: sudo apt-get update
  • Install updates strictly for current packages: sudo apt-get upgrade This Linux command updates packages, it never removes old ones. If an update is only possible by removing an existing package, the update will not be performed.
  • Install new updates (might remove older packages): sudo apt-get dist-upgrade Intelligently handles changing dependencies, solves package conflicts, focuses on important packages at the expense of less important ones if necessary.
    • OR install updates with full-upgrade: sudo apt-get full-upgrade This will update everything and full-upgrade is a newer tool than dist-upgrade, full-upgrade has been available since Ubuntu 14.04. It will not prioritise packages at the expense of others and remove packages to resolve a package conflict.
  • Remove any old packages that are no longer needed: sudo apt-get autoremove
  • Uninstall software: Use “dpkg –list” to list all packages. Look for the package to uninstall, e.g. gimp. Then type in sudo apt-get --purge remove gimp. That uninstalls the program but also the configuration files. If you do not want to remove them, just type sudo apt-get remove gimp, instead. Some packages leave dependencies behind, you do not need them anymore, so delete them with sudo apt-get autoremove.
  • Get the manual: With the command man apt-get, you can view the manual of apt-get with detailed descriptions. The same is possible for the Debian package management system with the command man dpkg.

On Ubuntu and some others, you can use apt, instead of apt-get, e.g. sudo apt autoremove. More info on that in this guide from It’s FOSS. To learn more about upgrade vs dist-upgrade and other Linux commands, visit AskUbuntu.

The official apt-get manual is here.

Additional tips

While these commands are used to update your current Ubuntu release, e.g. 19.04, it is also possible to upgrade to the newer version, like 19.04 -→ 19.10, for example. How you do this can be found here on AskUbuntu.

When you want to access a folder with Linux commands, use forward slashes “/” like on macOS. That is a difference to Windows, on Windows you would have to use backward slashes “\”. You can easily remember this: “Windows is thinking backwards, while Linux goes forward.cd directory_name is used to change the directory, ls is used to list contents of a directory.


Remove Linux (if you messed up) or Windows

Easy way

Should you not like a Linux distro, you can easily remove it if you have it installed as a dual-boot machine together with Windows. Install AOMEI Partition Assistant on Windows. Delete the Linux partition and merge it with your Windows partition. That probably requires a restart, reboot and open AOEMI again. Right-click the Windows partition and choose Rebuild MBR. Follow the wizard that opens. You will boot automatically into Windows from now on.

Hard way

Should you not like a Linux distro, you can easily remove it if you have it installed as a dual-boot machine together with Windows. You just have to boot into Windows and erase the Linux partition using the Windows Disk Management tool or AOMEI. Then, you can rebuild the Master Boot Record (MBR) to make your PC boot Windows automatically and remove Linux completely. Go to the Start Menu on Windows, press and hold Shift and click Restart. In the menu that appears, go to Troubleshoot>Advanced options>Command Promt>%username, enter your password.

Now enter the command bootrec/fixmbr and hit Enter. Do the same with bootrec/fixboot and bootrec/scanos. Now make Windows the primary OS again with bootrec/rebuildbcd, confirm the boot list by typing A and hit Enter. Finally, type exit and press Enter. You will boot automatically into Windows from now on.


Of course, it is also possible to remove Windows from a dual-boot machine and keep Linux. This is quite a bit easier, because of the tools Linux provides. Just boot into a live-OS, like an Ubuntu flash drive, for example. Then, open the GNOME Disk Utility, delete the Windows partition and expand the Linux partition to the whole disk. Click the Apply All Operations button in the toolbar to perform the selected tasks. Finally, we have to fix the GRUB boot loader, which is done by opening the Terminal with Ctrl + Alt + T and typing in sudo update-grub. You have to confirm this with your password. That is all, Windows should be gone. A great guide is here on LifeHacker.com.

Configure the GRUB Bootloader

If you want to keep a dual-boot system, it is probably smart to give the GRUB bootloader a clear structure. You can add themes, change the order of the entries or rename them with the GUI tool GRUB Customizer.

To get this tool, you will need to add an apt repository, since it is not in the official Ubuntu/Debian repositories. So, open a Terminal with Ctrl + Alt + T and type in the command sudo add-apt-repository ppa:danielrichter2007/grub-customizer to install the necessary repositories, hit Enter and install the GRUB Customizer with sudo apt-get install grub-customizer. Then, open the software. You can now hit the pen icon to edit entries or move them up or down with the arrows. It is pretty self-explanatory and we are sure you will figure it out in no time. This is an absolutely fantastic tool, since doing the same with the command-line is quite a hassle.

Here is a guide if you need more assistance. A great cheat sheet with useful Linux commands is offered by LinOxide. They also provide a section with advanced commands that go beyond the basics.

Previous

Choosing a Linux Distro Guide

Next

Linux’ Weakness 1 – Packages, Releases and Distro Websites