3 ms·
So as someone who's not very good at UNIX, knows that it has signals, subshell, what ls is, don't know of, know there's a manual and has invoked man many times
by magicalhippo 4y ago
So as someone who's not very good at UNIX, knows that it has signals, subshell, what ls is, don't know of, know there's a manual and has invoked man many times and is interested in finding out...
How would I use man to find that lsof exists so that I could come up with the incantation mentioned in OP? I tried "man -k 'open'" but none of the answers returns lsof on my system. I checked that "man lsof" works as expected.
- pxc 4y agoman -k open should surface lsof on your system. On mine it only has the description 'open files', though, which might not be obviously relevant to many people. I'm not sure what macOS or FreeBSD `man` have, but GNU `man` has `-K` as well as `-k`. The uppercase version searches the manpages globally, instead of just their short descriptions. So something like man -K -a 8 "list open" port will turn up `lsof` on GNU, even if `apropos` doesn't. If you have a tldr client installed, that can also be useful for searching through common examples including for programs you may not have installed. For example with tealdeer, the following (Fish) surfaces both lsof and netstat as options: for page in (tldr -l) tldr $page | rg -A2 -i '\b(find|list)\b.*\bport' end and for page in (tldr -l) tldr $page | rg -A2 -i '\bkill\b.*\bport' end shows that fuser and fkill can both do the same thing as killport. Grep sucks as a search interface for tldr, though, so you probably want a better tldr client than I have, which will do global search, or an FZF script that will let you filter through tldr results. Discovering new (to you) tools which are not yet installed is a good reason to use the web to look up Unix stuff, especially after you've checked the manpages and your package manager.
- magicalhippo 4y agoThanks for the detailed response. Seems -K is not available on the UNIX I have (TrueNAS, FreeBSD-based). That should indeed have helped. > Discovering new (to you) tools which are not yet installed is a good reason to use the web to look up Unix stuff Of course a web search can help, however I often find that the times when I need to do such searches is quite correlated with times when I don't have internet access. Less frequent now with my "smart" phone, but still happens.