Which .service related this file?

qf2s() { rpm -ql $(rpm -qf $1)|grep -P "\.service"; }
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 ;)
Sample Output
$ qf2s /bin/rsync
/usr/lib/systemd/system/rsyncd.service

1
By: nnsense
2015-05-11 16:32:16

These Might Interest You

  • Use curl to invoke remote web service, where the file 'XML' is the soap payload


    -1
    curl -D - -X POST -H 'Content-type: text/xml' -d @XML http://remote_server:8080/web-service/soap/WSName
    igorfu · 2011-05-23 08:25:24 0
  • This command restarts mysql service.


    -4
    service mysqld restart
    denni · 2013-12-18 19:13:56 0
  • 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 Show Sample Output


    2
    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; }
    nnsense · 2015-05-11 16:46:01 3
  • Some shell newbies don't know this very handy file management related command so I decided to include it here. You need to have the "file" package installed. Show Sample Output


    -1
    file <filename>
    lordtoran · 2011-11-19 23:39:29 0

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: