💭
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.
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.
Top comments (0)