Command to show all commands in linux

How to get a list of all the commands available for Ubuntu?

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?

7 Answers 7

First Method

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

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.

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  

Second Method

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

Third Method

Another method is a double Tab click.

Fourth Method

Another method using find command:

Notice that the first command works in bash but not in zsh , which has word split disabled by default. refining-linux.org/archives/38/…

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.

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.

@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 🙂

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

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

+1 for additional info. whatis `compgen -c` | sort > listOfCommands.txt will help go get in sort list.

Another useful command: apropos searches all commands and their short description and displays the results

Open up a terminal and press the Tab key twice.

@LorenzoAncora why is it not standard? Does not all Ubuntu have the autocompletion with double Tab as standard behaviour?

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.

Ok, thanks for the explanation 🙂 I thought that the standard behaviout of the double Tab on Ubuntu was to list the content of PATH 🙂

@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.

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:
ls /bin /sbin /usr/bin /usr/sbin /usr/local/bin /usr/local/sbin 

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.

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 .

This is a bit old, but can be still relevant

And information on using the Ubuntu terminal

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

Источник

Shell command to list all commands in linux

Solution 3: Open terminal Ctrl + Alt + t and run this command: This will list all commands and a simple description of each command. In order to use that just create a shell file with the command shown below − Now insert the code shown below − And then give permission to the script before running it − Output In order to print the aliases, we just need to replace the code inside the sample.sh file to the code shown below − Output Solution 1: The solution I chose was to run the command: which appends all runnable commands, functions and aliases to a text file Taken from: https://stackoverflow.com/questions/948008/linux-command-to-list-all-available-commands-and-aliases

Linux command to list all available commands and aliases

You can use the bash(1) built-in compgen

  • compgen -c will list all the commands you could run.
  • compgen -a will list all the aliases you could run.
  • compgen -b will list all the built-ins you could run.
  • compgen -k will list all the keywords you could run.
  • compgen -A function will list all the functions you could run.
  • compgen -A function -abck will list all the above in one go.

Check the man page for other completions you can generate.

To directly answer your question:

compgen -ac | grep searchstr 
function ListAllCommands < echo -n $PATH | xargs -d : -I <>find <> -maxdepth 1 \ -executable -type f -printf '%P\n' | sort -u > 

If you also want aliases, then:

function ListAllCommands < COMMANDS=`echo -n $PATH | xargs -d : -I <>find <> -maxdepth 1 \ -executable -type f -printf '%P\n'` ALIASES=`alias | cut -d '=' -f 1` echo "$COMMANDS"$'\n'"$ALIASES" | sort -u > 

command which lists all aliases and commands in $PATH where mycommand is used. Can be used to check if the command exists in several variants. Other than that. There's probably some script around that parses $PATH and all aliases, but don't know about any such script.

Unix / Linux - Useful Commands, Misc Commands ; 35. umask. Show the permissions that are given to view files by default ; 36. uname. Displays name of the current system ; 37. uptime. Gets the

How to view list of all commands in Linux Shell terminal

Force an External Mac Drive to Mount via Command Line Terminal Commands in Mac OS X
Duration: 1:24

Learn the 50 most popular Linux commands from Colt Steele. All these commands work on Duration: 5:00:17

30 BASIC COMMANDS IN LINUX / UNIX

LINUX TERMINAL (UBUNTU) IN WINDOWS 10 || HOW TO USE LINUX TERMINAL IN WINDOWS
Duration: 40:39

How to list down all the available commands and aliases on Linux?

Linux provides us with a huge amount of commands along with their aliases that we can make use of. Although these commands serve different purposes we can still make use of all these commands anywhere we like in the terminal.

There are different ways with which we can interact with Linux commands. When it comes to listing all the available commands to the terminal we also have different approaches, either we can write a shell script by ourselves or we can use a shell library function that does that for us.

Let’s consider the first approaches where I'll make use of a shell library keyword named compgen , which is a bash builtin command that can be used to list all the available commands.

Syntax

In the above syntax, the flag is a placeholder that can be replaced according to our needs.

The flag can have all these different values −

  • -c − used to list all the commands you could run.
  • -a − used to list all the aliases you could run.
  • -k − used to list all the keywords you could run.
  • -b − used to list all the built-ins you could run.
  • -A function − used to list all the functions you could run
  • -A function -abck − used to list everything shown above in one go.

Since, we only need to list the commands and their aliases we will make use of the -c and -a flags only.

In order to use that just create a shell file with the command shown below −

Now insert the code shown below −

And then give permission to the script before running it −

chmod 777 sample.sh ./sample.sh

Output

immukul@192 Downloads % ./sample.sh if then else elif fi case esac for select while until do done in . . .

In order to print the aliases, we just need to replace the code inside the sample.sh file to the code shown below −

Output

101 Bash Commands and Tips for Beginners to Experts, [ andrew@pc01 ~ ]$ myvar="hello, world!" && echo $myvar hello, world! Env vars can also be defined using the export command. When

How to generate list of *all* available commands and functions?

The solution I chose was to run the command:

$ compgen -A function -abck | sort -u >> cmds.txt 

which appends all runnable commands, functions and aliases to a text file cmds.txt

Taken from: https://stackoverflow.com/questions/948008/linux-command-to-list-all-available-commands-and-aliases

Edit: added sort -u to command to remove duplicates as suggested by glenn jackman

It seems compgen outputs duplicates: perhaps programs that appear in multiple locations in your PATH:

$ [tab][tab] Display all 2328 possibilities? (y or n) 
$ compgen -A function -abck | wc -l 2647 $ compgen -A function -abck | sort -u | wc -l 2328 

I don't know if this is important for you.

Read the Source Code of Shell Commands, The which command prints the full path of the shell commands, helping us to find out where it is on our file system. It searches through the

How to get a list of all the commands available for Ubuntu?

First Method

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

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.

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 

Second Method

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

Third Method

Another method is a double Tab click.

Fourth Method

Another method using find command:

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.

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

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

Getting Started with Linux Shell Commands, As part of this video, you will get started with Linux Shell Commands by running the first Duration: 29:53

Источник

Читайте также:  Информация о юзере линукс
Оцените статью
Adblock
detector