[go: up one dir, main page]

0% found this document useful (0 votes)
135 views28 pages

Shell Basics

The document provides an in-depth overview of the shell in Linux systems. It discusses user interfaces and different types including graphical (GUI) and command line (CLI). It defines what a shell is and its importance for automating tasks. The document covers how to access the shell, navigate the file system, write shell scripts, and reasons for using scripts. Resources for further learning about shells and scripting are also listed.

Uploaded by

rennie kimutai
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)
135 views28 pages

Shell Basics

The document provides an in-depth overview of the shell in Linux systems. It discusses user interfaces and different types including graphical (GUI) and command line (CLI). It defines what a shell is and its importance for automating tasks. The document covers how to access the shell, navigate the file system, write shell scripts, and reasons for using scripts. Resources for further learning about shells and scripting are also listed.

Uploaded by

rennie kimutai
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/ 28

The Shell

A look at :

● Introduction
● ICE Breaker
● UI - in depth
● GUI & CLI
● What is the shell
● Shell navigation

UI
User Interface

● Communication between a user and a computer is two-way.


● One of the jobs of the operating system is to provide a 'user
interface', so that a human can communicate with the
hardware that makes up a computer.
● A user will give data and instructions to a computer and a
computer will give information back to a user. The way that a
computer and a user communicate is known as the interface.
Types of User Interfaces

1. GUI - windows
2. CLI - unix (
3. Form-based interfaces - hospital form
4. Menu-based interfaces- ATM
5. Natural language interfaces - alexa, siri
1. Graphical User Interface

Interfaces that are graphical in


nature are known either as Graphical
User Interfaces (GUI) or WIMP
interfaces (Windows, Icons, Menus
and Pointer)
2. Command Line Interface

● A command line interface requires a user to type in commands from a


list of allowable commands.
● This type of interface can take a long time to learn and is not intuitive.
● For inexperienced users it can be a frustrating type of interface whilst
for experienced users it can be very powerful. This is because
command line interfaces provide commands that can get a user very
close to the workings of the components of a computer system. There
are commands that can manipulate the hardware and software in a
computer system in a way that simply cannot be done using a GUI.
● Indeed, there are tasks where you have to use a command line
interface to carry them out. UNIX and DOS are good examples of CLI OS.
What is a shell and why you should care

● A shell is a computer program that presents a CLI which allows you to control
your computer using commands entered with a keyboard instead of
controlling graphical user interfaces (GUIs) with a
mouse/keyboard/touchscreen combination.
● The shell makes your work less boring, you can automate those repetitive
tasks and leave you free to do more exciting things.
● The shell makes your work less error-prone. Your computer can do the same
thing a thousand times with no mistakes.
● The shell makes your work more reproducible since it keeps a history of your
work.
● etc
Hello Shell,

Could you please ask Kernel to create a


directory in /root/Documents for me, call
it my_dir. Then inside it create a script
called my_script.sh and type #!/bin/bash
inside it.

Thank you in advance.

-Beta
How to access the shell

● On a Mac or Linux machine, you can access a shell through a


program called “Terminal”, which is already available on your
computer.
● The Terminal is a window into which we will type commands.
● If you’re using Windows, you’ll need to download a separate
program to access the shell e.g git bash, WSL
What is the alx-SE sandbox

● Sandbox is a remotely isolated virtual machine that is


configured to run ubuntu version 20.04 CLI to enable you to
access a terminal to work on the projects.
● Your sandbox is your playground.
The anatomy of the Shell

● The innermost core of the Linux OS is the kernel.


● The outermost shell of the Linux OS is Shell.
● The kernel acts as a window for the software
programs to recognize and run on the hardware
components.
● While the Shell receives the commands directly
from the user and sends it to the kernel for
processing and in turn, returns back the
response to the user.
● It wraps inside of the OS and protects it from any
external damage directly. Hence, the name Shell.
Main types of Shell

1. Bourne Shell (sh) - the first kind of shell programmed by


Stephen R. Bourne in AT&T Bell Labs in the mid-1970s. Also
known as the primary Unix Shell. E.g ksh, bash, sh
2. C Shell (csh) - the UNIX enhancement written by Bill Joy
Shell Prompt

● The prompt, "$", is called the command prompt, which is displayed by


the Shell. This command prompt is the interface, on which you can
write and execute your commands and programs.
● The command prompt reads the first word and interprets the
command. The Shell reads the command only once you press "Enter".
Linus Torvalds, (born December 28, 1969, Helsinki, Finland), Finnish computer
scientist who was the principal force behind the development of the Linux
operating system.
Navigating the
linux file system
Navigating the file system

● The part of the operating


system that manages
files and directories is
called the file system.
● It organizes our data into
files, which hold
information, and
directories (also called
“folders”), which hold files
or other directories.
Shell Commands

● Shell commands are


particular to the shell (tcsh, in
this case).
● Unix commands are common
to all Unix systems, though
options vary a bit.
● Special characters may apply
to Unix in general, or be
particular to a shell.
Talking to the computer kernel directly

A shell command is one that is processed internally by the shell. There is no


corresponding executable program.
Shell Scripting
Shell Scripting

● A shell script is a text file that contains a sequence of


commands for a UNIX-based operating system.
● It is called a shell script because it combines a sequence of
commands, that would otherwise have to be typed into the
keyboard one at a time, into a single script.
● To create a script you need to use a text editor (vim, vi, emacs)
to write your commands in ASCII text.
Writing a shell script

● #! (Shebang) - The first line of the script dictates the program will be
used to interpret the script. In the example above /bin/bash has been
used (but you can also use Perl, aw, tcl, Python and Tk instead)
● comment – The comment basically explains to the programmer
viewing the text what the script is for (the # tells bash to ignore what
appears after it.)
● echo command – Prints out the argument.
Writing a shell script

● Granting permission to Shell script - Each shell script must have the execute
permission
● Executing shell scripts - specify the path to the script file to run it
Why you need shell scripts

There are many reasons to go through the process of writing your own
scripts, and the number one reason is convenience. With shell scripts, you
can create your own commands and save time entering commands on a
case-by-case basis. You can effectively automate multiple commands.
Without scripts, you’d have to run these manually yourself each and every
time.
Resources

1. Understanding what the shell is


2. User Interfaces in detail
3. All about the Shells
4. Linux commands handbook
5. Linux commands cheat sheet
6. Linux terminal starter guide
7. Getting started with Shell Scripting
8. Linux is amazing
9. Shell Scripts are awesome
10. Shell scripting crash course
Announcements
Explore your intranet
Explore your sandbox
Feedback form is calling for your response
More Live Sessions loading in your intranet calendars…
See you at
the next
session!

You might also like