Bird
Raised Fist0
Linux CLIscripting~5 mins

Repository management in Linux CLI - Cheat Sheet & Quick Revision

Choose your learning style10 modes available
Recall & Review
beginner
What is a repository in Linux package management?
A repository is a storage location on the internet or local network where software packages are kept. It allows your system to download and install software easily and safely.
Click to reveal answer
beginner
How do you update the list of available packages on a Debian-based system?
You run the command sudo apt update. This refreshes the package list from all configured repositories so you can install the latest versions.
Click to reveal answer
intermediate
What command adds a new repository on a Debian-based system?
You can add a new repository by editing the /etc/apt/sources.list file or adding a file in /etc/apt/sources.list.d/. Then run sudo apt update to refresh.
Click to reveal answer
beginner
What is the purpose of the yum or dnf commands in repository management?
yum and dnf are package managers for Red Hat-based systems. They manage repositories, install, update, and remove software packages.
Click to reveal answer
beginner
Why is it important to keep your repositories updated?
Keeping repositories updated ensures you get the latest software versions, security patches, and bug fixes. It helps keep your system safe and running smoothly.
Click to reveal answer
Which command updates the package list on Ubuntu?
Asudo apt update
Bsudo apt upgrade
Csudo apt install
Dsudo apt remove
Where are repository sources listed on Debian-based systems?
A/etc/apt/sources.list
B/etc/yum.repos.d/
C/usr/bin/repos
D/var/lib/repos
What does the dnf command do?
ACreates new Linux users
BUpdates Windows software
CManages packages and repositories on Red Hat-based systems
DFormats hard drives
Why should you run sudo apt update after adding a new repository?
ATo clear the cache
BTo uninstall old packages
CTo reboot the system
DTo refresh the package list and include the new repository's packages
What file format do repository configuration files usually have on Debian systems?
A.xml
B.list
C.conf
D.repo
Explain how to add a new software repository on a Debian-based Linux system and why it is necessary to update the package list afterward.
Think about where repository info is stored and what command refreshes package info.
You got /4 concepts.
    Describe the role of package managers like apt, yum, and dnf in repository management.
    Consider how these tools help keep your system software organized and up to date.
    You got /4 concepts.

      Practice

      (1/5)
      1. What is the purpose of the git init command in repository management?
      easy
      A. To add files to the staging area
      B. To check the status of the repository
      C. To upload changes to a remote repository
      D. To create a new Git repository in the current directory

      Solution

      1. Step 1: Understand the role of git init

        This command sets up a new Git repository by creating necessary files and folders in the current directory.
      2. Step 2: Differentiate from other commands

        git add stages files, git push uploads changes, and git status shows repository state, so they do not create a repository.
      3. Final Answer:

        To create a new Git repository in the current directory -> Option D
      4. Quick Check:

        git init creates repo [OK]
      Hint: Remember: init means start a new repo [OK]
      Common Mistakes:
      • Confusing git init with git add
      • Thinking git init uploads files
      • Using git init to check status
      2. Which of the following is the correct syntax to add all changed files to the staging area in Git?
      easy
      A. git add .
      B. git add *
      C. git add -all
      D. git add --commit

      Solution

      1. Step 1: Identify the command to stage all changes

        git add . stages all changes in the current directory and subdirectories.
      2. Step 2: Check other options for correctness

        git add * may not include hidden files, git add -all is invalid, and git add --commit is not a valid option.
      3. Final Answer:

        git add . -> Option A
      4. Quick Check:

        git add . stages all files [OK]
      Hint: Use dot (.) to add all files in current folder [OK]
      Common Mistakes:
      • Using git add * which misses hidden files
      • Typing invalid options like -all
      • Confusing git add with commit commands
      3. What will be the output of the command git status immediately after running git init in a new directory?
      medium
      A. fatal: not a git repository (or any of the parent directories): .git
      B. On branch main nothing to commit, working tree clean
      C. On branch main No commits yet nothing to commit (create/copy files and use "git add" to track)
      D. On branch master nothing to commit, working tree clean

      Solution

      1. Step 1: Understand initial state after git init

        After initializing, the repository has no commits yet, so git status shows "No commits yet" and instructions to add files.
      2. Step 2: Check branch name and messages

        Modern Git uses "main" as default branch, and the message includes "nothing to commit (create/copy files and use \"git add\" to track)".
      3. Final Answer:

        On branch main No commits yet nothing to commit (create/copy files and use "git add" to track) -> Option C
      4. Quick Check:

        New repo status shows no commits yet [OK]
      Hint: New repo shows 'No commits yet' on main branch [OK]
      Common Mistakes:
      • Expecting 'master' branch instead of 'main'
      • Thinking working tree is clean immediately
      • Confusing error message with valid status
      4. You ran git commit -m "Initial commit" but got the error: nothing to commit, working tree clean. What is the most likely cause?
      medium
      A. The repository is not initialized
      B. You forgot to run git add to stage files before committing
      C. The commit message is missing quotes
      D. You need to run git push first

      Solution

      1. Step 1: Analyze the error message meaning

        The message means there are no staged changes to commit, so Git has nothing to save.
      2. Step 2: Identify missing step before commit

        Files must be staged using git add before committing; skipping this causes the error.
      3. Final Answer:

        You forgot to run git add to stage files before committing -> Option B
      4. Quick Check:

        Stage files before commit [OK]
      Hint: Always add files before commit [OK]
      Common Mistakes:
      • Trying to push before committing
      • Ignoring the need to stage files
      • Assuming commit message syntax error
      5. You cloned a repository and want to update your local copy with the latest changes from the remote. Which sequence of commands correctly achieves this?
      hard
      A. git fetch origin; git merge origin/main
      B. git pull origin main; git add .
      C. git push origin main; git commit -m "update"
      D. git clone origin; git commit -m "update"

      Solution

      1. Step 1: Understand how to update local repo from remote

        git fetch origin downloads changes from remote without merging, then git merge origin/main applies those changes to your current branch.
      2. Step 2: Check other options for correctness

        git pull origin main combines fetch and merge but git add . after pull is unnecessary; git push uploads changes, not updates; git clone is for initial copy, not update.
      3. Final Answer:

        git fetch origin; git merge origin/main -> Option A
      4. Quick Check:

        Fetch then merge updates local repo [OK]
      Hint: Fetch then merge to update local repo safely [OK]
      Common Mistakes:
      • Using push instead of pull to update
      • Running add after pull unnecessarily
      • Trying to clone again to update
      Recommended

      Ready to prove it?

      Pass the test and this pattern moves unknown strong while earning +1 Grip toward your certificate.

      10 questions~5 mineasy hard