Small knowledge, big challenge! This article is participating in the creation activity of “Essential Tips for Programmers”.
Linux commands are so numerous that they can be hard to find. So how do you find the order you want in “The Order of the Crowd”? Sometimes I can’t remember how a command is spelled. Fortunately, the Linux developers were prescient enough to come up with a solution, which is to use the Tab key to complete commands!
Tab key can not only complete command, can also complete file name, path name, absolutely let you double efficiency. For example, if I type the letters da and press Tab twice, it will show me all the possible completion options. We can see that there are only two possible options: dash and date. The diagram below:
At this point, if I continue typing, it becomes DAT. Press Tab twice more, and it will auto-complete to date for me. Because there’s only one possibility.
For example, if I use ls followed by a directory name, I can type the first letters of the directory name and then use Tab to complete it for me, which is extremely convenient when I have a long path name:
If you press Tab multiple times and no options are displayed, the command or path that starts with these letters does not exist.
Sometimes we have too many command candidates. So let’s test that out. If I type a character C and press Tab twice, the terminal will prompt me for all commands starting with the letter C, as shown below:
As shown above, type in C, press Tab twice, and the terminal asks me: Display all 113 possibilities? (y or n)
Show all 113 possible options? (Y (short for yes) for yes, n (short for no) for no) “, indicating that there are currently 113 commands starting with the letter C in Ubuntu.
We can type y, press Enter, and it literally shows us 113 commands. Not on one page, of course, but on many pages.
How do we navigate these pages?
- Space bar: Used to skip to the next page
- Enter key: Used to skip to the next line
- Q: Used to exit the list
Normally, we would type n, press enter and nothing would show up. After all, it’s a bit of a hassle to find one command out of 113.
The number of commands in your system varies from person to person, depending on how much software you have installed on your system. The more software you install, the more commands you can choose from.