7 sudo
sudo Super User DO is a prefix of commands that only superuser or root users are allowed to run. It is similar to run as administrator option in Windows. It is used to install, update and remove software. We will use it in the next section to install & update packages.
| Command | Description |
|---|---|
dpkg --list |
List installed packages |
sudo apt-get update |
Update packages |
sudo apt-get install |
Install packages |
sudo apt-get remove |
Remove packages (retain configuration, plugins and settings) |
sudo apt-get purge |
Remove packages including personalized settings |
sudo apt-get autoremove |
Remove any dependencies no longer in use |
7.1 Exercises
- Safe listing (no
sudoneeded): rundpkg --list | head -n 10andapt list --installed 2>/dev/null | head -n 10. Describe in one sentence what kind of information each shows — both list installed software without changing the system. - Without running them, write the commands
sudo apt-get update,sudo apt-get install <pkg>,sudo apt-get remove <pkg>,sudo apt-get purge <pkg>, andsudo apt-get autoremove. State which ofremove/purgekeeps configuration files and which deletes them. - Explain in 2–3 sentences why
apt-get install/remove/purgerequire thesudoprefix whiledpkg --listandapt list --installeddo not (superuser privileges modify system software; read-only queries are safe for any user).
Worked solutions in solutions/sudo.md (attempt first).