Path completion
The tab key can help you in typing a path without errors. Typing cd /et followed by the tab key will expand the command line to cd /etc/. When typing cd /Et followed by the tab key, nothing will happen because you typed the wrong path (upper case E).
You will need fewer key strokes when using the tab key, and you will be sure your typed path is correct!
- ls
You can list the contents of a directory with ls.
2. ls -a
A frequently used option with ls is -a to show all files. Showing all files means including the hidden files. When a file name on a Linux file system starts with a dot, it is considered a hidden file and it doesn’t show up in regular file listings.
3. ls -l
Many times you will be using options with ls to display the contents of the directory in different formats or to display different parts of the directory. Typing just ls gives you a list of files in the directory. Typing ls -l (that is a letter L, not the number 1) gives you a long listing.
4. ls -lh
Another frequently used ls option is -h. It shows the numbers (file sizes) in a more human readable format. Also shown below is some variation in the way you can give the options to ls. We will explain the details of the output later in this book.
Note that we use the letter L as an option in this screenshot, not the number 1.
5. mkdir
Walking around the Unix file tree is fun, but it is even more fun to create your own directories with mkdir. You have to give at least one parameter to mkdir, the name of the new directory to be created. Think before you type a leading / .
6. mkdir -p
The following command will fail, because the parent directory of mydir11 does not exist.
When given the option -p, then mkdir will create parent directories as needed.
7. rmdir
When a directory is empty, you can use rmdir to remove the directory.
8. rmdir -p
And similar to the mkdir -p option, you can also use rmdir to recursively remove directories.