Let's go ahead and discuss the structure of the Linux commands. To give a comment to a Linux system, 1
you type in a shell,the command’s name, its options and arguments, if required. 2
Let's get started with an example. 3
I’m opening a terminal and the default shell, which is bash,was started. 4
And I’m running: ping -c 1 8.8.8.8 5
As you probably already know, the ping command, which is available on Windows and Mac as well, is 6
used to test the network connectivity to a destination host. 7
For the moment, please don't focus on the actual command or on what it does. 8
We'll have plenty of time to dive deep into important command. 9
Just focus on the structure of the command line and how I put things together. 10
We notice that we have an active connection to 8.8.8.8 , which, by the 11
way, is a public DNS server from Google. 12
This is how we check that the Internet is working. 13
If you have any issue with your Internet connection to continue with this example, you can ping your 14
loopback interface ip address, which is 127.0.0.1. 15
This is the IP address of your loopbeck interface. 16
It will work even though you don't have an active network connection. 17
Let's take a closer look at the command line. 18
The name of the command is ping, 19
c is one of the command's options, 1 is the options value and the IP address, which was 127. 20
0.0.1 is the command argument. 21
It's important to know that all options are preceded by a hyphen, a minus sign. 22
Note the the command name, its options and arguments are always separated by one or more white 23
spaces. 24
In fact, the shell knows that the command name ends where it sees the first white space. 25
The command name has ended here before, hyphen c. Note that it's common to separate the command 26
name, its options and arguments by one whitespace, but there's nothing wrong if you write more white 27
spaces. 28
This is correct as well. 29
It's fairly standard that the options must come after the command name and before any command 30
arguments. 31
However, there are variations in the commands that permit options after the main argument like 32
this. 33
I'm removing -c1 34
and I'm writing it at the end -c1. By the way, it means that it will send only one ping packet 35
to the destination. 36
This is the same, but it's not common. 37
In the examples of this course will follow the standard we’ll write 38
the options after the command name and before its arguments. 39
In Linux, there are commands that require some options or arguments and return an error if they are run 40
without arguments; and they are other commands that do not necessarily require options or arguments. 41
For example, if I ran the ping comment again, this time without any option or argument, I'll get 42
an error. 43
It says " destination address required". 44
It's mandatory to specify an argument; but if we take another command, say ls, will see that we 45
can run it both with and without options or arguments. 46
By the way, ls is probably the most used the Linux command. 47
Its name comes from list and it displays or lists information about the file system. 48
In this example, the ls commeand has displayed the contents of the current working directory. 49
Now let's run it with an option and the argument: -l option tells ls to use a long listing format 50
/etc, which is the argument, indicates what directory to list. 51
Using the options, we change the commands behavior. 52
Note that some options can be written using a hyphen or a minus sign and a single character such as 53
-l or double hyphens and an entire word. 54
So ls-- all and ls -a are similar, it's the same command. 55
By the way, this option-a or --all, will display the hidden files and directories 56
as well. Note 57
that you can use more options, not only one. 58
In this example, I'm using both short and long options. 59
And it's common togroup all short options together like this. 60
See how I've grouped the L and age options together; the last two commands have the same effect, 61
they are equal. Let’s see one last example: 62
I'm running a command without any option, df; the same command with a single option in short format: 63
The command with two options. 64
Sorry, the command is df 65
Or I can group the options. 66
I can also add a third option in long format. 67
By the way, the df command displays information about the filesystem and the disk space usage. 68
OK, that's all about the Linux commands' structure, options and arguments. 69
This lecture is really important 70
if you are a complete beginner. Take your time to deeply understand each concept and rewatch the video 71
until you feel confident about it.