Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

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?

share|improve this question

7 Answers 7

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'
share|improve this answer
    
Notice that the first command works in bash but not in zsh, which has word split disabled by default. refining-linux.org/archives/38/… –  Rmano Mar 10 at 22:54

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

share|improve this answer
    
+1 for additional info. whatis `compgen -c` | sort > listOfCommands.txt will help go get in sort list. –  Saurav Kumar Mar 25 at 7:44

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.

share|improve this answer
    
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. –  Eliah Kagan Mar 10 at 17:27
    
Post edited. Thank you. –  Lorenzo Ancora Mar 10 at 20:46

Open up a terminal and press the Tab key twice.

share|improve this answer
    
+1 for an easy and smart way! :) –  i08in Mar 10 at 13:24
1  
-1 because this is not standard. –  Lorenzo Ancora Mar 10 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 at 15:29
2  
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. –  Lorenzo Ancora Mar 10 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 at 16:22

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.

share|improve this answer
    
Is that bash only? –  Braiam Jan 10 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 at 14:00
1  
Mmm... is doesn't work in Debian. Which package provides that? –  Braiam Jan 10 at 14:03
2  
@Rinzwind that explains it, I'm using zsh. –  Braiam Jan 10 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 at 10:37

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
    
share|improve this answer

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.

share|improve this answer
    
thanks for this. –  user233219 Jan 11 at 1:21

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.