Software Management
Introduction
We hope to answer
- what are repositories
- what is a package
- how to install packages
- how to update your computer
- other commands (remove, purge, list)
- other flags(-y, -f, ...)
dpkgvsaptvsapt-get
APT / dpkg
find installed packages
sudo apt list --installed *<part-of-package-name>*
look for packages to install, with more info
apt search <part-of-package-name>
or
dpkg --list | grep <package-name-fragment>
reinstall package
sudo apt --reinstall install <package>
Update packages
sudo apt update && sudo apt upgrade
Note: we want to prevent "unattended" upgrades on hardware. (only upgrade when we mean to). upgrading can also block us from installing something we need, or introduce new bugs at a bad time.
sudo apt remove -y unattended-upgrades
Desktop applications
- ends in .desktop
- found in
/usr/share/applications
Desktop icons
- svg and png typically
- found in
/usr/share/icons
search path
.bashrc holds path variables.
Upgrade Distro
Based on this link
-
Might as well be fully updated first
bash sudo apt update sudo apt upgrade sudo shutdown -r now -
edit which upgrade you want to do (lts or normal)
bash sudo nano /etc/update-manager/release-upgradeschange
prompt=ltstoprompt=normal -
run updater
bash do-release-upgradeyou may need to indicate what to do with specific config files that get updated.
-
Restart
bash sudo shutdown -r now
Package Management
List repositories
To list the repositories on your system, you can use the command:
apt policy
Remove a repository
To remove a repository:
sudo add-apt-repository --remove ppa:PPA_Name/ppa
Show all manually-installed packages
when you want to install a package, sometimes many other dependencies get installed that you did not specify. Here's how you can list packages installed intentionally vs required dependences that were not specified
apt-mark showmanual
Duplicate Installed Packages
To clone your system to another system. Or make a backup. In a terminal type:
dpkg --get-selections | grep -v deinstall > ubuntu-files
This command makes a file list of all installed packages in your system (and stores it in present working directory). Backup this file in hdd, email, etc...(this file is very small).
In the freshly installed ubuntu system run:
sudo dpkg --set-selections <./ubuntu-files (will set it up and)
apt -y update
apt dselect-upgrade
This will install only those packages you had installed (with apt) in the old system.
(OR)
You could back up all the .deb packages from /var/cache/apt/archives/ and install them manually using:
dpkg -i *.deb
And after that running an update cycle later.
Identifying packages installed via logs
You can inspect logs to find installed files:
less /var/log/apt/history.log
Older log files have a number suffix and are compressed. So to view the next history log, use:
zless /var/log/apt/history.log.1.gz
To view the logs available:
ls -la /var/log/apt/
Thus, the first step is to find the first line number where a particular date occurs
cat /var/log/apt/term.log | grep -n 08-15
do that again to find the beginning of the second date range if necessary
cat /var/log/apt/term.log | grep -n 08-16
Then use this technique to select only part of the log and then identify newly added packages
sed '915,10000000!d' /var/log/apt/term.log | grep -i "selecting previously unselected"
this returns something like
Selecting previously unselected package libglfw3:amd64.
Selecting previously unselected package libgl1-mesa-glx:amd64.
Selecting previously unselected package libosmesa6:amd64.
...
Selecting previously unselected package libosmesa6-dev:amd64.
Selecting previously unselected package libglu1-mesa-dev:amd64.
Selecting previously unselected package libglew-dev:amd64
by doing a quick find/replace you can then clean up the list and do a sudo apt remove
sudo apt remove libglfw3:amd64 libgl1-mesa-glx:amd64 libosmesa6:amd64 \
...
libegl1-mesa-dev:amd64 libosmesa6-dev:amd64 libglu1-mesa-dev:amd64