دافغانستان امارت اسالمي
اداره کړو زده مسلکي او دتخنیکي
System Administration Tools
Introduction to Linux CLI
o Course: System Administration Tools
o Topic: Linux CLI Mode
o Lecture: Hafizrahman Jabarkhil
o Faculty: Computer Science
o Department: Information Technology
2
1
Objectives
• Introducing Linux Command Line Interface
• Working in Command Line Environment
3
Command line structure
• Unlike many of the operating systems in use today, Linux
(in its base form) does not have a visual interface.
• The UNIX interface consists of commands being typed by
the user and then interpreted by the shell.
• The structure of the command line is a very important
thing to memorize if you plan to use the UNIX system.
• The command line has the form:
prompt command options arguments
4
Continue...
●
For example:
% ls -l this
●
Prompt: Given by the shell to tell the user the shell is
waiting. Will be different depending on which shell is in
use.
●
Command: Typed by the user telling the shell what task
is desired. It is usually one word (or abbreviation).
●
The command portion of the command line corresponds
to the verb portion of a sentence it provides the action
requested. The user can create additional commands.
5
Continue...
●
Options: Typed by the user telling the shell any details
about the command requested.
●
They are often called "switches" in Linux texts.
●
They are usually a single letter or number preceded by a
dash "-" or a plus sign "+".
●
Most commands have default values for the options which
will be used if no option is specified.
●
The option portion of the command line corresponds to the
adverb portion of a sentence it gives details of how the
command should do its task.
●
What options are available are specified by each command.
6
Continue...
●
Arguments: Typed by the user telling the shell to whom the
action should be done.
●
Each argument is often a single file, user or directory name.
●
Most commands have default values for the arguments
which are not specified.
●
The arguments portion of the command line corresponds to
the direct object of a sentence.
●
How many and what types of arguments are expected are
specified by each command.
7
Continue...
●
White-space: The portions of the command line typed by
the user must be delimited by white space.
●
At least one whitespace character must be typed between
the end of the command at the beginning of the option or
argument or between two arguments (etc.).
●
The whitespace can be a space (pressing of the space bar),
multiple spaces (several pressings of the space bar), a tab,
several tabs or any combination of these.
8
Continue...
●
Enter (return): The command is submitted to the shell
when the enter (or return) key is pressed at the end of the
command line.
●
This is called "entering the command". Until the command is
"entered" it can be modified because the shell will not try to
interpret the command until it is entered.
9
Designed by programmers/for programmers
●
It is harder to learn, but faster once you know it for several
reasons:
✔ The first reason is that the commands were selected to
be easy for people to type, most of the commands
represent words, but some of the letters have been
removed to make them faster and easier to type.
One example of this is the ls command, ls stands for the
word "list", but the "l" and the "s" are the easy ones to
type because they are under your two ring fingers.
✔ It is also difficult to learn because they designed Linux
with many very small utilities. Whenever you want to do a
task, you often have to use several of these utilities just
to get the one task done.
1
0
Continue...
✔
These small utilities make it is easier for the people who
really know UNIX because the commands can be
personalized to make whatever you do the most often
more efficient.
●
The commands must be spelled completely correct, in the
correct command line structure and at the correct prompt
these are a lot of details to remember.
1
0
Case sensitivity
●
Linux is extremely sensitive in how the command is typed
including case sensitivity (upper and lowercase letters are
distinct).
●
This applies to the command names typing " LS " when you
meant " ls " would be as invalid as any other garbage
command you could have given.
●
This case sensitivity also applies to the options and
arguments. If a file is named this.fileand you refer to it in a
command as THIS.FILE , you are naming a completely
different file which may also exist, but is definitely not the file
intended.
1
1
Naming rules
●
Default directory: When you first log in to the Linux system,
you are usually placed in your home directory.
The directory you are in at that time is called the current
directory.
There are many ways to indicate the name of the directory.
One obvious distinction is between the references which are
absolute in contrast to the references which are relative.
1
2
Continue...
●
The notation includes:
Looking at the beginning It means ... Example...
of the complete
filename...
If there is a / (slash) at Start at the root directory /this/that/my.file
the beginning, (the other slashes after
the beginning are
delimiters)
If there is a . (period) at the Start at the current ./that/my.file
beginning, working directory
If there is a .. (period, Start at the directory which ../this/that/my.file
period) at the is the parent of the current
beginning, directory
If there is a ~ (tilde) at the Start at your own home ~/this/that/my.file
beginning with no name directory
1
following it, 3
Continue...
Looking at the beginning It means ... Example...
of the complete
filename...
If there is a ~ (tilde) at Start at the home of the ~user1/this/that/my.fil
the beginning with a name user ID given by e
following it,
If there is nothing Start at the current this/that/my.file
indicating the directory working directory
(notice no /, ., .., or ~ at the
beginning)
These notations can also be mixed in other ways such as
~user1/../this/my.file
which would mean go to the home of the user whose login id is user1 ,
then to that home's parent, then to that parent's child named this
and then to the child of this named my.file .
1
4