Linux Terminal Techniques: Mastering the Art of Command-Line Software Removal

Linux Terminal Techniques: Mastering the Art of Command-Line Software Removal

Ian Lv13

Linux Terminal Techniques: Mastering the Art of Command-Line Software Removal

Key Takeaways

  • Identify the installed package’s name by running commands like “apt list –installed” (on Ubuntu) or “dnf list –installed” (on Fedora).
  • On Ubuntu, use the “sudo apt remove [package_name]“ to uninstall the program.
  • On Fedora Linux, the “sudo dnf remove [package_name]“ command will uninstall the package.

Linux distributions provide different methods for installing software. You can install software from the standard Ubuntu or Fedora software repositories using the Software Center, from outside of the standard Ubuntu or Fedora software repositories, or by compiling source code. However, what if you need to uninstall a program?

https://techidaily.com

How to Uninstall Software Using the Command Line on Ubuntu

If you’ve installed software from the Ubuntu software repositories using the Ubuntu Software Center, you can use the Ubuntu Software Center to uninstall that software as well. However, if you’re more comfortable using the command line, we’ll show you an easy way to see what’s installed on your system and uninstall programs.

The command line uninstallation methods will work with any Debian-based Linux distribution , not just Ubuntu.

If you have an idea of what you want to uninstall, but you don’t know the exact name, see our article about finding out exact package names in Linux . You can also use the “dpkg” command to see a list of all installed packages on your computer. Press Ctrl+Alt+T to open a Terminal window, then enter the following command into the prompt:

dpkg –list

Or:

apt list –installed

The commands will display the same content, but it’ll be displayed a little differently.

Running "dpkg --list" in the Termminal on Ubuntu.

Scroll through the list of installed packages in the Terminal window to find the one you want to uninstall. Note the full name of the package.

GIMP listed as an installed program.

To uninstall a program, use the apt command, which is the general command for installing programs and manipulating installed programs. For example, the following command uninstalls gimp and deletes all the configuration files, using the purge command.

sudo apt purge gimp

Enter your password when prompted and press Enter.

The password does not display as you type it. However, you can choose to display asterisks as you type the password .

The uninstallation process begins and a summary of the actions to be taken appears. When asked if you want to continue, type a “y” and press Enter.

Run "sudo apt purge gimp" to uninstall GIMP and remove the configuration files on Ubuntu, or any Debian installation.

https://techidaily.com

The installation process continues. When it’s done, type “exit” at the prompt and press “Enter” to close the Terminal window, or click the “X” button in the upper-left corner of the window.

GIMP was successfully removed.

If you don’t want to remove the configuration files, simply substitute the command remove for purge, as shown in the following command.

sudo apt remove gimp

Enter "sudo apt remove gimp" to remove just GIMP, but leave the configuration files in place.

Programs installed in Linux — just like Windows and MacOS — depend on other packages to function. When you uninstall a program, there may be packages that the uninstalled program depended upon that are no longer used. To remove any unused packages, use the “autoremove” command, as shown in the following example.

sudo apt autoremove

Run "sudo apt autoremove" to remove a package and all of the dependencies it installed.

https://techidaily.com

You can combine the two commands for removing a program and removing dependencies that are no longer being used into one, as shown below (two dashes before “auto-remove”).

sudo apt purge –auto-remove gimp

Run "sudo apt purge --autoremove gimp" to remove all of GIMP's dependencies and the configuration files.

If you’re short on space, you can use the “clean” command to remove downloaded archive files, as shown below.

sudo apt clean

This command removes the aptitude cache in “/var/cache/apt/archives”. When you install a program, the package file is downloaded and stored in that directory. You don’t need to keep the files in that directory. However, there is a potential drawback from deleting them: if you decide to install any of those programs again, the packages will have to be downloaded again.

Run "sudo apt clean" to remove archive files.

The APT is a handy tool that makes downloading, installing, and uninstalling programs quick and easy. For more information about using the “apt” command, type “apt” at the prompt and press Enter.

The older “apt-get” command will accept most of the same arguments as the “apt” command demonstrated here, and you can use that instead if you prefer it.

| | Linux Commands | | |
| —————– | ———————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————— | |
| Files | tar · pv · cat · tac · chmod · grep · diff · sed · ar · man · pushd · popd · fsck · testdisk · seq · fd · pandoc · cd · $PATH · awk · join · jq · fold · uniq · journalctl · tail · stat · ls · fstab · echo · less · chgrp · chown · rev · look · strings · type · rename · zip · unzip · mount · umount · install · fdisk · mkfs · rm · rmdir · rsync · df · gpg · vi · nano · mkdir · du · ln · patch · convert · rclone · shred · srm · scp · gzip · chattr · cut · find · umask · wc · tr | |
| Processes | alias · screen · top · nice · renice · progress · strace · systemd · tmux · chsh · history · at · batch · free · which · dmesg · chfn · usermod · ps · chroot · xargs · tty · pinky · lsof · vmstat · timeout · wall · yes · kill · sleep · sudo · su · time · groupadd · usermod · groups · lshw · shutdown · reboot · halt · poweroff · passwd · lscpu · crontab · date · bg · fg · pidof · nohup · pmap | |
| Networking | netstat · ping · traceroute · ip · ss · whois · fail2ban · bmon · dig · finger · nmap · ftp · curl · wget · who · whoami · w · iptables · ssh-keygen · ufw · arping · firewalld | |

How to Uninstall Software Using the Command Line in Fedora

Fedora is another popular Linux distribution , but uses a different package manager named DNF. Fortunately, DNF shares a lot its syntax with APT — that means if you’re familiar with APT from Debian, you won’t have a difficult time using DNF.

Open up a Terminal window — or just type in the command-line interface (CLI) — and run the following command to list the installed libraries and programs. It’s handy if you know what you want to remove but don’t recall the specific name.

dnf list –installed

Terminal output of the DNF command to list installed packages.

https://techidaily.com

Scroll through the list until you find the program that you’re looking for.

The GIMP package found in the list of installed packages on a Fedora installation.

https://techidaily.com

There are two quick ways to remove a program using DNF.

  • sudo dnf remove — Removes only the specified program and, depending on configuration, additional dependencies.
  • sudo dnf autoremove — Removes the specified program and any additional dependencies it installed always.

Remove is generally a safer command than autoremove. Autoremove has occasionally been known to get a bit overzealous and remove something it shouldn’t. If you don’t care too much about making sure stray dependencies get removed, just use sudo dnf remove.

Enter the following command into the Terminal or CLI, then enter your password.

sudo dnf remove [program name]

For example, if you wanted to remove the GIMP from your PC, it’d look like this:

sudo dnf remove gimp

Note that though the list command showed the GIMP package with its architecture attached to the name, like “gimp.x86_64”, I don’t have to include the architecture or its preceding period in the remove command.

The DNF command to remove the GIMP package.

Just enter “y” and GIMP will be removed.

Typically, the remove command removes any dependencies that were installed with the program. However, depending on your configuration, it might not. If you want to make sure all unnecessary dependencies are removed, use the sudo dnf autoremove command.

The DNF auto-remove command being used to remove GIMP and all its dependencies.

Fedora is usually pretty good at grabbing only the correct dependencies, but if you notice something on the “Removing Unused Dependencies” list that you’d like to keep, you can manually flag it to be kept. Enter the following command in a command line to keep a dependency:

dnf mark install (Dependency/Package Name)

Accidentally uninstalling a package isn’t a big deal — just use dnf install (package) to reinstall it.

Of course, adding and removing packages is only the beginning of running a Linux installation. There are a handful of other basic commands that you should know if you’re going to use Linux regularly.

Also read:

  • Title: Linux Terminal Techniques: Mastering the Art of Command-Line Software Removal
  • Author: Ian
  • Created at : 2024-11-07 16:27:39
  • Updated at : 2024-11-14 03:35:23
  • Link: https://techidaily.com/linux-terminal-techniques-mastering-the-art-of-command-line-software-removal/
  • License: This work is licensed under CC BY-NC-SA 4.0.