Enhancing Skills

apt-get install: Install a specific package

Command: apt-get install

Used to install a specific package from the repositories configured on your system. This command handles package dependencies and installs the package along with any required libraries.


Sample Command and Output:

$ sudo apt-get install vim
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following additional packages will be installed:
  vim-common vim-runtime xxd
Suggested packages:
  ctags vim-doc vim-scripts
The following NEW packages will be installed:
  vim vim-common vim-runtime xxd
0 upgraded, 4 newly installed, 0 to remove and 0 not upgraded.
Need to get 2,536 kB/2,942 kB of archives.
After this operation, 11.0 MB of additional disk space will be used.
Do you want to continue? [Y/n]

Description:

  • sudo apt-get install <package_name>: Installs the specified package (vim in the example). The command checks for package dependencies and prompts for confirmation before proceeding with the installation. It also lists additional packages that will be installed and provides an estimate of the disk space required.

Additional Commands and Sample Outputs:

  • apt-get install -y <package_name>: Install a package without prompting for confirmation. Sample Command and Output:
  $ sudo apt-get install -y vim
  Reading package lists... Done
  Building dependency tree       
  Reading state information... Done
  The following additional packages will be installed:
    vim-common vim-runtime xxd
  Suggested packages:
    ctags vim-doc vim-scripts
  The following NEW packages will be installed:
    vim vim-common vim-runtime xxd
  0 upgraded, 4 newly installed, 0 to remove and 0 not upgraded.
  Need to get 2,536 kB/2,942 kB of archives.
  After this operation, 11.0 MB of additional disk space will be used.

Description:

  • apt-get install -y <package_name>: Automatically confirms the installation of the package and any dependencies without prompting the user. Useful for scripting and automation.
  • apt-get install <package_name>=<version>: Install a specific version of a package. Sample Command and Output:
  $ sudo apt-get install vim=2:8.1.2269-1ubuntu5
  Reading package lists... Done
  Building dependency tree       
  Reading state information... Done
  The following NEW packages will be installed:
    vim
  0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded.
  Need to get 1,804 kB of archives.
  After this operation, 7,896 kB of additional disk space will be used.

Description:

  • apt-get install <package_name>=<version>: Installs a specific version of the package. You need to provide the exact version number available in the repository.
  • apt-get install --reinstall <package_name>: Reinstall an already installed package. Sample Command and Output:
  $ sudo apt-get install --reinstall vim
  Reading package lists... Done
  Building dependency tree       
  Reading state information... Done
  The following packages will be reinstalled:
    vim
  0 upgraded, 1 reinstalled, 0 to remove and 0 not upgraded.
  Need to get 1,804 kB of archives.
  After this operation, 0 B of additional disk space will be used.

Description:

  • apt-get install --reinstall <package_name>: Reinstalls a package that is already installed. Useful for fixing broken installations or replacing corrupted files.

Note: apt-get is a command-line tool used in Debian-based distributions, including Ubuntu, for handling packages. For a more interactive package management experience, you can use apt, which combines some apt-get commands and provides a user-friendly interface.


Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.