Difference between revisions of "Lostfiles"

From ArchWiki
Jump to: navigation, search
(ignore /etc/pacman.d and /etc/sensors.d)
(pulled source into a github repo)
Line 2: Line 2:
 
'''Lostfiles''' is a script for detecting orphaned files (files which are not owned by any Arch Linux packages).
 
'''Lostfiles''' is a script for detecting orphaned files (files which are not owned by any Arch Linux packages).
  
The script ignores by default a series of directories where packages should not install files. Some files might appear as removed if they're placed in those directories which are not checked.
+
An AUR package has been created for easy and convenience: {{AUR|lostfiles}}
  
== Script source ==
+
The script generates a list of all files owned by installed packages and compares that against all files on the root filesystem showing the user the difference, i.e. files on the filesystem that are not owned by a package.  Users can inspect the output and choose to leave any orphans alone or to backup and delete them.
{{hc|/usr/local/bin/lostfiles|<nowiki>
+
#!/bin/bash
+
  
# License: GPL v2.0 http://www.gnu.org/licenses/gpl.html
+
On 26-Oct-2013, [[User:Graysky]] assumed the duty of maintainer for the script, hosting it in [[https://github.com/graysky2/lostfiles this public github repo]]; any user wishing to modify the code is encouraged to submit a pull request.
 
+
# Initially scripted by the Arch Linux Community
+
# Mircea Bardac (dev AT mircea.bardac.net)
+
# http://mircea.bardac.net/
+
# Modified by Jan Janssen
+
 
+
# Description:
+
# Search for files which are not part of installed Arch Linux packages
+
 
+
# Usage:
+
lostfiles
+
 
+
if [ $UID != "0" ]; then
+
  echo "You must run this script as root." 1>&2
+
  exit 1
+
fi
+
 
+
comm -13 \
+
  <(pacman -Qlq | sed -e 's|/$||' | sort -u) \
+
  <(find / -not \( \
+
  -wholename '/boot/grub' -prune -o \
+
  -wholename '/dev' -prune -o \
+
  -wholename '/etc/conf.d' -prune -o \
+
  -wholename '/etc/pacman.d' -prune -o \
+
  -wholename '/etc/sensors.d' -prune -o \
+
  -wholename '/etc/ssh' -prune -o \
+
  -wholename '/etc/ssl' -prune -o \
+
  -wholename '/etc/systemd/system' -prune -o \
+
  -wholename '/home' -prune -o \
+
  -wholename '/lost+found' -prune -o \
+
  -wholename '/media' -prune -o \
+
  -wholename '/mnt' -prune -o \
+
  -wholename '/proc' -prune -o \
+
  -wholename '/root' -prune -o \
+
  -wholename '/run' -prune -o \
+
  -wholename '/scratch' -prune -o \
+
  -wholename '/sys' -prune -o \
+
  -wholename '/srv/http' -prune -o \
+
  -wholename '/tmp' -prune -o \
+
  -wholename '/usr/lib/virtualbox/ExtensionPacks/Oracle_VM_VirtualBox_Extension_Pack' -prune -o \
+
  -wholename '/usr/local/bin' -prune -o \
+
  -wholename '/usr/share/mime/application' -prune -o \
+
  -wholename '/usr/share/mime/audio' -prune -o \
+
  -wholename '/usr/share/mime/image' -prune -o \
+
  -wholename '/usr/share/mime/inode' -prune -o \
+
  -wholename '/usr/share/mime/interface' -prune -o \
+
  -wholename '/usr/share/mime/message' -prune -o \
+
  -wholename '/usr/share/mime/multipart' -prune -o \
+
  -wholename '/usr/share/mime/text' -prune -o \
+
  -wholename '/usr/share/mime/uri' -prune -o \
+
  -wholename '/usr/share/mime/video' -prune -o \
+
  -wholename '/usr/share/mime/x-content' -prune -o \
+
  -wholename '/var/abs' -prune -o \
+
  -wholename '/var/cache' -prune -o \
+
  -wholename '/var/lock' -prune -o \
+
  -wholename '/var/log' -prune -o \
+
  -wholename '/var/lib/mysql' -prune -o \
+
  -wholename '/var/lib/pacman' -prune -o \
+
  -wholename '/var/run' -prune -o \
+
  -wholename '/var/spool' -prune -o \
+
  -wholename '/var/tmp' -prune \) | sort -u \
+
  ) | sed -e 's|^\t||;' | less
+
 
+
# vim:set ts=2 sw=2 et:
+
</nowiki>}}
+

Revision as of 15:28, 26 October 2013

Lostfiles is a script for detecting orphaned files (files which are not owned by any Arch Linux packages).

An AUR package has been created for easy and convenience: lostfilesAUR

The script generates a list of all files owned by installed packages and compares that against all files on the root filesystem showing the user the difference, i.e. files on the filesystem that are not owned by a package. Users can inspect the output and choose to leave any orphans alone or to backup and delete them.

On 26-Oct-2013, User:Graysky assumed the duty of maintainer for the script, hosting it in [this public github repo]; any user wishing to modify the code is encouraged to submit a pull request.