Topics covered

the first linux kernel was invented by Linus Torvalds.

The kernel is the core of linux system, it's a program running all the time in the background and it's the first program to run when we start up the computer when the boatstrap starts and loads it into the RAM then the function init() or system() is called and loaded into the virtual memory to be the parent of all upcoming processes which will run on our OS that's how it has the control over all the processes running on our OS.

kernel is responsible for 4 main functions:
  • System memory management: it can create virtual memory not only our physical memory.
  • Software program management: it manages all the processes running on the OS, for instance it manages whether the process will run on foreground or background, when the process is supposed to wait and when it will back to the running state as the process scheduler is a core part of the kernel in linux.
  • Hardware management: each device has a driver code saved inside the kernel and whenever the kernel needs to communicate with that divice it uses that code, also the kernel is responsible for allocating the resources required by each process to it.
  • Filesystem management: linux kernel supports many file systems.

GNU stands for GNU’s Not Unix.
GNU organization supports OSS(open source software) to allow programmers to develop and release software without any licensing fees, anyone can use, test, update and develop new releases of software without license so it's completly free.

Shell is one of the most important part in any linux OS, we can deal with the shell using the terminal as we can consider the terminal is the program takes commands from the user as input and give it to the shell then the shell executes this command and returns the result to terminal to be viewed to the user.

we can consider the shell as the core command prompt so users can use it to execute any sort of operations as he knows the command and has the privelege to execute it.

there're many types of shells supported by linux OSs.

Standard Shells :

  • Bourne Shell(sh): the first shell invented with unix's start, it was a very simple shell in which all variables are strings.

  • C shell(csh): it was inveted after Bornue shell and it's very efficient as it can deal with a lot of variables types and OS jobs and processes and it keeps commands history. it has just 1 problem, commands and programs on this shell are following C language syntax.

  • Korn Shell(ksh): it was invented after the C shell with more capabilities and it solved the problem of C shell, the commands became more easy and clear but it has another problem as we're writing on the prompt using vi which is not user friendly.

  • Bash Shell (Bourne-Again SHell): it took all the advantags of KSH and made dealing with the shell as easy as dealing with bourne shell and by the time they're adding new features to it.

CLI was the only way to deal with the earlier versions of Unix and Linux we just have the command prompt and the only input device is the keyboard so these systems had many restrictions because they had no GUI but also that made CLI have commands for every operation can be done in an easy way.

When new versions of linux with GUI were released such as Ubuntu they noticed they implemeted the terminal in it to allow users to deal with the shell (linux console) and as we know in many operations we prefer to do it using commands because GUI actually freed us from restriction of using different input devices and getting output in a fancy way but it also ristrict us to use only around 10% of system capabilities and options.

So after linux releases included the GUI they also provided the terminal to access the CLI.

GNOME's terminal is the latest version.
To access GNOME's tetminal press: Ctrl + Alt + T, or you can just run it throuth the GUI.
Important shortcuts can be used with terminal:
  • Ctrl + Shift + C: Copy.
  • Ctrl + Shift + V: Paste.
  • Ctrl + C: to break out of command or process and stop it.
  • Ctrl + Z: to send the current running process that is holding the terminal to background.
  • Ctrl + D: it will log you out of the current terminal. If you are using an SSH connection, it will be closed and If you are using a terminal directly, the application will be closed immediately.

Directory hierarchy.




Directory Description
/ root directory.
/bin contains user level commands as executable programs available in order to attain minimal functionality for the purposes of booting and repairing system.
/boot contains the boot files.
/dev that's where linux creates file for each device.
/etc contains system configuration files.
/home contains directories for each user of the system.
/lib contains system and application library files.
/media that's where mount points of removable media are created.
/mnt
/opt that's where 3rd party software and data files are stored.
/var contains the files and directories which their size changes dramatically such as log files.
/usr consists of several subdirectories that contain additional UNIX commands and data files.
/tmp consists temporary files such as the files stored by the browser or the server for a little time and the files in this directory are usually distroyed in different periods.
/proc contains the running processes and its information.
/sbin contains admin-level commands as executable programs.
/run contains runtime data during system operation.
/srv that's where local services store there files.
/sys contains hardware information files.

bash shell has manual which has information about every command and some system files like passwd, shadow, group, etc.
The main sections of the manual:
  • Name: it contains command name and description.
  • Synopsis: shows command syntax.
  • Description: general description of the command.
  • Options.
  • Return Value.
If you can't remember some command use man -k with a keyword, for instance if that command is dealing with terminal just type: man -k terminal.

manual has different sections which have numbers 1 to 9, we can write the section number after man keyword to access it and if you don't write any number then it's 1 by default. commands example:
  • man passwd
  • man 1 passwd
  • man 5 passwd
-the first and second commands are the same and it'll show the man page of passwd command.
-the third command will show you the man page of the passwd file in (/etc/passwd).

Sections of man page

Section number Description
1 shell commands, and programs.
2 sys calls.
3 lib calls.
4 special files.
5 descripes file format and it deals with system files.
6 Games manual.
7 System adminstration commands, eg: root commands.
9 kernel related.


Basic commands

Section number Description
cd + (relative or absolute directory path) changes the working directory to that path.
cd changes the directory to user's home directory.
cd ~
cd /home/_my user name(login)_
pwd print working directory (current directory).
ls basic listing, list the contents of current directory.
ls + (absolute or relative path of directory) list the contents of the given directory.
ls -l option -l is used for more information such as file or dir type, permissions, its owner and group, creation date and last modification date.
ls -a option -a shows the current directory contents including hidden files
ls -R option -R means recursive listing lists the contents and for directories it lists its contents.
ls -R option -R means recursive listing lists the contents and for directories it lists its contents.