Originally Posted by
tojonukokhadush
i am wondering if there's any mechanism by which we can find the history of changes made in any files especially system files in linux and therefore in ubuntu!
Depends on how the system was setup. E.g. Ubuntu with ZFS as filesystem offers that functionality out of the box, as everytime you install something a snapshot will be taken. And you can browse those snapshots and compare the files inside of them.
Example from one of my systems:
On a ZFS setup the "/boot" filesystem resides on a ZFS pool called "bpool". So to the see all snapshots that exist of "bpool" I'd type a command such as:
Code:
> zfs list -t snapshot -o creation,space -s creation -r bpool
CREATION NAME AVAIL USED USEDSNAP USEDDS USEDREFRESERV USEDCHILD
Tue Mar 2 7:18 2021 bpool/BOOT/ubuntu_r07xkn@FreshInstall_WorkingOK_20210301 - 56K - - - -
Tue Mar 2 7:32 2021 bpool/BOOT/ubuntu_r07xkn@DataPool_Imported-OK - 8K - - - -
Tue Mar 2 12:34 2021 bpool/BOOT/ubuntu_r07xkn@Everything_WorkingOK_20210302 - 8K - - - -
Sun Apr 18 3:15 2021 bpool/BOOT/ubuntu_r07xkn@Backup_2021-04-18 - 157M - - - -
Sun May 9 19:17 2021 bpool/BOOT/ubuntu_r07xkn@Backup_2021-05-09 - 72K - - - -
Tue May 11 1:07 2021 bpool/BOOT/ubuntu_r07xkn@autozsys_837u48 - 72K - - - -
Tue May 11 1:41 2021 bpool/BOOT/ubuntu_r07xkn@autozsys_hhs6ex - 88K - - - -
Wed May 12 16:10 2021 bpool/BOOT/ubuntu_r07xkn@autozsys_hyzi9v - 56K - - - -
Wed May 12 21:54 2021 bpool/BOOT/ubuntu_r07xkn@autozsys_1ihpf0 - 48K - - - -
Sat May 15 2:38 2021 bpool/BOOT/ubuntu_r07xkn@autozsys_0hpp1d - 48K - - - -
Mon May 17 13:59 2021 bpool/BOOT/ubuntu_r07xkn@autozsys_mnvd5c - 56K - - - -
Tue May 18 22:27 2021 bpool/BOOT/ubuntu_r07xkn@autozsys_yp1t6t - 64K - - - -
Wed May 19 9:32 2021 bpool/BOOT/ubuntu_r07xkn@autozsys_s79yfb - 64K - - - -
Thu May 20 9:23 2021 bpool/BOOT/ubuntu_r07xkn@autozsys_7hvkjk - 64K - - - -
Tue May 25 10:57 2021 bpool/BOOT/ubuntu_r07xkn@autozsys_j76hpe - 56K - - - -
Wed May 26 10:07 2021 bpool/BOOT/ubuntu_r07xkn@autozsys_nwf9vi - 0B - - - -
Thu May 27 10:20 2021 bpool/BOOT/ubuntu_r07xkn@autozsys_jgruvm - 0B - - - -
Thu May 27 22:22 2021 bpool/BOOT/ubuntu_r07xkn@autozsys_d8gs1w - 0B - - - -
Wed Jun 2 14:06 2021 bpool/BOOT/ubuntu_r07xkn@autozsys_ynckg2 - 0B - - - -
Thu Jun 3 10:08 2021 bpool/BOOT/ubuntu_r07xkn@autozsys_p7qqg8 - 72K - - - -
Thu Jun 3 10:25 2021 bpool/BOOT/ubuntu_r07xkn@autozsys_dyd4m5 - 88K - - - -
Fri Jun 4 11:09 2021 bpool/BOOT/ubuntu_r07xkn@autozsys_7tfnz4 - 56K - - - -
Tue Jun 8 2:49 2021 bpool/BOOT/ubuntu_r07xkn@autozsys_mgbmzr - 56K - - - -
Wed Jun 9 11:04 2021 bpool/BOOT/ubuntu_r07xkn@autozsys_c1fzhx - 64K - - - -
Thu Jun 10 6:51 2021 bpool/BOOT/ubuntu_r07xkn@autozsys_conc7f - 0B - - - -
I did a manual snapshot on March 2 that I called "FreshInstall_WorkingOK_20210301" ... I can enter into it and take a look what's inside:
Code:
# cd /boot/.zfs/snapshot/FreshInstall_WorkingOK_20210301/
# ls -al
total 184993
drwxr-xr-x 4 root root 19 Mar 2 01:44 .
drwxrwxrwx 2 root root 2 Jun 10 10:35 ..
-rw-r--r-- 1 root root 237718 Apr 20 2020 config-5.4.0-26-generic
-rw-r--r-- 1 root root 237730 Jan 27 22:44 config-5.4.0-66-generic
drwxr-xr-x 2 root root 2 Mar 2 01:10 efi
drwxr-xr-x 2 root root 2 Mar 2 01:10 grub
lrwxrwxrwx 1 root root 27 Mar 2 01:21 initrd.img -> initrd.img-5.4.0-66-generic
-rw-r--r-- 1 root root 82430171 Mar 2 01:41 initrd.img-5.4.0-26-generic
-rw-r--r-- 1 root root 82531431 Mar 2 01:44 initrd.img-5.4.0-66-generic
lrwxrwxrwx 1 root root 27 Mar 2 01:10 initrd.img.old -> initrd.img-5.4.0-26-generic
-rw-r--r-- 1 root root 182704 Aug 18 2020 memtest86+.bin
-rw-r--r-- 1 root root 184380 Aug 18 2020 memtest86+.elf
-rw-r--r-- 1 root root 184884 Aug 18 2020 memtest86+_multiboot.bin
-rw------- 1 root root 4736015 Apr 20 2020 System.map-5.4.0-26-generic
-rw------- 1 root root 4746873 Jan 27 22:44 System.map-5.4.0-66-generic
lrwxrwxrwx 1 root root 24 Mar 2 01:21 vmlinuz -> vmlinuz-5.4.0-66-generic
-rw-r--r-- 1 root root 11657976 Apr 23 2020 vmlinuz-5.4.0-26-generic
-rw------- 1 root root 11690752 Jan 27 23:14 vmlinuz-5.4.0-66-generic
lrwxrwxrwx 1 root root 24 Mar 2 01:21 vmlinuz.old -> vmlinuz-5.4.0-26-generic
What I get here is the content of my "/boot" filesystem how it was back on March 2, 2021 when this system was freshly installed.
And I can of course compare that against my current contents of "/boot" that are live now:
Code:
root: /boot/.zfs/snapshot/FreshInstall_WorkingOK_20210301 # ls -al /boot/
total 189569
drwxr-xr-x 4 root root 19 Jun 9 11:06 .
drwxr-xr-x 20 root root 26 Mar 2 07:30 ..
-rw-r--r-- 1 root root 237851 Apr 14 18:35 config-5.4.0-73-generic
-rw-r--r-- 1 root root 237851 May 8 02:45 config-5.4.0-74-generic
drwxr-xr-x 4 root root 4096 Jan 1 1970 efi
drwxr-xr-x 4 root root 4096 Jun 10 06:51 grub
lrwxrwxrwx 1 root root 27 Jun 3 10:09 initrd.img -> initrd.img-5.4.0-74-generic
-rw-r--r-- 1 root root 84686305 Jun 9 11:06 initrd.img-5.4.0-73-generic
-rw-r--r-- 1 root root 84694981 Jun 9 11:06 initrd.img-5.4.0-74-generic
lrwxrwxrwx 1 root root 27 Jun 3 10:09 initrd.img.old -> initrd.img-5.4.0-73-generic
-rw-r--r-- 1 root root 182704 Aug 18 2020 memtest86+.bin
-rw-r--r-- 1 root root 184380 Aug 18 2020 memtest86+.elf
-rw-r--r-- 1 root root 184884 Aug 18 2020 memtest86+_multiboot.bin
-rw------- 1 root root 4750832 Apr 14 18:35 System.map-5.4.0-73-generic
-rw------- 1 root root 4751152 May 8 02:45 System.map-5.4.0-74-generic
lrwxrwxrwx 1 root root 24 Jun 3 10:09 vmlinuz -> vmlinuz-5.4.0-74-generic
-rw------- 1 root root 11764480 Apr 14 18:37 vmlinuz-5.4.0-73-generic
-rw------- 1 root root 11763968 May 8 03:42 vmlinuz-5.4.0-74-generic
lrwxrwxrwx 1 root root 24 Jun 3 10:09 vmlinuz.old -> vmlinuz-5.4.0-73-generic
It's already easy to tell that there were several Linux kernel upgrades between March 2 and now, e.g. the March 2 snapshot still lists files belonging to kernel 5.4.0-26 whereas the current content of "/boot" lists kernel 5.4.0-74.
I could now use every Linux tool in the arsenal (e.g. tools such as "diff" and so on) to see what exactly has changed between each file in the snapshot and the currently live one, e.g. the GRUB config.
There are other mechanisms, tools and ideas (e.g. regularly uploading your config files to a Git repository and then checking the differences via the "git" tool ...) but if you are new simply installing your Ubuntu system with ZFS might probably be the easiest approach as it doesn't require much else other than making sure that "Use ZFS" is selected during the installation.
Please be aware that ZFS will swallow the whole disk, it doesn't do well with other OS'es. If you intend to share the same SSD / the same harddrive with a different OS then ZFS is a no-go (that other OS would get destroyed during installation).
Bookmarks