This article is part of a 37 articles-long series extracted from the course: Mastering the Unix Command-Line with Bash available on Skillshare.
The first thing you should see appearing when opening a new terminal window is a bunch of random characters, usually terminated by a percentage or a dollar sign.
This character sequence is called a command prompt, and it is here to indicate you that the shell is ready to accept commands as it literally prompts you to take action.
Beside being a shell readiness indicator, the prompt can also be customized to include colours, special characters and other elements to make it more informative or just visually pleasing.
We can for example change the prompt to include our username, the name of our computer or the current working directory.
Next comes the command itself.
In general, a command is composed of the three following elements separated by one or more space characters: a name, a list of options also called flags and a list of arguments.
The name, which always comes first, is indeed the name of the program we want to run.
The options, are parameters used to influence the program’s behaviour and are quite easy to recognize as they are always preceded by a dash or a double dash.
Finally, the arguments, are values the program will use as an input, like a number, a file name or text string for example.
Let’s illustrate this by running a basic command called: echo
, which takes a list of strings as arguments and prints them back into the terminal window.
Running echo
on its own for example, will simply print an empty newline as indeed we didn't specify any arguments to print.
Running echo
with a few arguments this time, will result in displaying each argument separated by a space character followed by a newline.
And finally, running echo
with the -n
option and the same arguments, will also result in displaying each argument separated by a space character but this time without being followed by a new line — as you can see, the prompt appeared right after the output of the command.
One thing you should keep in mind as of now tho, is to always place the options before the arguments, as most commands won’t understand what you are trying to do if you were to switch them.
For example, placing the -n
option after the arguments list when using echo
will result in the -n
being treated as string of characters and not an actual option.
👨🏫 Don’t want to wait for the next part? Get the FULL course now on Skillshare + 30 FREE days with this link: https://www.skillshare.com/r/profile/Razvan-Ludosanu/961339862?gr_tch_ref=on
Don’t forget to 👏🏻 if you enjoy reading my work and you can also buy me a cup of steaming hot ☕!