Linux+: Applications 22 – Optional Commands with Apt-Get

J

Jarret W. Buse

Guest
Linux+: Applications 22 – Optional Commands with Apt-Get

As with most command-line commands, there are optional commands used to add functionality. The apt-get command is no exception and has numerous optional parameters.

The optional parameters are:
  • --no-install-recommends
  • --install-suggests
  • -d (--download-only)
  • -f (--fix-broken)
  • -m (--ignore-missing, --fix-missing)
  • --no-download
  • -q (--quiet)
  • -s (--simulate, --just-print, --dry-run, --recon, --no-act)
  • -y (--yes, --assume-yes)
  • --assume-no
  • -u (--show-upgraded)
  • -V (--verbose-versions)
  • -a (--host-architecture)
  • -P (--build-profiles)
  • -b (--compile, --build)
  • --ignore-hold
  • --with-new-pkgs
  • --no-upgrade
  • --only-upgrade
  • --force-yes
  • --print-uris
  • --purge
  • --reinstall
  • --list-cleanup
  • -t (--target-release, --default-release)
  • --trivial-only
  • --no-remove
  • --auto-remove
  • --only-source
  • --diff-only, --dsc-only, tar-only
  • --arch-only
  • --allow-unauthenticated
  • --show-progress
  • -h (--help)
  • -v (--version)
  • -c (--config-file)
  • -o (--option)

Now, to cover each of these individually.

  • --no-install-recommends

Recommended packages are not considered as dependencies and will not be installed. The option can help save space, but files which are recommended are not included and may be needed later. A command could be “sudo apt-get --no-install-recommends install totem”. In this case, the recommended packages “totem-plugins” and “gstreamer1.0-pulseaudio” would not be installed with totem.


  • --install-suggests

Suggested packages are considered dependencies and will be installed. A sample command would be “sudo apt-get --install-suggests install totem”. Here, the five suggested files would be installed with the totem package.


  • -d (--download-only)

The option causes the packages to be downloaded, but not unpackaged or installed. The files should be placed into /var/cache/apt/archives. The command could be “sudo apt-get -d install 2ping”.


  • -f (--fix-broken)

Dependencies may be accidentally removed causing programs to not work. In this case, a dependency is broken and needs to be repaired. The command to fix a broken dependency is “sudo apt-get -f install”. Dependencies will be checked and repaired if needed.


  • -m (--ignore-missing, --fix-missing)

If dependencies are downloaded which are corrupted or the dependency cannot be found then the option allows that dependency to be ignored. The install should continue as normal with the error of a missing dependency being overlooked as the install is continued and not halted. A command could be “sudo apt-get -m install totem”.


  • --no-download

If a package has previously been downloaded, the cached files can be used instead of downloading them again. The command would be “sudo apt-get --no-download install 2ping”.


  • -q (--quiet)

Provides a quiet output suitable for logging without progress indicators. A sample command would be “sudo apt-get -q install totem”.


  • -s (--simulate, --just-print, --dry-run, --recon, --no-act)

Causes the command to be simulated without changing any system settings. A sample is “sudo apt-get -s remove totem”.


  • -y (--yes, --assume-yes)

Causes all queries to be answered with a “yes”. A sample command would be “sudo apt-get -y remove 2ping”.


  • --assume-no

Causes all queries to be answered with a “no”. A sample command would be “sudo apt-get --assume-no remove 2ping”.


  • -u (--show-upgraded)

Shows packages which are to be upgraded. Command is “sudo apt-get -u upgrade”.


  • -V (--verbose-versions)

Shows full version information on all listed files. For example, when listing the upgradeable packages, you can see the versions with the command “sudo apt-get -u -V upgrade”.


  • -a (--host-architecture)

The “-a” option allows files to be downloaded for other architectures. The command would be “sudo apt-get download --host-architecture=amd64 firefox”.


NOTE: If the system is not compatible to the specified architecture, the proper repositories must be allowed to be used for the other architectures.


  • -P (--build-profiles)

Use specified build profiles when compiling source files.


  • -b (--compile, --build)

If source code packages are downloaded, the “-b” parameter can be used to compile them after the are downloaded. A sample command is “sudo apt-get -b source 2ping”. The command downloads the source code for the package “2ping” and compiles it.


  • --ignore-hold

The “--ignore-hold” will cause an upgrade or removal to be performed on all packages, even those with a hold on them. An example would be “sudo apt-get --ignore-hold remove 2ping”.


  • --with-new-pkgs

To install new available dependencies on packages, the option will allow those to be upgraded. The command would be “sudo apt-get --with-new-pkgs upgrade”.


  • --no-upgrade

Prevents files from being upgraded which already exist such as dependencies. For example, if Firefox were installed which updated a dependency that caused another package to fail, you could use the command “sudo apt-get --no-upgrade install firefox”.


  • --only-upgrade

Used with the “install” subcommand. Only packages already installed will be upgraded, but no packages will be installed. The command is “sudo apt-get --only-upgrade install”.


  • --force-yes

All queries will be answered as yes even if the result can be harmful. A command could be “sudo apt-get --force-yes install firefox”.


  • --print-uris

Instead of downloading the required files, their URI will be displayed. The Uniform Resource Identifier (URI) can include path, destination name, file size and md5 hash. The option works with the update and source subcommands. An example is “sudo apt-get --print-uris source firefox”.


  • --purge

Used to remove a package and its configuration files. An example is “sudo apt-get --purge remove 2ping”.


  • --reinstall

If a package is corrupted and failing it can be reinstalled. If a newer version exists, then the package would be upgraded as well. The command is like “sudo apt-get --reinstall install firefox”.


  • --list-cleanup

The option will cause the obsolete files in /var/lib/apt/lists to be removed during a list update. An example is “sudo apt-get --list-cleanup update”. The option “--no-list-cleanup update” can turn the option off.


  • -t (--target-release, --default-release)

The apt-get program will download the specified version of a package. Packages can be labeled as “stable”, “testing” or “unstable”. Each of these can be specified to make sure the package downloaded is the type needed or wanted. An example is to download the latest version stable version of firefox with the command “sudo apt-get -t stable install firefox”.


  • --trivial-only

Similar to “--assume-yes”, the “--trivial-only” option answers “no” to all prompts. An example is “sudo apt-get --trivial-only install firefox”.


  • --no-remove

Causes any command to skip any removal of packages. If an error occurs for dependencies, but you want none removed, you can fix it and skip removal with the command “sudo apt-get -f -no-remove install”.


  • --auto-remove

When used with the subcommand install or remove, all unused dependencies are removed. The command can be like “sudo apt-get --auto-remove install 2ping”.


  • --only-source

When used with the “source” subcommand, allows the package name to be specified when downloading source files. A command could be “sudo apt-get --only-source source 2ping”.


  • --diff-only, --dsc-only, tar-only

Downloads only the .diff, .dsc or .tar of a file of the source. For example, to get the tar file for the source of Firefox, the command would be “sudo apt-get --tar-only source firefox”.


  • --arch-only

Process only the dependencies for the architecture. To check the dependencies of Firefox for the architecture use the command “sudo apt-get --arch-only build-dep firefox”.


  • --allow-unauthenticated

Allows package authentication to be ignored and do not prompt for it when getting a source package.


  • --show-progress

Progress information is shown when performing an install, removal or upgrade. An example is “sudo apt-get --show-progress install 2ping”.


  • -h (--help)
Shows help information for apt-get. The command is “apt-get -h”.


  • -v (--version)

Shows the apt-get version with the command “apt-get -v”.


  • -c (--config-file)

Uses a different configuration file other than the default. An example is “sudo apt-get -c=~/apt.conf install firefox”.


  • -o (--option)

Sets a configuration option to be used for the current command without having to change the configuration file or an environment variable. An example is “sudo apt-get -o=APT::Get::Fix-Broken=true install”. The example will perform the same as “sudo apt-get -f install” since the configuration item for the -f option is APT::Get::Fix-Broken.


Keep these options in mind to help enhance the ability of the normal subcommands so apt-get will operate as needed.
 

Attachments




Top