• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
  • Skip to footer navigation

The Geek Diary

  • OS
    • Linux
    • CentOS/RHEL
    • Solaris
    • Oracle Linux
    • VCS
  • Interview Questions
  • Database
    • oracle
    • oracle 12c
    • ASM
    • mysql
    • MariaDB
  • DevOps
    • Docker
    • Shell Scripting
  • Big Data
    • Hadoop
    • Cloudera
    • Hortonworks HDP

apt-get Command Examples in Linux

by admin

apt-get is a command-line utility for installing, updating, and removing packages on a Debian-based Linux system. It is a package manager for the Debian family of Linux distributions, including Ubuntu and Debian itself.

Using apt-get, you can search for and install packages from the command line, as well as upgrade and remove them. You can also update the package database and upgrade all installed packages to the latest versions.

Here are a few examples of common apt-get commands:

  • apt-get update: Update the package database with the latest package information.
  • apt-get upgrade: Upgrade all installed packages to the latest version.
  • apt-get install package-name: Install a package.
  • apt-get remove package-name: Remove a package.
  • apt-get purge package-name: Remove a package and its configuration files.
  • apt-get search package-name: Search for a package by name.

To use apt-get, you must have superuser privileges, which you can obtain by running the sudo command. For example, to install the nano text editor, you could use the following command:

$ sudo apt-get install nano

apt-get Command Examples

1. Update the list of available packages and versions (it’s recommended to run this before other apt-get commands):

# apt-get update

2. Install a package, or update it to the latest available version:

# apt-get install {{package}}

3. Remove a package:

# apt-get remove {{package}}

4. Remove a package and its configuration files:

# apt-get purge {{package}}

5. Upgrade all installed packages to their newest available versions:

# apt-get upgrade

6. Clean the local repository – removing package files (.deb) from interrupted downloads that can no longer be downloaded:

# apt-get autoclean

7. Remove all packages that are no longer needed:

# apt-get autoremove

8. Upgrade installed packages (like upgrade), but remove obsolete packages and install additional packages to meet new dependencies:

# apt-get dist-upgrade

Filed Under: Linux

Some more articles you might also be interested in …

  1. How To Separate Each Of Syslog Client’s Messages Into Different File (CentOS/RHEL 6 and 7)
  2. btrfs rescue Command Examples in Linux
  3. grub-mkconfig Command Options
  4. engrampa Command Examples in Linux
  5. CentOS/RHEL: How to find the package with a missing file using YUM
  6. Understanding the /etc/skel directory in Linux
  7. test Command Examples in Linux
  8. Detect rootkits & malware on Linux Servers using rkhunter
  9. inxi Command Examples in Linux
  10. How to Read Audit Log in Linux

You May Also Like

Primary Sidebar

Recent Posts

  • protonvpn-cli Command Examples in Linux
  • protonvpn-cli connect Command Examples
  • procs Command Examples in Linux
  • prlimit: command not found

© 2023 · The Geek Diary

  • Archives
  • Contact Us
  • Copyright