apt Command in Linux

Learn via video courses
Topics Covered

Transform Your Career

Choose from our industry-leading programs designed for career success

NSDC Certified

Modern Software and AI Engineering Program

Master full-stack development with AI integration

12 MonthsDuration
AI-LedCurriculum
Career SupportSupport
GoogleAmazonPaytm+1000 more
Go to Program
NSDC Certified

Modern Data Science and ML with specialisation in AI

Advanced data science techniques with AI specialization

12 MonthsDuration
AI-LedCurriculum
Career SupportSupport
GoogleAmazonPaytm+1000 more
Go to Program
NSDC Certified

Advanced AIML with Specialisation in Agentic AI

Deep dive into AIML with focus on Agentic systems

12 MonthsDuration
AI-LedCurriculum
Career SupportSupport
GoogleAmazonPaytm+1000 more
Go to Program
NSDC Certified

DevOps, Cloud & AI Platform Engineering

Build and manage AI-powered cloud infrastructure

12 MonthsDuration
AI-LedCurriculum
Career SupportSupport
GoogleAmazonPaytm+1000 more
Go to Program
NSDC Certified

AI Engineering Advanced Certification by IIT-Roorkee

Premier AI engineering certification from IIT-Roorkee

3 MonthsDuration
AI-LedCurriculum
Career SupportSupport
Program highlights
Go to Program

Overview

The Advanced Packaging Tool, apt command in Linux, is a powerful command-line tool used for handling packages in Ubuntu/Debian-based systems. It provides powerful, consistent command-line interfaces for package management and takes care of dependencies automatically.

Syntax of apt Command in Linux

The basic syntax of the apt command in Linux is as follows:

Where:

  • options: Options are the optional flags that can be used with the apt command to modify its behavior. For example, '-y' is used to answer 'yes' to all prompts.
  • command: This is the action you want to perform, such as install, remove, upgrade, etc.
Free Courses by top Scaler instructors
Python Course for Beginners With Certification: Mastering the Essentials
Java Course - Mastering the Fundamentals
DBMS Course - Master the Fundamentals and Advanced Concepts
JavaScript Course With Certification: Unlocking the Power of JavaScript
C++ Course: Learn the Essentials
Python and SQL for Data Science Course
Python Course for Beginners With Certification: Mastering the Essentials
Java Course - Mastering the Fundamentals
DBMS Course - Master the Fundamentals and Advanced Concepts
JavaScript Course With Certification: Unlocking the Power of JavaScript
C++ Course: Learn the Essentials
Python and SQL for Data Science Course

Options in apt Command in Linux

  1. -y: This option is used to answer 'yes' to all prompts during the operation.

    For example -

    Output:

    The '-y' option instructs apt to proceed with all actions without asking for confirmation.

  2. --show-progress: This option is used to display the progress during the operation.

    For example -

    Output:

    The '--show-progress' option makes apt show a progress indicator during the operation.

  3. --fix-broken: This option attempts to correct a system with broken dependencies in place.

    For example -

    Output:

    The '--fix-broken' option commands apt to try and fix unresolved dependencies.

Scaler Placement Report and Statistics

₹23L
AVG CTC
SCALER PLACEMENT PROOF

Scaler learners achieved 2.5x salary growth with average post-Scaler CTC reaching ₹23L.

11,000+placements
650+companies
Verified data
Hiring Partners:
GoogleGoogleAmazonAmazonMicrosoftMicrosoftFlipkartFlipkartAdobeAdobe1200+ more

Example Usages

  • Installing a package.:

    Output:

    Explanation: The 'install' command is used to install a new package, in this case, Vim text editor.

  • Upgrading all upgradable packages.:

    Output:

    Explanation: The 'upgrade' command upgrades all the upgradable packages in the system.

Tips

  • Always use 'sudo apt update' before 'sudo apt upgrade' to ensure your package lists are up-to-date.

  • Use 'sudo apt autoremove' to remove packages that were automatically installed to satisfy dependencies for other packages and are now no longer needed.

Turn Learning into Career Growth

1200+Hiring Partners
89%Placement Rate
11,000+Placements
147%Avg Salary Increment
2.5XCareer Growth
₹23 LPAAvg Post-Scaler Salary
1200+Hiring Partners
89%Placement Rate
11,000+Placements
147%Avg Salary Increment
2.5XCareer Growth
₹23 LPAAvg Post-Scaler Salary

Advanced Use Cases of apt Command in Linux

  • Use 'dist-upgrade' command to intelligently handle changing dependencies.:

    Output:

    Explanation: The 'dist-upgrade' command will upgrade your system by handling changing dependencies with new versions of packages.

  • Use 'full-upgrade' command which performs the function of upgrade but also removes installed packages if needed.:

    Output:

    Explanation: The 'full-upgrade' command performs the same function as 'upgrade' but will remove currently installed packages if necessary.

  • Hold a package using 'hold' command to prevent it from being automatically installed, upgraded or removed.:

    Output:

    Explanation: The 'hold' command is used to mark a package to hold back its installation or upgrade.

Conclusion

  • The apt command in Linux is a powerful tool for managing packages in Ubuntu and Debian-based systems.

  • It simplifies the process of installing, upgrading, and removing software packages.

  • Advanced options and commands allow fine-grained control over your system's software packages and dependencies.