Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

4
  • 2
    You have to know where the command is. On some systems, the division between /bin and /usr/bin is arbitrary. Commented May 25, 2012 at 20:50
  • @KeithThompson For that, you could use which for some commands: which ls. Commented Apr 19, 2016 at 11:44
  • @cst1992: If you're going to use which (or type), it does a lookup via $PATH; you might as well just use ls or \ls rather than specifying the path. Commented Apr 19, 2016 at 15:10
  • @cst1992 I know the OP is about Bash, but on zsh, both which and command -v or its human-readable command -V return the alias versions. Using \ls just works, but to get its real path I can only seem to think of echo "$PATH" | tr ':' '\n' | xargs -I{} find {} -maxdepth 1 -name 'ls' -type f 2>/dev/null | head -n1... which works. Commented Feb 27, 2022 at 1:36