Terminal Takeaway πŸ₯‘

This brought tears to my eyes.

1 Like

A fantastic post and a must-read or -have for any Debian admin and user.

2 Likes

That reminds me of the plethora of options to search through Debian packages. To make it swift. I will just copy the commands from the Ubuntu documentation* as the Debian handbook that I have here still talks about aptitude that I do not use personally.

Search commands

apt-cache search <search_term>

Each package has a name and a description. This command lists packages whose name or description contains <search_term>.

dpkg -l *<search_term>

This will find packages whose names contain <search_term>. Similar to apt-cache search, but also shows whether a package is installed on your system by marking it with ii (installed) and un (not installed).

apt-cache show <package_name>

This command shows the description of package <package_name> and other relevant information including version, size, dependencies and conflicts.

dpkg --print-avail <package_name>

This command is similar to β€œapt-cache show”.

dpkg -L <package_name>

This command will list files in package <package_name>.

dpkg -c foo.deb

This command lists files in the package β€œfoo.deb”. Note that foo.deb is a pathname. Use this command on .deb packages that you have manually downloaded.

dlocate <package_name>

This command determines which installed package owns <package_name>. It shows files from installed packages that match <package_name>, with the name of the package they came from. Consider this to be a β€œreverse lookup” utility.

dpkg -S <filename_search_pattern>

This command does the same as dlocate, but does not require the installation of any additional packages. It is slower than dlocate but has the advantage of being installed by default on all Debian and Ubuntu systems.

apt-file search <filename_search_pattern>

This command acts like dlocate and dpkg -S, but searches all available packages. It answers the question, β€œwhat package provides this file?”.

apt-cache pkgnames

This command provides a listing of every package in the system

  • A general note on searching: If searching generates a list that is too long, you can filter your results by piping them through the command grep. Examples:

apt-cache search <filename> | grep -w <filename>

will show only the files that contain as a whole word

dpkg -L package | grep /usr/bin

will list files located in the directory /usr/bin, useful if you’re looking for a particular executable.

For more info on the usage of apt just type:

man apt

*Reference

Edit: Now you can also use the abbreviated

apt search instead of apt-cache search

3 Likes

I am not sure where to post this as it is a comprehensive guide of all apt/apt-get commands but I will just stay within the last posts here regarding apt’s usage.

I knew that Linux Mint has a ton of extra apt commands but I did not know how much actually, interesting.

2 Likes

Well, I have given some thought to this phenomenon over the last 2 years and have a couple of other solutions – though none as elegant as the double tack to indicate the end of arguments.

Create the problem:

# create an empty file with a troubling name
> --help

1) Remove the problem file by specifying the path (absolute or relative) in front of the file:

# using an absolute path
rm /home/user/path/to/--help

or simply:

# using a relative path
rm ./--help

2) Remove the file by deleting it via its inode number. First display the inode number:

ls -ltri
39482924 -rw-rw-r-- 1 mark mark      0 Aug 28 22:04 --help

Then pass the inode number to the find command with a delete action:

find -inum 39482924 -delete

@Ulfnic, thanks for giving me something to think about for the last 2 years!

1 Like

Deleting it via inode lol, brilliant never knew you could do that.