Sunteți pe pagina 1din 18

Introduction to LINUX &

LINUX Commands

by

Saurabh Sharma
Suggestion Accepted on

(saurabh.sharma44@gmail.com)
saurabh.sharma44@gm
ail.com
The PATH: Locating Commands
• UNIX obtains the list of directories that has
to be searched from of an environment
variable – PATH.
• If you evaluate the value of PATH, you’ll
find a directory list separated by colons:
$ echo $PATH
/bin:/usr/bin:/usr/X11R6/bin:/usr/local/bin:.
http://www.dynamicminds.co.in

The PATH: Locating Commands


• There are five directories in this list, and
when you issue a command, the system will
search this list in the sequence specified to
locate and execute it.
• . indicates the current directory.
• To know in which directory the command is
located, you can use the type command.
$ type ls
ls is /bin/ls
http://www.dynamicminds.co.in
Internal and External Commands
• The agency that actually does all this work
is known as shell – a command interpreter.
• Since ls is a file having an independent
existence in the /bin directory (or /usr/bin),
it is called an external command. Most
commands are external in nature.
• The commands built in shell are known as
internal commands.
Saurabh.sharma44@
gmail.com
Internal and External Commands
• The type command itself is a shell built-in.
Whether or not you are able to execute it
depends on the shell you use.
• In some versions of the C shell, the type
command won’t work. In this case, which
or whereis can be used.
• The shell uses its internal command even
though there is an external command of the
same name.
http://www.dynamicminds.co.in
Command Structure
• An UNIX command is composed of two
parts: command and argument.
• Commands and arguments are separated by
any number of spaces or tabs know as
whitespace.
$ ls-l
ls-l: Command not found.
• The argument that begins with a – symbol is
called an option.
http://www.dynamicminds.co.in

Options and Filenames


• Every command has a fixed set of options.
• The command with its arguments and
options is entered in one line that is referred
to as the command line.
• Some commands accept a single filename,
some accept more than one filenames.
• Wrong options will be indicated.
• An option can have its own arguments.
pine –f mail-may
http://www.dynamicminds.co.in

Combining Options
• Options that begin with a – sign can
normally be combined with only one – sign.
• For instance, this command has three
options:
ls –l –a -t
• The -l option provides most details of a
file’s attributes. The –t option sorts files
according to the time of modification. The
-a option lists the hidden files.
http://www.dynamicminds.co.in

Combining Options
• You can combine these options in this way:
ls –lat
ls -atl
• This facility reduces your typing load. The
shell parses (break up) the option
combination into separate options.
• Some commands won’t let you combine
options in the way you did just now.
tar –cv –f /dev/fd0 –b 18
http://www.dynamicminds.co.in

Combining Options
• There are four options here, but two of them
(-f and –b) has their own arguments. These
arguments are called option parameters.
• We combined the –c and –v options here.
We can combine the –f and –b options,
provided that their own parameters are
placed in the same sequence.
tar –cvfb /dev/fd0 18
• The following one won’t work:
tar –cvfb 18 /dev/fd0
http://www.dynamicminds.co.in

Exceptions and Variations

• All commands don’t compulsorily use


options and arguments.
• Commands like clear don’t accept any
argument.
• The who and date commands may or may
not be specified with arguments.
http://www.dynamicminds.co.in

Exceptions and Variations


• The ls command permits more variations:
– Without any argument (ls)
– With only one option (ls –l)
– With only filenames (ls chap01 chap02)
– Using a combination of both (ls –la chap01
chap02)
• This text discusses commands that use
options. The vast majority will conform to
the option rules that have been discussed
but there are some exceptions.
http://www.dynamicminds.co.in

Flexibility of Command Usage


• UNIX allows you to specify more than one
command in the same command line. Each
command is separated from the other by a ;
(semicolon):
who; ls -l
• The ; is one of special characters that are
understood by the shell. These special
characters are known as metacharacters.
http://www.dynamicminds.co.in

A Command Line Can Overflow


• When a command has more characters than
the terminal width, it simply overflows to
the next line.
• You may want to spread the command into
multiple lines. The shell issues a secondary
prompt, usually > (or ?).
$ echo “This is a two-line
> text message”
• In C shell you have to enter a \ (backslash).
http://www.dynamicminds.co.in

Flexibility of Command Usage


• Subsequent commands can be entered at the
keyboard without waiting for the prompt.
There is a type-ahead buffer (a temporary
storage area) which stores all these
commands and passes them on for
execution.
• A command may not behave in the way you
want because UNIX comes in many flavors.
http://www.dynamicminds.co.in

Flexibility of Command Usage


• The uname can print system information.
$ uname
Linux
• The uname –r command shows the version
number of the kernel.
$ uname –r
2.2.19
http://www.dynamicminds.co.in
References and Contacts
To know the details about
• Why Linux?
• Linux architecture
• File System & Permissions
• Basic and Advanced commands
• Networking concepts & commands
• Utilities like RPM, TAR…etc
• System calls
• Kernel level programming
• Project Ideas and help (Final year – BE , MCA)

For more details visit:- www.dynamicminds.co.in


Contact:- Sharad Durgawad /Narayan Sonumkar
Mobile:- 9822541698/9960515188
email:- sharad.durgawad@dynamicminds.co.in
narayan.sonumkar@dynamicminds.co.in
http://www.dynamicminds.co.in

Thank You

http://www.dynamicminds.co.in

S-ar putea să vă placă și