×

Linux apt-get command

Apt-get is a command-line that helps to handle the packages in Linux. Its major task is to assist in retrieving data and packages from trusted sources for purposes of installation, update, and removal of the package and any related dependencies. Advanced packaging Tool is the full name of TP.

Linux apt-get command

The Debian, Ubuntu, and Linux Mint operating systems come preinstalled with the apt-get command and other essential APT utilities.

Syntax of Apt-get command

apt-get [-asqdyfmubV] [-o=config_string] [-c=config_file] 
       [-t=target_release] [-a=architecture] 
       { update | upgrade | dselect-upgrade | dist-upgrade |
       install pkg [{=pkg_version_number | /target_release}]... |
       remove pkg... | purge pkg... |
       source pkg [{=pkg_version_number | /target_release}]... |
       build-dep pkg [{=pkg_version_number | /target_release}]... |
       download pkg [{=pkg_version_number | /target_release}]... |
       check | clean | autoclean | autoremove | {-v | --version} |
       {-h | --help}}

Some most popular commands

1. Update: The package index files are once more synchronized from their sources with the help of using below command. Before you upgrade or dist-upgrade, you must run an update.

Updates information about available new and updated packages by resynchronizing the local index of package files. The locations listed in /etc/apt/sources.list are where the indexes are downloaded from.

apt-get update

2. Upgrade: Installing the latest versions of all currently installed packages on the system using the sources provided in /etc/apt/sources.list. A package is fetched and upgraded if a new version is available when it is already installed. Installed packages cannot be removed, and neither can uninstalled packages be recovered. New versions of presently installed packages won't be upgraded unless another package's install status is altered; instead, they will stay at their existing state.

It is usually advisable to update first so that apt-get is aware of the latest package releases.

apt-get upgrade

3. Deselect upgrade: This is used in conjunction with the deselect Debian packaging tool. It observes the modifications made by deselecting to the Status field of the packages that are now accessible and takes any necessary steps to bring about that status.

apt-get deselect-upgrade

4. Dist upgrade: This command handles upgrading and dealing with dependencies that change as a result of new package versions. If necessary, the apt-get command will try to update crucial packages at the expense of less crucial ones. During this process, other packages might also be removed.

Therefore, the dist-upgrade command can get rid of some packages.

The list of places from which package files will be retrieved can be found in the /etc/apt/sources.list file. For a system that alters the default settings for certain packages, see also apt preferences.

apt-get dist-upgrade

5. Install: To install or upgrade packages, use below command. It is followed by the names of any further packages the user wants to install. The appropriate packages will also be downloaded and installed together with all of their dependencies. By adding the desired version number and a "equals" sign to the package name, the user can also select the desired version. Additionally, the user can choose a certain distribution by adding a forward slash to the package name, followed by the version or archive name (such as "stable," testing," or "unstable"). Both of these methods for version selection should be utilized carefully because they have the potential to downgrade the programs.

apt-get install [...PACKAGES]

6. Remove: This is comparable to installing, but removes the packages as opposed to installing them. No configuration files produced by the software are deleted.

apt-get remove [...PACKAGES]

7. Purge: The packages are removed together with any associated configuration files by this command.

apt-get purge [...PACKAGES]

8. Check: The package cache is updated with this command, which also looks for broken dependencies.

apt-get check

9. Download: The specified binary package is downloaded in the current directory with this command.

apt-get download [...PACKAGES]

10. Clean: This operation clears the local repository of all retrieved package files. Everything excluding the lock file is removed from /var/cache/apt/archives/partial/ and /var/cache/apt/archives/.

apt-get clean

11. Autoremove: When automated packages that are installed to meet the dependencies of other packages are no longer required, the autoremove command is used to get rid of them.

apt-get autoremove

12. Source: To choose which source package to retrieve, APT will look at the currently installed packages. In accordance with any default releases specified using the APT::Default-Release option, the -t option, or per package using the pkg/release syntax, the most recent version of that source package will then be located and downloaded into the current directory.

By using deb-src lines in the sources. List file and source packages are tracked independently from binary packages.

When the —compile option is used, the package will be built using dpkg-build package to produce a binary.deb for the architecture supplied by the —host-architecture option. Using the —download-only option prevents the source package from being unpacked.

Similar to the method used for package files, a specific source version may be requested by prefixing the source name with an equals sign before the version to fetch. This automatically activates the APT::Get::Only-Source option and allows for accurate matching of the source package name and version.

Be aware that source packages are downloaded to the current directory as source tarballs rather than being installed and recorded in the dpkg database like binary packages are.

13. Changelog: Downloads a package changelog and uses a sensible pager to display it. The APT::Changelogs::Server variable specifies the server name and base directory. It shows the changelog for the installed version by default. The same arguments as for the install command can be specified, though.

Options:

–No-install-recommends: By selecting this option, the user instructs apt-get not regarding suggested packages as installation dependencies.

apt-get --no-install-recommends [...COMMAND]
  • –Install-suggests: The user instructs apt-get to take suggested packages into account when determining which dependencies to install by passing this option.
apt-get --install-suggests  [...COMM
  • -d or –download-only: The user instructs apt-get not to unpack or install the packages; instead, they should only be retrieved by passing this option.
apt-get -d [...COMMAND]
  • -f or –fix-broken: The user instructs apt-get to make an attempt to fix the system's faulty dependencies by passing this option.
apt-get -f [...COMMAND]
  • -m or –ignore-missing or –fix-missing: By passing this option, the user tells apt-get how to treat the result and disregard any missing packages (packages that can't be retrieved or fail the integrity check).

apt-get -m [...COMMAND]

  • –no-download: The user can prevent apt-get from downloading by passing this command. The only.debs it should utilize are those it has previously downloaded, according to this.
apt-get  [...COMMAND]
  • -q or –quie: Apt-get generates output that is acceptable for logging when this option is supplied.
apt-get  [...COMMAND]
  • -s or –simulate or –just-print or –dry-run or –recon or –no-act: This option clearly states that nothing should be done. Instead, a simulation of what would happen if the system as it is now were to continue is run.
apt-get -s [...COMMAND]
  • -y or –yes or –assume-yes: The user may occasionally be asked a yes/no question while the apt-get command is running. With this option, it is defined that it should run automatically and presume "yes" for all questions.
apt-get -y [...COMMAND]
  • –assume-no: Apt-get assumes "no" for all prompts when this option is selected.
apt-get --assume-no [...COMMAND]
  • –no-show-upgraded: This setting prevents apt-get from displaying a list of every package that has to be upgraded.
apt-get --no-show-upgraded [...COMMAND]
  •   -V or –verbose-versions: With this option, apt-get will show user-friendly progress in the terminal window while the packages are installed, deleted, or upgraded.
apt-get -V [...COMMAND]
  • –Show-progress: With this selection, apt-get will display user-friendly progress during the installation, removal, or upgrade of the packages in the terminal window.
apt-get --show-progress [...COMMAND]
  • -b or –compile or –build: This setting instructs apt-get to build the source packages it downloads.
apt-get -b [...COMMAND]
  • –no-upgrade: If the packages are already installed, apt-get won't allow them to be upgraded.
apt-get --no-upgrade [...COMMAND]
  • –Only-upgrade: With this selection, apt-get won't install any new packages; it will only upgrade the existing packages.
apt-get --only-upgrade [...COMMAND]
  • –reinstall: When using this option, apt-get updates any already installed packages to the most recent versions.
apt-get --reinstall [...COMMAND]
  • –Auto-remove or –autoremove: This option functions as the autoremove command when executing the install or remove command with apt-get.
apt-get install/remove --autoremove [...PACKAGES]
  • -h or –help: A brief usage summary is shown by apt-get using this option.
apt-get -h

Output

  1. -v or –version: The current version number of apt-get is displayed using this option.
apt-get  [...COMMAND]
Linux apt-get command

Output

Linux apt-get command

Note: - The apt-get command returns zero (zero) for successful executions and one hundred (one hundred) for errors.


Related Topics

ping Command in Linux/Unix with Examples

The "ping" command in Linux (and other Unix-like operating systems) is used to test the connectivity between two networked devices. The "ping" command sends a small packet of data, called...

4 minutes read.

cut Command in Linux/Unix with Examples

The "cut" command in Linux (and other Unix-like operating systems) is used to remove sections from each line of a file or stream of data. The cut command is often...

3 minutes read.

mkdir Command in Linux/Unix with Examples

The "mkdir" command in Linux (and other Unix-like operating systems) is used to create new directories. The "mkdir" command stands for "make directory" and it is used to create a...

3 minutes read.

ls Command in Linux/Unix with Examples

The ls command in Linux is a command-line utility that is used to list the files and directories in a directory. It is one of the most basic and commonly...

4 minutes read.

wget Command in Linux/Unix with Examples

The wget command is a command-line utility in Linux that is used to download files from the internet. It supports various protocols including HTTP, HTTPS, and FTP and can be...

5 minutes read.

chown Command in Linux/Unix with Examples

The 'chown' command in Linux is used to change the ownership of a file or directory. The command stands for "change owner" and it allows you to change the user...

3 minutes read.

df Command in Linux/Unix with Examples

The 'df' command in Linux is used to display the amount of disk space available on the file system. The command reports the amount of disk space used and available...

3 minutes read.

addr2line Command in Linux with Examples

Use of addr2line Command The addr2line command is used to convert addresses to line numbers and file names. This command uses debugging info to check which line number and file name...

4 minutes read.

top Command in Linux/Unix with Examples

The 'top' command in Linux is a real-time system monitoring tool that displays information about the running processes and system resource usage. The command provides a dynamic, scrolling view of...

4 minutes read.

Rename Folder in Linux

Rename Folder in Linux In the Linux system, there is not any single dedicated command for renaming the files and directories. Mostly, the mv command is used extensively for the purpose...

3 minutes read.

echo Command in Linux/Unix with Examples

The "echo" command in Linux is used to display a line of text on the terminal. It can also be used to print the value of a variable or to...

3 minutes read.

cat Command in Linux/Unix with Examples

The cat command in Linux is a command-line utility that is used to display the contents of a text file. It stands for "concatenate" and it is used to view...

4 minutes read.

curl Command in Linux/Unix with Examples

The 'curl' command in Linux is a command-line tool that allows you to transfer data from or to a server using various protocols, including HTTP, HTTPS, FTP, and many more....

3 minutes read.

cp Command in Linux/Unix with Examples

The cp (copy) command in Linux is a command-line utility that is used to copy files and directories. It is one of the most basic and commonly used commands in...

5 minutes read.

gzip Command in Linux/Unix with Examples

The gzip command in Linux is used for compressing and decompressing files. It uses the Lempel-Ziv coding (LZ77) algorithm to compress files, which is known for its high compression ratio...

6 minutes read.

Linux cd

Linux cd: As in GUI operating systems like Windows 10, we use the mouse to travel to various folders back and forth; similarly, we have the “cd” command in Linux...

4 minutes read.

find Command in Linux/Unix with Examples

The find command in Linux is a command-line utility that is used to search for files and directories in a file system. It is a versatile command that can be...

5 minutes read.

sudo Command in Linux/Unix with Examples

The sudo command in Linux is used to run a command or set of commands with the privileges of another user, typically the root user. This allows users to perform...

3 minutes read.

mv Command in Linux/Unix with Examples

The 'mv' command in Linux is used to move or rename files and directories. The command stands for "move" and it allows you to move files and directories from one...

3 minutes read.

Linux Commands List

Linux Commands List The Linux systems are filled with commands for several use cases. We have divided these commands into some of the most common implementations for a better understanding of...

2 minutes read.