Listing package man page, services, config files and related rpm of a file, in one alias

fileinfo() { RPMQF=$(rpm -qf $1); RPMQL=$(rpm -ql $RPMQF);echo "man page:";whatis $(basename $1); echo "Services:"; echo -e "$RPMQL\n"|grep -P "\.service";echo "Config files:";rpm -qc $RPMQF;echo "Provided by:" $RPMQF; }
Many times I give the same commands in loop to find informations about a file. I use this as an alias to summarize that informations in a single command. Now with variables! :D
Sample Output
$ fileinfo /var/log/sssd
man page:
sssd (8)             - System Security Services Daemon
Services:
/etc/systemd/system/sssd.service.d
/etc/systemd/system/sssd.service.d/journal.conf
/usr/lib/systemd/system/sssd.service
Config files:
/etc/logrotate.d/sssd
/etc/rwtab.d/sssd
/etc/sssd/sssd.conf
/etc/systemd/system/sssd.service.d/journal.conf
log files:
/var/log/sssd
Provided by: sssd-common-1.12.2-58.el7_1.6.x86_64

These Might Interest You

  • I use this as an alias to get all .service files related a single installed file/conf (if it has services, of course). For rpm based systems ;) Show Sample Output


    1
    qf2s() { rpm -ql $(rpm -qf $1)|grep -P "\.service"; }
    nnsense · 2015-05-11 16:32:16 0
  • some configuration files, particularly those installed by default as part of a package, have tons of comment lines, to help you know what's possible to configure, and what it means. That's nice, but sometimes you just want to see what specifically what _has_ been configured. That's when I use the above snippet, which I save as a bash alias 'nocom' (for 'no comments'). Apache default config files are perfect examples of when/why this script is handy.


    1
    grep -vE '^$|^[\s]*[;#]'
    dirtman0504 · 2012-01-06 20:53:03 0

  • 0
    debconf-copydb configdb copydb --pattern=<PACKAGE> --config="Name: copydb" --config="Driver: File" --config="Filename: ~/copydebconf.dat"
    ohe · 2011-08-29 14:00:42 0
  • Tells you everything you could ever want to know about all files and subdirectories. Great for package creators. Totally secure too. On my Slackware box, this gets set upon login: LS_OPTIONS='-F -b -T 0 --color=auto' and alias ls='/bin/ls $LS_OPTIONS' which works great. Show Sample Output


    2
    lsr() { find "${@:-.}" -print0 |sort -z |xargs -0 ls $LS_OPTIONS -dla; }
    h3xx · 2011-08-15 03:10:58 0

What Others Think

OK the information might be useful, but the command? Urgh! You run "rpm -qf" four times and then "rpm -ql" twice. Step 1: Have a think about caching your results Step 2: Edit command to be more 'fu' Step 3: Profit ;-)
flatcap · 158 weeks and 6 days ago
Challenging:) I slightly modified it. To make it really "fu" I should came with something extraordinary.. will think about, should be something! :)
nnsense · 158 weeks and 5 days ago
That's brilliant! Much more efficient :-)
flatcap · 158 weeks and 5 days ago

What do you think?

Any thoughts on this command? Does it work on your machine? Can you do the same thing with only 14 characters?

You must be signed in to comment.

What's this?

commandlinefu.com is the place to record those command-line gems that you return to again and again. That way others can gain from your CLI wisdom and you from theirs too. All commands can be commented on, discussed and voted up or down.

Share Your Commands



Stay in the loop…

Follow the Tweets.

Every new command is wrapped in a tweet and posted to Twitter. Following the stream is a great way of staying abreast of the latest commands. For the more discerning, there are Twitter accounts for commands that get a minimum of 3 and 10 votes - that way only the great commands get tweeted.

» http://twitter.com/commandlinefu
» http://twitter.com/commandlinefu3
» http://twitter.com/commandlinefu10

Subscribe to the feeds.

Use your favourite RSS aggregator to stay in touch with the latest commands. There are feeds mirroring the 3 Twitter streams as well as for virtually every other subset (users, tags, functions,…):

Subscribe to the feed for: