DEV Community

Vivesh
Vivesh

Posted on

1

Understanding Basic Concept of Shell part 1

💭
What is Shell?
Why shell?
💭

*Shell *- Shell is a command-line interpreter. It translates commands entered by the users and converts them into a language that is understood by the kernel. (Kernel Heart of a computer)

*Kernel *- The computer programs that allocate the system resources and coordinate all the details of the computer's internals are called Kernel or OS.

*CLI *- Command-line interface is a text-based interface used to interact with software & OS by typing commands into the interface & receive a response in the same way. (Fastest ways, runs faster)

Graphical User Interface (GUI) Command Line Interface (CLI)
Graphical Representation Console Representation
Ease of use (depends on comfort) 😔 Ease of use (depends on comfort) 😊
OS is slower Faster OS
Less control Granular Control

Shell Script - A Shell script is a command containing a text file that contains one or more commands.
Advantage
Facilitates us to develop our own OS with relevant features.

Superblock - A program that contains all the information regarding a specific file system.

Types of Shell - basically there are two types of shell script.

Bourne Shell Type C Shell Type
Bourne Shell C Shell
Korn Shell TENEX/TOPS C Shell
POSIX Shell Z Shell

*Variables *- Character string which we assign to value, it can be number, text, filename, device, any other type of data.
System Defined variables - Set command
User-Defined variables - Echo command
Types of Variables - Local, Environmental, Shell

Local - Variable that is present within the current instance of the shell. They are not available to programs that are started by the shell.
Environmental - Variable that is available for any child process of the shell. Some programs need environmental variables to function.
Shell - They are special variables set by the shell. They can be Local or Environmental. Required by the shell to function.

cd - change directory
pwd - show you the current working directory
ls - for list
cp - copy
mv - move
rm - remove
echo -for print
cat - concatenate the file.(textfile)
less - utility that can be used to read the contents of the file on one page at a time.(textfile)
grep - search for a particular pattern of characteristics.
mkdir - make a directory
touch - make file (Quickly)
chmod - change mode
man - manual/help.
-l - used for long listing format.
Enter fullscreen mode Exit fullscreen mode

The reason behind 111, 777, 000 Chmod 777 👀

n - Nothing, x - Execute, w - Write, r- Read

0 = 0 - n
1 = 1 - x
2 = 2 - w
3 = 2+1 - x+w
4 = 4(2+2) - r
5 = 4+1 - r+x
6 = 4+2 - r+w
7 = 4+2+1 - r+w+x

Creating Shortcut in Linux - Softlink & Hardlink

Softlink - soft link is linked to the filename & can reside on different file systems, deleting the original file makes the soft link inactive.
Hardlink - Hard links are linked to the inode of the file & have to be on the same file systems, deleting the original file does not affect the hard link.
An Inode number is a uniquely existing number for all the files in Linux and all Unix-type systems.
When a file is created on a system, a file name and Inode number are assigned to it.

Stages of Linux process -
Waiting - In this stage the Linux process waits for the resource.
Running - The Linux process is currently being executed.
Stopped - The Linux process is stopped after successful execution.
Zombie - The process is stopped but still active in the process table.

Basic Operators -

  • Arithmetic
  • Relational
  • Boolean
  • String
  • File test

Shell Loops -

  • For Loop
  • While Loop
  • Until Loop
  • Nested Loop
  • Infinite Loop

Break Command - It's a Simple way to escape out of a loop in the program, we can use the break command to exit out from any loop including while and until loop.

Continue Command - It causes the present iteration of the loop to exit, instead of the entire loop.

Image of AssemblyAI

Automatic Speech Recognition with AssemblyAI

Experience near-human accuracy, low-latency performance, and advanced Speech AI capabilities with AssemblyAI's Speech-to-Text API. Sign up today and get $50 in API credit. No credit card required.

Try the API

Top comments (0)

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more

👋 Kindness is contagious

Discover a treasure trove of wisdom within this insightful piece, highly respected in the nurturing DEV Community enviroment. Developers, whether novice or expert, are encouraged to participate and add to our shared knowledge basin.

A simple "thank you" can illuminate someone's day. Express your appreciation in the comments section!

On DEV, sharing ideas smoothens our journey and strengthens our community ties. Learn something useful? Offering a quick thanks to the author is deeply appreciated.

Okay