Commands, flags and help
Every command you will type/learn will have the same structur:
command --flags arguments- The command is the program you’re running, like
ls. - Flags (also called options) change how the command works. They start with
-or--. - Arguments are the things it works on, They are usually files or folders.
Spaces separate these parts. This would be useful in coming chapters.
ls -l# -rw-r--r-- 1 obay obay 48213 Nov 9 10:12 cats_are_better_than_dogs.jpg# drwxr-xr-x 2 obay obay 4096 Nov 8 22:40 screenshots-l means “long format”, with permissions, owner, size and date. Short flags (one dash, one letter) can be stacked, so ls -l -a -h and ls -lah are the same thing. (-a shows hidden files, the ones starting with a dot, and -h prints sizes like 48K instead of 48213.)
Long flags use 2 dashes and a whole word, like ls --all. They’re easier to read, which will help your script be more readable!
Where do I find help?
Section titled “Where do I find help?”You might forget some flags, and that’s totally fine. Luckily, most of the commands has a help flag:
ls --help # a quick summary of what the command doesman ls # the full manual pageman opens a long page you can scroll with the arrow keys. Press / to search inside it and q to get out.
For short examples instead, install tldr. It shows a few common ways to use a command:
tldr tarIn fish, type a command followed by a dash (like ls -) and press Tab. Fish shows every flag with a short description.
For commands built into bash, like cd, use help cd instead of man cd. They’re part of bash itself, so they usually don’t have their own manual page.
What does this error mean?
Section titled “What does this error mean?”Error messages are short and tell you what went wrong:
cd Picturs# cd: The directory 'Picturs' does not existcd Picturs# bash: cd: Picturs: No such file or directoryHere, the folder name has a typo. When a command fails, read the error message first.