Published on

Basic Terminal Commands: man, wget, and apt

Authors
  • avatar
    Name
    Hieu Cao
    Twitter

Introduction

When working on a Linux system, common tasks include looking up information, downloading files, and managing software packages. Three essential commands—man, wget, and apt—help you perform these tasks efficiently. This article introduces each command with examples to get you started.

The man Command: Viewing Manuals

The man command displays the manual page for a command or program.

Syntax

man [command]

Common Use Cases

  1. Look up command information

    man ls
    
    • Displays detailed documentation for the ls command.
  2. Search for keywords in a manual While in a man page, press / to search for a keyword.

  3. Navigate the manual

    • Press Space to go to the next page.
    • Press q to quit the manual.

The wget Command: Downloading Files

The wget command is used to download files from the internet via HTTP, HTTPS, or FTP.

Syntax

wget [options] URL

Common Use Cases

  1. Download a single file

    wget https://example.com/file.zip
    
    • Downloads the file file.zip from the specified URL.
  2. Download a file with a specific name

    wget -O myfile.zip https://example.com/file.zip
    
    • Saves the file as myfile.zip.
  3. Resume an interrupted download

    wget -c https://example.com/file.zip
    
    • Continues downloading a partially downloaded file.

The apt Command: Managing Software Packages

The apt command is a package management tool commonly used on Debian-based systems like Ubuntu.

Syntax

sudo apt [options] command

Common Use Cases

  1. Update the package list

    sudo apt update
    
    • Updates the list of available packages from the repositories.
  2. Upgrade installed packages

    sudo apt upgrade
    
    • Updates all installed packages to their latest versions.
  3. Install a package

    sudo apt install package-name
    
    • Installs the package named package-name.
  4. Remove a package

    sudo apt remove package-name
    
    • Removes the package package-name from the system.
  5. Completely remove a package and its configuration

    sudo apt purge package-name
    
    • Deletes both the package and its related configuration files.

Practical Example

Combine the above commands in a basic workflow:

  1. Look up information about the wget command

    man wget
    
  2. Download a file from the internet

    wget https://example.com/sample.pdf
    
  3. Install a new software package

    sudo apt install curl
    

Conclusion

The man, wget, and apt commands are powerful tools for Linux users. Understanding and using them effectively can make your workflow more efficient. Practice regularly to master these commands!