0% found this document useful (0 votes)
21 views24 pages

Wa0011.

Uploaded by

mussabazhari88
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
21 views24 pages

Wa0011.

Uploaded by

mussabazhari88
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 24

‫نظم التشغيل مفتوحة المصدر‬

‫‪Open Sources Operating System‬‬

‫د‪ .‬منار أحمد محمد حمزة‬


‫كلية علوم الحاسوب وتقانة المعلومات‬
‫جامعة أم درمان االسالمية ‪ -‬السودان‬

‫‪1‬‬
Lecture 5

2
LINUX Shell and Commands

Introduction to shell

Command Structure

Types of Commands
LINUX Shell
The Kernal is the core of a computer’s operating system, with
complete control over everything in the system.

A shell is special user program which provide an interface to a


user for using operating system services.

When you log into the system you are given a default shell.

When the shell starts up it reads its startup files and may set
environment variables, command search paths, and command
aliases, and executes any commands specified in these files.

Shell is broadly classified into two categories, namely Command


line shell and Graphical shell
LINUX Shell (Cont)
Command line Shell can be accessed by a user using a
command line interface via a special program called
terminal in Linux.
The command output is then displayed on the terminal.
 Graphical shells provide means for manipulating
programs based on graphical user interface(GUI), by
allowing for operations such as opening, closing,
moving, resizing windows, as well as switching focus
between windows.
Command Prompt or Prompt

Command Prompt is a short text message at the start of a


command line interface.
The default prompt on the bash shell contains the user
name, the computer name and the current directory name.
For example user name is OIU on computer named
VirtualBox and who is working in a directory called work,
the prompt would look like
Shell Programming

 You can write shell programs by creating scripts containing


a series of shell commands.

 The first line of the script should start with #! which


indicates to the kernel that the script is directly executable.

 You immediately follow this with the name of the shell, or


program (spaces are allowed), to execute, using the full path
name. So to set up a Bourne shell script the first line would
be: #! /bin/sh
Shell Programming

 The first line is followed by commands


 Within the scripts # indicates a comment from that point
until the end of the line, with #! being a special case if
found as the first characters of the file.
#!/bin/bash
cd /tmp
mkdir t
 You also need to specify that the script is executable by
setting the proper bits on the file with chmod, e.g.:
$ chmod +x shell_script
Command Structure

Command <Options> <Arguments>


Multiple commands separated by ; can be executed one after
the other
Lower-case and upper-case letters are not the same.
All linux commands are single words like ls, cat who, etc.
All stand command tend to be lower-case.
Basic Linux Commands
The ‘ls’ COMMAND
The ‘ls’ command is a Linux shell command that is used to
obtain a list of all filenames in the current directory.
Basic Linux Commands (Conts.)
The pwd COMMAND
The ‘pwd’ command stands for ‘print working directory’ and as
the name says, it displays the directory in which we are
currently (Directory is same as folder for windows OS users).
Basic Linux Commands (Conts.)

The cd COMMAND
Basic Linux Commands

The man COMMAND


The ‘man’ command stands for ‘manual’ and it can display the
in-built manual for commands that we ever need.
Basic Linux Commands
The clear Command
The ‘clear’ command is used to clean up the terminal so that
you can type with more accuracy.

After pressing Enter the terminal appears as follow:


Internal and External Command

Internal Commands
Internal commands are command the are already loaded in
the system. They can be executed any time and are
independent.
External Command
External commands are loaded when the user requests from.
Command Structure

Commands and arguments have to be separated by spaces or


tabs to enable the system to interpret them as words.
Any number of spaces can be used.
Command Structure
Options
There’s a special type of arguments that’s mostly used with a
‘-’ sign for example, when you use
 ls -l abc
-l is an argument to ls by definition, but more importantly,
it’s a special argument known as an option.
An option is normally proceeded by a minimum sign to
distinguish it from filenames.
There must not be any whitespaces between – and l but there
must be a space between the command and the argument , I,e,
after ls
Command Structure
Relative paths
 Relative paths is defined as the path related to the present
working directory (pwd). It starts at your current directory and
never starts with a /

Linux offers a shortcut in the relative pathname- that uses


either the current or parent directory as reference s and
specifies the path relative to it. A relative path-name uses
one of these cryptic symbols:
 (a single dot) –this represents the current directory.
 (two dots) –this is represents the parent directory.
• Options can be combined with only one ‘-’ sign
ls –lat abd
Is the same as
Ls –l -a –t abc
Flexibility of Commands
Combining Commands
 Linux allows you to specify more than one command in the
command line.
 Each command has to be separated from the other by a;
(semicolon)
ls; pwd
When a command line contains a semicolon, the shell
understands that the command on each side of it needs to be
processed separately The semicolon (;) here is known as
metacharacter.
Flexibility of Commands(Cont.)
Multi-line prompts
 Linux allows you to specify more than one command in the
command line.
Help Facilities for Commands

To understand the working of the command and possible


options use (man command)
 Using the GNU Info System (info, info command)
Listing a Description of a Program (what is command)
Many tools have a long−style option, `−−help', that outputs
usage information about the tool, including the options and
arguments the tool takes. Ex: whoami --help
Pipes

An important early development in Unix was the invention of


"pipes," a way to pass the output of one tool to the input of
another.
eg. $ who | wc −l
By combining these two tools, giving the wc command the
output of who, you can build a new command to list the
number of users currently on the system
Good Luck

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy