Home > Default > Find unowned files via command line?

Find unowned files via command line?

October 11Hits:0
Advertisement
I'm interested in making a list of files not owned by any package and sending it to a text file I can review. I found this thread, which suggests pacpal (link appears to be broken now) and this script. I could try the script, but I noted from a bit back that the Arch news page listed a one-liner for finding unowned packages in the preparation of moving /usr/lib -> /lib:
$ find /bin /sbin /usr/sbin -exec pacman -Qo -- {} + >/dev/null
Here's the script linked to above, for reference:
#!/bin/bash
# Utility to generate a list of all files that are not part of a package
# Author: Spider.007 / Sjon
TMPDIR=`mktemp -d`
FILTER=$(sed '1,/^## FILTER/d' $0 | tr '\n' '|')
FILTER=${FILTER%|}
cd $TMPDIR
find /bin /boot /etc /lib /opt /sbin /usr /var | sort -u > full
pacman -Ql | tee owned_full | cut -d' ' -f2- | sed 's/\/$//' | sort -u > owned
grep -Ev "^($FILTER)" owned > owned- && mv owned- owned
echo -e '\033[1mOwned, but not found:\033[0m'
comm -13 full owned | while read entry
do
echo [`grep --max-count=1 $entry owned_full|cut -d' ' -f1`] $entry
done | sort
grep -Ev "^($FILTER)" full > full- && mv full- full
echo -e '\n\033[1mFound, but not owned:\033[0m'
comm -23 full owned
rm $TMPDIR/{full,owned,owned_full} && rmdir $TMPDIR
exit $?
## FILTERED FILES / PATHS ##
/boot/grub
/dev
/etc/X11/xdm/authdir
/home
/media
/mnt
/proc
/root
/srv
/sys
/tmp
/var/abs
/var/cache
/var/games
/var/log
/var/lib/pacman
/var/lib/mysql
/var/run
/var/tmp
Is there any reason to use a script like the above compared to such a simple script, which appears to just be spitting a list of all files in /bin, /urs/sbin, and /sbin into `pacman -Qo`. What I can't figure out is what the end of the command does (the `-- {} + > /dev/null`). From various attempts to pipe that output into a text file, I've noticed that it just gets filled with the owned files... so I'm guessing something in there is filtering so that unowned get printed to stdout and owned go to /dev/null. I can't figure out how to redirect the unowned to a text file.
Thanks for any suggestions.

Answers

alphaniner wrote:"--" is often used to tell the program there are no more options. I didn't see it in the manpage, but that's the case with pacman as well.* The "{} +" is part of the find -exec argument, search for {} in the find manpage.
Ah. Thanks for that. I'd been googling things like " linux command line '-- {}'" and not getting any hits. I combined the arguments incorrectly! Thanks for letting me know that this was part of `find`, as I was also looking in the man page for pacman wrongly.
alphaniner wrote:
The >/dev/null is redirecting stdout (list of owned files) to oblivion. The list of unowned files (and other errors) goes to stderr. To redirect stderr you use "2>" so try
find /bin /sbin /usr/sbin -exec pacman -Qo -- {} + >/dev/null 2>unowned_files
Perfect, and now I understand how `pacman -Qo` is working: it sends the answer to stdout if it knows the answer and to stderr if it doesn't find a hit. Thanks!

Read other 6 answers

Tags:

Related Articles

  • Find unowned files via command line?October 11

    I'm interested in making a list of files not owned by any package and sending it to a text file I can review. I found this thread, which suggests pacpal (link appears to be broken now) and this script. I could try the script, but I noted from a bit b

  • Adobe Reader 11 (XI) won't open file via command lineOctober 11

    Hello, I have posted this question to probably inapropriate topic earlier today, so I am repeating it again. I installed newest Adobe Reader XI today and when I tried to open certain pdf file via command line, it reported a syntax error. Now, this sy

  • How to specify xml file to populate form fields in the PDF file via command line?October 11

    Hi, I would like to specify xml data file to populate my pdf file using command line. The form was Reader extended. I've tried the following syntax : Acrobat.exe /A "zoom=100" "C:\example.pdf"#xml="C:\example.xml" but got an

  • How To Run An External .exe File With Command Line ArgumentsOctober 11

    Hiya, could anyone tell me how I can run an external .exe file with command line arguments in Java, and if possible catch any printouts the external .exe file prints to the command line. Thanks.Using the Runtime.exec() command. And read this: http://

  • HT3924 Target display mode connects but only displays desktop background, no files or command linesOctober 11

    I have connected my early 2014 MacBook to a late 2012 imac and connected them via Thunderbolt cable.  Pressing Command F2 causes the screen on teh iMac to change to teh MacBook background screen, but does not display any desktop files or command line

  • Undeploy an sda file through command-lineNovember 30

    Hi All,       I want to undeploy an .sda file through command-line,what is the procedure to undeploy an sda file through command-line and send me the procedure for this Thanks & Regards, guruHi Please find below the steps to undeploy thro command lin

  • How to undeploy an .sda file through command lineNovember 30

    Hi, How to undeploy an .sda file through command line.send me the related command to do it.and related information and links.Hi Please find below the steps to undeploy thro command line : Shut down the sdm server 1)SDM shutdown "sdmhome=D:\usr\sap\J2

  • Compiling FLA and AS files to SWF file using command lineNovember 30

    I need to encorporate the .as sources and .fla file, into my build environment, to compile the SWF file. Right I have to Open Flash 8 to perform this and copy the SWF created through the compilation process. Compiling FLA and AS files to SWF file usi

  • In making .ard file what command line argumentNovember 30

    In making .ard file what command line argument  must be keptTaken form SAP Business One Development Environment Project. .bat file: "SAPAddOnRegDataGenFileFolder\AddOnRegDataGen.exe" "YourAddOnInstallXMLFolder\YourAddOnInstall.xml" &qu

  • Run PDF File from command line and goto a bookmarkNovember 30

    Hi, I need to open a pdf file vi command line (WinXP / Win7). Till this I do not have a problem. But I need to go to a bookmark in the file direct after opening the file. I tried "acrord23.exe /a nameddest=BOOKMARK file.pdf" but this opened only

Copyright (C) 2019 wisumpire.com, All Rights Reserved. webmaster#wisumpire.com 14 q. 0.505 s.