Dnf - switch from aptitude

I switch from debian to fedora and althogh reading wikis and mans etc. I get caught on dnf where I do not find answers…

When I use e.g. ‘dnf se nextcloud’ there is a lot of output - but I can’t see whether the package is installed or not (like aptitude search nextcloud would tell me). Is there a switch for it?
And for selection package I used something like ‘aptitude search nextcloud|grep ^i’ in the past for (only) seeing, what packages including ‘nextcloud’ are installed. How would this possible with dnf?
Is it possible to shorten the list of ‘dnf se’ only for the excatly matches (or the other possibilities)?

Thanking you in anticipation!

bengoshi

3 Likes

To query if a RPM package is installed or not, we can use rpm -qa | grep pkgname

https://fedoranews.org/alex/tutorial/rpm/3.shtml

5 Likes

Great, this helped a lot!
Thank you!

bengoshi

3 Likes

You don’t actually need to use grep there, try:

rpm -qa \*<string>\*

For example:

rpm -qa \*python\*

Of course, the man pages are your best source of information:

man dnf
man rpm
5 Likes

Man pages are a very good source, but honestly I almost always look for a nice example and just after I check what all the parameters are for. So here my hints:

hint rpm
rpm

# To install a package:
rpm -ivh <rpm>

# To remove a package:
rpm -e <package>

# To find what package installs a file:
rpm -qf </path/to/file>

# To find what files are installed by a package:
rpm -ql <package>
rpm -qpl <rpm>

# To find what packages require a package or file:
rpm -q --whatrequires <package>
rpm -q --whatrequires <file>

# To list all installed packages:
rpm -qa
3 Likes

hint does not seem to be a command in the Fedora repos, though. Where can one find this package? (dnf whatprovides '/usr/bin/hint' doesn’t return anything here on F34)

There’s really no shortage of docs on the web etc. about most commands. The man pages just tend to be the authoritative source of information (along with info docs).

2 Likes

It is not … no … but as I said examples bring me faster to the point as trail and fail with man pages. They are very well as you said no doubts.
About hint this is a script i found while learning bash. It was named cheat as cheat-sheet. I believe that I not cheat while looking up in my or others notes. So for learning bash and to see how the scripts work i made my own version based on an existing script.

Probably I need to develop the attitude to request adding more examples in the man and info pages.

3 Likes

For this, use dnf list nextcloud instead of dnf search nextcloud.

5 Likes

And dnf list "*nextcloud*" will list packages which include the given string (in this case, nextcloud) in their name and whether they are installed or not.

7 Likes

For online man pages, I’ve been finding https://www.mankier.com very useful.

  • It integrates examples from tldr.sh.
  • Command options are hyperlinked
  • It generates man pages from Fedora rawhide; this makes it a good choice for Fedora derived distributions. It has a github repo for holding extra man pages beyond what is in Fedora rawhide.
  • After you integrate it as a search engine for Firefox, you can type man rpm in the Firefox location and it will take you directly to the rpm man page.
  • See the about page for an explanation of how to use s for searching within a page.
4 Likes