How I do a system restore?
Solution 1:
There is a software for Linux called Timeshift exactly for this purpose. Using Timeshift you can take snapshots of your Linux system regularly and restore them whenever you need.
This software brings System Restore feature of Windows to your Linux distribution.
A short description from its official website:
TimeShift for Linux is a application that provides functionality similar to the System Restore feature in Windows and the Time Machine tool in Mac OS. TimeShift protects your system by taking incremental snapshots of the file system at regular intervals. These snapshots can be restored later to bring your system to the exact state it was in at the time when the snapshot was taken.
Snapshots are taken using rsync and hard-links. Common files are shared between snapshots which saves disk space. Each snapshot is a full system backup that can be browsed with a file manager.
Solution 2:
Actually, there are few things in Ubuntu et al. that will allow you to roll-back changes. Brief below:
-
/var/backups/dpkg.status.*
: this directory keeps a set of log of the last system state prior to an install as follows;/var/backups/dpkg.status.0
is the most recent log prior to a state change (e.g. package install/remove/update ...etc);/var/backups/dpkg.status.?.gz
are compressed, archived versions of the logs at various points in time, rotated monthly. -
/var/lib/dpkg/status
: this is the current state of installed packages. Manually backing this up, or providing a logrotate script in/etc/logrotate.d
will ensure schedule snapshots of your system state to your liking. -
Roll-back: the corner stone is your previous state
/var/backups/dpkg.status.0
. Here is a brief step-wise procedure to restore previous package state (note brief and not exhaustive).a.
cp /var/backups/dpkg.status /var/lib/dpkg/status
(will revert back the package state one version back).b.
dpkg -l | grep ii
(will give you a list of supposedly installed packages based on the rolled-back/var/lib/dpkg/status
file achieved in step a. above).c.
dpkg -l | grep ii | awk '{print "apt-get --reinstall -y install", $2}' > /tmp/reinstall && sh /tmp/reinstall
(will create a simple one-liner shell script and runs that to reinstall packages determined to have been on the system prior to an apt-get operation)d.
apt-get --reinstall install ucf
(will take care of sanitising /etc config files et. al)e. Repeat step c. if/as necessary
With a minimal bit of luck, you should be OK.
Solution 3:
The complement of apt-get install package
is apt-get remove package
. To remove all associated settings too, you need to run apt-get purge package
.
Note that these commands rely on the uninstallation scripts provided with the package. All packages in the main repository I know of do their job of uninstalling very well. This may not be the case for third-party packages.
As for your driver issue, there are a few possibilities why installing a package broke your wireless driver:
- The driver has a post-installation hook which is executed when a condition is met, e.g. kernel updates
- The package overwrote a file that the wireless driver depended on
- The package in question was a kernel update but the driver does not have a post-installation hook for recompiling the driver (most likely)
As for the "System rollback" / "System Restore" features, the closest feature you'll get is a system image using software like Clonezilla. Unfortunately, this cannot be done within a running system and must be performed from a Live CD.