Understanding: OS, UNIX, Kernel, Shell and Terminal and make your terminal attractive

This is a compilation of best resources and lil summary of them: Highly recommend you to check out those resources
Some of my regrets from bachelors:
1. Read “Theory of Computation” (TOC) and Compiler just to pass the exam.
2. Not understanding “Comp Architecture” fully.
Anyways,
The more I read and learn about computers, more I become thankful. We are the luckiest generation because a older people have already figured out things like electricity, computers, softwares, graphics blabla… fundamentals are already figured out.
But it raises a question, what’s our purpose? well i don’t know either..
Maybe all the inventions that made the current reality possible where, I am laying on my bed with my laptop and writing this blog. Maybe, we are making small progresses in the field of AI and some years later, some other Gaurab will write directly from the brain, thanking our generation for researching in AI.
( Where is my contribution in AI ?? lmao)
UNIX: (one of the greatest step)
Unix is simply the first developed operating system which really enhanced the interactivity between humans and computers. Seeing it’s features today won’t sound exciting but at that time, it was the most exciting and most wonderful thing every developed.
About the History (5 min read):
Read the history, telegraph and starting of the shell. https://thevaluable.dev/guide-terminal-shell-console
Must watch video: best video
Video Link ——- https://www.youtube.com/watch?v=tc4ROCJYbm0&t=296s
Shell: aka command interpreter
Shell is from where you interact to the UNIX systems. ( think of it as terminal ). The terminal window in front of you contains shell, and shell allows you by use of commands to interact with your computer, hence retrieve or store data, process information and various other simple or even extremely complex tasks.
Script:
The command you write in the shell. commands we run are the prewritten small files in our file system and our shell knows which file to execute when that command/code/programme is run. like "ls" command Locates the binary file, typically at /usr/bin/ls, which then executes that binary to list the content.
The shell interacts with shared libraries, mostly the C library, and the libraries make system calls to the kernel. The kernel itself is the operating system. The shell is a piece of software that facilitates interactions between the user and the kernel.
so simply: "primary interface between you and the operating system's kernel"
Shell Script:
It is a file where we write a bunch of programmes (commands) and store in the file. That file runs it form top-bottom. eg: Creating a backup which includes maybe moving file, zipping file and saving somewhere. Best explained at : 15:00 in video.
Kernel: (the core)
Kernel is where the system calls happens. System calls is when the programme we wrote, the file we open, actually interacts with the hardware. eg: ReadFile( ), open( ), close( ) …
Figure from AT&T Archives
(Outermost is terminal you use like alaricty, kitty, gnome terminal )
Blog to read for writing Shell Scripting: https://linuxconfig.org/bash-scripting-tutorial-for-beginners#h1-bash-shell-scripting-definition
What are bash, zsh, fish?
They are the shell programmes.
What is actually different between shells?
The differences are mainly in language and user experience. (syntax, configurations made easy with fish using web etc)
Step Example of What Actually Happens
You enter: "ls"
1️⃣ Terminal sends input
2️⃣ Shell reads the command
3️⃣ Shell finds /bin/ls
4️⃣ Shell calls: system calls the functions that makes the system calls
fork()
execve("/bin/ls")
5️⃣ Kernel creates process
6️⃣ ls runs
7️⃣ Output printed to terminal
Change the SHELL you use and customize it:
cat ./.bashrc is the default bash file, the shell you use and likewise zsh. ./.zshrc
for fish you need to exit this: "~/.config/fish/config.fish"
config.fish
functions/
completions/
fish_variables
Each shell loads different startup files.
| Shell | Config file |
|---|---|
| Bash | .bashrc |
| Zsh | .zshrc |
| Fish | ~/.config/fish/config.fish |
So when you switch shells, the old config is ignored.
Since your config is bash I suppose:
Steps:
a) First check your current shell : echo $SHELL
if output is : "/usr/bin/bash" Proceed to 1
else enter below command to make bash the default shell:
"chsh -s /usr/bin/bash"
Now you're default shell is bash:
- Install these two libraries:
sudo apt-get install fortune cowsay
Open the file : "vim ./.bashrc " or "nano ./.bashrc"
inside that in the bottom put the command:
fortune | cowsay -r
- Now everytime you open your terminal, there is something new quote and character in the terminal. its because of the fortune pipe cowsay with -r flag.
Thankyou !! Please comment or reach out to me at : "oe.gaurav@gmail.com" if there's some improvements or mistakes. Let's do some projects together, I am always willing to learn and work
