0% found this document useful (0 votes)
21 views

Writing Linux Commands

The document discusses various Linux commands, their syntax and usage. It explains commands like date, calendar, df, free, who, whoami, clear and man for displaying system information and clearing the terminal screen. Examples are provided for most commands.

Uploaded by

Siddiqa Amir
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
21 views

Writing Linux Commands

The document discusses various Linux commands, their syntax and usage. It explains commands like date, calendar, df, free, who, whoami, clear and man for displaying system information and clearing the terminal screen. Examples are provided for most commands.

Uploaded by

Siddiqa Amir
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

Writing Linux Commands

3.1 Command Line Interface


The Command Line Interface (CLI), is a non-graphical, text-based interface to the computer
system, where the user types in a command and the computer then successfully executes it. The
Terminal is the platform or the IDE that provides the command line interface (CLI) environment
to the user. The CLI terminal accepts the commands that the user types and passes to a shell. The
shell then receives and interprets what the user has typed into the instructions that can be
executed by the OS (Operating System). If the output is produced by the specific command, then
this text is displayed in the terminal. If any of the problems with the commands are found, then
some error message is displayed.
We can open the terminal by typing Ctrl + Alt + T short-key or by right-clicking the mouse and
selecting the Open New Terminal option. The terminal window looks like given below.

Basic syntax of Linux Commands


A command is an instruction given by a user telling a computer to do something, such a run a
single
program or a group of linked programs. Commands are generally issued by typing them in at the
command line (i.e., the all-text display mode) and then pressing the ENTER key, which passes
them
to the shell.
A shell is a program that reads commands that are typed on a keyboard and then executes (i.e.,
runs) them. Shells are the most basic method for a user to interact with the system.
Options and Arguments
This brings us to a very important point about how most commands work. Commands are often
followed by one or more options that modify their behavior, and further, by one or more
arguments,
the items upon which the command acts. So most commands look kind of like this:
Most commands use options consisting of a single character preceded by a dash, for example, “-
l”,
but many commands, including those from the GNU Project, also support long options,
consisting
of a word preceded by two dashes. Also, many commands allow multiple short options to be
strung
together.
Command History
Most Linux distributions remember the last 500 commands by default. Press the down-arrow key
and the previous command disappears.
Some Basic Linux Commands
1. Date Command: This command is used to display the current data and time.
Syntax:
$date
$date +%ch
Options:
a = Abbreviated weekday.
A = Full weekday.
b = Abbreviated month.
B = Full month.
c = Current day and time.
C = Display the century as a decimal number.
d = Day of the month.
D = Day in „mm/dd/yy‟ format
h = Abbrevated month day.
H = Display the hour.
L = Day of the year.
m = Month of the year.
M = Minute.
P = Display AM or PM
S = Seconds
T = HH:MM:SS format
u = Week of the year.
y = Display the year in 2 digit.
Y = Display the full year.
Z = Time zone
To change the format:
Syntax:
$date “+%H-%M-%S”
2. Calendar Command: This command is used to display the calendar of the year or the particular
month of calendar year.
Syntax :
Sudo snap install calandar
Calander 8 2024
$cal <year>
$cal <month> <year>
Here the first syntax gives the entire calendar for given year & the second Syntax gives
the calendar of reserved month of that year.

3. To see the current amount of free space on your disk drives, enter df:

4. Likewise, to display the amount of free memory, enter the free command.
5. We can end a terminal session by either closing the terminal emulator window, or by entering
the exit command at the shell prompt
6. ’who’ Command: It is used to display who are the users connected to our computer currently.
Syntax:
$who – option‟s

1. -m: Show the host name and user associated with standard input (stdin) such as
the keyboard
2. -q: Count the number of users who are logged in to the system
3. -s: Display the name, line, and time fields only (default)
4. -T: Display the status of the user's message status (as +, -, or ?)
5. -u: Show user's idle time and process ID.
6. Print all information (-a)
7. Displays column headers (-H)
Options : -

H–Display the output with headers


b–Display the last booting date or time or when the system was lastly rebooted

7. ’who am i’ Command: Display the details of the current working directory.


Syntax:
$whoami
8. CLEAR’ Command: It is used to clear the screen.
Syntax:
$clear
9. MAN’ Command: It help us to know about the particular command and its options &
working. It is like„help‟ command in windows .
Syntax:
$man <command name>

You might also like