Interview Q&A / Linux & Shell

INTERVIEW Q&A · 63 QUESTIONS

Linux & Shell interview questions

Permissions, processes, pipes and the commands you are expected to know cold.

  1. What is the difference between apt and apt-get?

    apt is the newer, friendlier front-end for interactive use, with a progress bar and combined commands such as apt install and apt list. apt-get is the older, stable interface with predictable output, so it is preferred in scripts.

    BeginnerQuick answer1 min read
  2. What is the difference between apt remove, purge and autoremove?

    remove deletes a package's programs but keeps its configuration files. purge deletes the programs and the configs. autoremove deletes dependency packages that were installed automatically and are no longer needed by anything.

    BeginnerQuick answer1 min read
  3. What is the difference between apt update and apt upgrade?

    apt update refreshes the local list of available packages and versions from the repositories but installs nothing. apt upgrade then installs newer versions of the packages you already have. Run update first, otherwise upgrade works from stale information.

    BeginnerQuick answer1 min read
  4. What is the difference between dpkg or rpm and apt or dnf?

    dpkg (Debian) and rpm (Red Hat) install, remove and inspect single package files, but do not fetch dependencies. apt and dnf sit on top: they download from repositories and resolve dependencies automatically, calling dpkg or rpm to do the actual installation.

    BeginnerQuick answer1 min read
  5. How do you find which package a file or command belongs to?

    On Debian and Ubuntu use dpkg -S /path/to/file for installed files and apt-file search for files not yet installed. On Red Hat family systems use rpm -qf /path for installed files and dnf provides '*/name' for uninstalled ones.

    IntermediateQuick answer1 min read
  6. How do you stop a package from being upgraded on Debian or Ubuntu?

    Use sudo apt-mark hold package to freeze it at the current version and apt-mark unhold to release it. For finer control, such as preferring a specific version or repository, use APT pinning in /etc/apt/preferences.d/.

    IntermediateQuick answer1 min read
  7. What is a package repository, and why do package managers check GPG signatures?

    A repository is a server holding packages and an index that package managers read. Packages and indexes are signed with GPG keys so your system can verify they came from the publisher and were not altered. Adding a third-party repository means trusting its key.

    IntermediateQuick answer1 min read