πΉ Overview
-
A Linux command typically consists of:
-
Command name
-
Options (also called flags or switches)
-
Arguments
-
-
Basic syntax:
command [options] [arguments]
Example Command
ping -c 1 8.8.8.8
-
pingβ Command name -
-cβ Option (sends a specified number of packets) -
1β Option value (only 1 packet) -
8.8.8.8β Argument (Google's public DNS server)
β Used to test network connectivity.
π‘ If you donβt have internet access, tryping 127.0.0.1(loopback interface).
Command Structure Breakdown
Component | Description |
|---|---|
Command Name | Starts the line; ends at first whitespace |
Options | Begin with a hyphen |
Option Values | Immediately follow the option |
Arguments | Come after options; provide input to the command |
-
Whitespace matters: Components are separated by one or more spaces.
-
Positioning: Options usually come between the command and its arguments.
β οΈ While some commands allow flexible placement of options, the course follows the standard convention:
- βCommand β Options β Argumentsβ
Optional vs Required Options/Arguments
-
Some commands require arguments:
-
ping # β Error: "destination address required" ping 8.8.8.8 # β -
Others can run without arguments:
-
ls # β Lists current directory contents ls -l # β Long listing format ls -l /etc # β Lists `/etc` in long format
Option Formats
Format | Example | Description |
|---|---|---|
Short |
| Single-character options with single |
Long |
| Word-based options with double |
Combined |
| Multiple short options grouped |
Mixed |
| Short and long options together |
π
ls -aandls --allare equivalent (show hidden files).
df Command Example
- Displays filesystem and disk usage:
df # Basic output
df -h # Human-readable format
df -hT # Combined short options
df -hT --total # Adds total disk usage (long option)
β Summary
-
Mastering command structure is essential for Linux beginners.
-
Components:
-
Command
-
Options (short
-x, long--xyz) -
Arguments
-
-
Stick to the standard format:
command [options] [arguments]
Not all commands behave the same; experiment and read help pages (man or --help) to understand specific command behaviour