27

I want to start using the terminal more often, but I don't know what are the different commands available to me. Is there a way to list all the different commands that I can make use of?

0

7 Answers 7

30

First Method

NB: Thanks to @Rmano. This method doesn't work with zsh shell.

A simple command:

ls ${PATH//:/ }

This will list all commands in your $PATH environment variable.

To store the result in a file you can redirect the output to a file.

ls ${PATH//:/ } > mycommands.txt

Note that this will return an error if any directory names in your $PATH contain spaces. In that case, use this instead:

while read -d ':' dir; do echo "$dir"; done <<<$PATH

Second Method

Also you can use:

compgen -c | sort -u > commands && less commands

Third Method

Another method is a double Tab click.

Fourth Method

Another method using find command:

find {,/usr}/{,s}bin -printf '%f\n\0'
1
12

If you are using bash, which is the default shell in all official Ubuntu flavors, run compgen -c to see the available commands including aliases.

11
  • Is that bash only?
    – Braiam
    Jan 10, 2014 at 13:52
  • 1
    Even the commands for gui-based programs are included. So if you do compgen -c | grep thunar and you have the Thunar file manager installed, you'll see commands related to Thunar as well.
    – user25656
    Jan 10, 2014 at 14:00
  • 1
    Mmm... is doesn't work in Debian. Which package provides that?
    – Braiam
    Jan 10, 2014 at 14:03
  • 2
    @Rinzwind that explains it, I'm using zsh.
    – Braiam
    Jan 10, 2014 at 14:10
  • 1
    @vasa1: Could this answer be more general? I mean it only provides the solution for bash, but as Braiam noted it doesn't work for zsh... If possible could you please expand the answer to cater to a larger audience - obviously only if you know the answer :-)
    – Aditya
    Jan 29, 2014 at 10:37
4

Open terminal Ctrl + Alt + t and run this command:

whatis `compgen -c` | more 

This will list all commands and a simple description of each command.

If you want to save the list you can redirect the result into an output file

whatis `compgen -c` > listOfCommands.txt

So why I used whatis command. The command man whatis gives:

Each manual page has a short description available within it.
whatis searches the manual page names and displays the manual page descrip‐ tions of any name matched.

so in easy words whatis give a general. description of each command

2
  • +1 for additional info. whatis `compgen -c` | sort > listOfCommands.txt will help go get in sort list. Mar 25, 2014 at 7:44
  • Another useful command: apropos <keyword> searches all commands and their short description and displays the results
    – Aloso
    Dec 19, 2017 at 16:17
3

Open up a terminal and press the Tab key twice.

6
  • 2
    -1 because this is not standard. Mar 10, 2014 at 14:25
  • @LorenzoAncora why is it not standard? Does not all Ubuntu have the autocompletion with double Tab as standard behaviour?
    – dadexix86
    Mar 10, 2014 at 15:29
  • 3
    Default != standard: in a future maybe we'll have a console that does not support that mechanism, because it's not standard; more, the TAB standard may serve a different function. A standard procedure is listing the content of 'bin', because is part of the official FHS standard and any Linux/Unix system has that directory. The correct functionality (and the ability of the community to help the users) of Ubuntu is ensured by the respect of the standards. Mar 10, 2014 at 16:13
  • Ok, thanks for the explanation :) I thought that the standard behaviout of the double Tab on Ubuntu was to list the content of PATH :)
    – dadexix86
    Mar 10, 2014 at 16:22
  • @LorenzoAncora Listing the contents of any one directory will not show anywhere close to all executable commands. Listing the contents of all PATH directories will not show shell builtins with no corresponding executable (such as cd). Pressing Tab twice overcomes both these severe limitations. If someone had asked how to show all commands on an arbitrary GNU/Linux system, one might argue that Tab completion is not an adequate solution. Of course anything might change in Ubuntu in the future but the likelihood of tab completion in the default interactive shell going away is minuscule. Mar 10, 2014 at 17:30
2

A list of command depends greatly on what you have installed, but there are cheats to list all commands. The following works on most bourne-like shells:

  1. Press Tab twice.
  2. Use find to find all executables:

    find / -perm +x
    
  3. List all the files in the binaries directories (could be incomplete):

    ls /bin /sbin /usr/bin /usr/sbin /usr/local/bin /usr/local/sbin
    
1

Open a terminal window (GNOME terminal is OK, also a configured xTerm).
Your options are:

  • By pressing the TAB key ("-><-") twice, you'll complete any command in the console and, if the line is empty, you'll get the number and the names of all available commands. Please note that it may require some time and may list semi-administrative utilities. NOTE: this isn't a standard, for a "cross-shell" way see the other options.

  • Use man -k NAME to search for a command (or part of it) and man COMMAND to obtain the manual for that command. Not al commands have a system manual; reading the man before using any administrative utility is always a good idea; trust me.

  • Use Midnight Commander (mc) to have a nice console (curses) GUI to manage the system and the file system. You may have to install it from your package manager. Don't worry; it is safe and extremely common software.
    NOTE: It's made for when you have confusion or difficulty in using the file system.

  • Use ls /bin | more to know all exential administrative executables; ls /sbin | more for common administrative executables.

  • Use ls /usr/sbin | more to know all user executables; ls /usr/sbin | more will give a very huge list of user executables and libraries.
    NOTE: If the output from more exceeds one page (screenful), you'll have to scroll py pressing "Page Up" and "Page Down" or spacebar.
    You can use COMMAND | grep TEXT to filter the output.

If you have more questions comment under here and don't forget to check the tick next to the answer if I helped you.
Have a nice experience.

1
  • Usually, most executables are in /usr/bin, which you haven't mentioned here. Also there's /sbin, which contains executables often used for system administration, such as usermod and ifconfig. And many systems have other binary directories as well, like /usr/games and /usr/local/bin. See Filesystem hierarchy standard and man 7 hier. You might want to expand this to mention important directories for executables besides /bin and /usr/sbin. Mar 10, 2014 at 17:27
-1

This is a bit old, but can be still relevant

http://fosswire.com/post/2008/04/ubuntu-cheat-sheet/

And information on using the Ubuntu terminal

https://help.ubuntu.com/community/UsingTheTerminal

the above page has more links at the end which will help you finding more commands for Ubuntu.

0

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .