LINUX
Kernel
The kernel is the core part of the operating system. It manages the
system's hardware and acts as a bridge between software (applications)
and hardware (CPU, memory, devices).
You can think of the Linux kernel as a communicator or translator
between:
🧠 Software (your apps and programs)
⚙️Hardware (CPU, RAM, hard drive, network card, etc.)
💬 Here's how it works:
When you open a program (like a browser):
The program doesn't talk to hardware directly.
Instead, it sends requests to the kernel.
The kernel processes those requests and tells the hardware what to
do.
🧩 Distribution
A distribution (or distro) is a complete operating system built around the
Linux kernel, bundled with tools, software, and a user interface.
🧩 What Is a Bootloader?
A bootloader is a small program that runs when you power on your
computer.
Its main job is to load the operating system (like Linux) into memory and
start it.
💡 Service:
A service in Linux is a background process that runs without direct user
interaction. It keeps your system running smoothly.
📁 What Is a Filesystem in Linux?
A filesystem is the way data is organized and stored on a disk.
It defines how files and folders are named, stored, accessed, and
managed, organizes data into files and directories, keeps track of where
each file is stored, Controls permissions (who can read/write/execute a
file).
What Is a Desktop Environment in Linux?
A desktop environment (DE) is a collection of software that provides a
graphical user interface (GUI) on top of the Linux operating system. The
normal stuff you see when using a computer.
💻 What Is the Command Line?
A command line, also known as a command-line interface (CLI), is a text-
based way to interact with a computer's operating system.
🐚 What Is a Shell in Linux?
Command line interpreter that interprets the command line input and
instructs the computer system to perform any necessary tasks and
commands (bash).
The Boot Process
The Linux boot process is what happens from the moment you turn
on your computer until the system is ready to use.
The first step when starting a Linux PC (like most desktops and
laptops) is the BIOS. It’s a small program stored on the
motherboard that runs when you power on the computer. The BIOS
checks and starts basic hardware like the screen, keyboard, and
memory — this check is called POST (Power-On Self-Test). Once this
is done, control is passed to the operating system to continue
starting up.
After the BIOS finishes its checks, it hands control to the boot
loader — a small program stored on the computer’s storage drive.
This can be in the boot sector (on older systems) or the EFI
partition (on newer systems using UEFI).At this point, the system
also reads settings like the date and time from a small memory chip
(CMOS), which keeps data even when the computer is off.
The Initial RAM Disk
The initramfs is a temporary mini filesystem loaded into memory during
boot. It contains the tools and drivers needed to:
Detect hardware (using udev),
Load storage drivers,
And mount the correct root filesystem.
Once the real root filesystem is found and checked for errors, it is
mounted using the mount command.
Removes initramfs from memory.
Runs the init program (found at /sbin/init) to continue booting.
Text-Mode Login
At the end of the boot process, the system starts login prompts where
you can enter your username and password to access the system.
On systems with a graphical login, these text prompts are hidden
at first.
You can access text-mode terminals using ALT + Function keys
(like F2, F3, etc.), or CTRL + ALT + Function key from a
graphical desktop.
Linux usually provides 6 text terminals and 1 graphical
terminal.
The default command shell is bash, which shows a prompt where you can
type commands. After you press Enter, the command runs, and the
prompt appears again, ready for the next command
The Linux Kernel
The boot loader loads the kernel and initramfs into memory.
Once the kernel is in memory, it:
Sets up the computer’s memory,
Detects and configures all hardware (like CPUs, storage, and
input/output devices),
And loads some essential user-space programs to continue the
startup process.
/sbin/init and Services
After the kernel finishes setting up the hardware and mounts the root
filesystem, it starts the init program (found at /sbin/init). This becomes
the first process and starts all other necessary processes.
init manages all non-kernel processes: it starts system services,
handles user logins, restarts services, and shuts the system down
properly,starts other processes to launch the full system.
Visual Example:
Imagine your hard drive is a cabinet:
Each partition is a drawer in the cabinet.
Inside each drawer, there's a way to organize things — that’s the
file system.
Directories are folders inside the drawer.
Files are papers or items inside those folders.
Linux Commands
expr 1 + 2 >>adding items
variable name= “value” >> creating a variable
echo $variable name >>display a line of text or a variable
value. Print echo
To print using the above variable in a sentence:
echo “Hello $variable name, How are you $variable_name”
History >> displays the history of used commands
Focus your terminal window and use the "up" arrow key to start
cycling through your command history.
Once you've cycled back through your history with the "up" arrow,
you can use the "down" arrow to cycle back to the most recent
command.
ctrl + l. >> clears screen, not history
pwd >>file system I am working on
echo 'export MY_VAR="Hello"' >> ~/. bashrc source
~/.bashrc
🔑 Root User
The superuser (administrator) of the system.
Has unlimited permissions: can read, write, and
delete any file, install software, manage users, and
change system settings.
Can accidentally (or intentionally) damage the
system—for example, by deleting important files or
changing critical configs.
👤 Regular User
A limited user account with restricted permissions.
Can only access or modify files they own (or are
given access to).
Needs permission (via sudo) to perform system-
level tasks like installing programs or changing
system files.
🔁 From Regular User → Root: sudo -I or sudo su
🔙 From Root → Regular User: exit
File system
/Users/wagslane
Let's break it down:
The first slash (/) represents the root directory. It's the tippy-top of
the filesystem tree.
The next part (Users) is the name of a directory inside the root
directory.
Finally, the last part (wagslane) is the name of a directory inside
the Users directory.
The cd dir_name command "changes directory" to move into a
directory.
cd.. is a special alias that refers to "the parent directory". It's a
shortcut that you can use to move up one level in the directory tree.
💡 Bonus Tips
~ always means your home directory (/home/Sandiswa)
cd .. means “go up one folder”
cd (with no arguments) takes you to your home directory
cd directory_name this takes you to the specified
directory
pwd print your current directory.
whoami To check who you are signed in as.
ls lists the files and folders.
cat view the contents of a file
Sometimes you don't want to print everything in a file. Files can be
really big after all, hence head and tail commands.
The tail command prints the last n lines of a file, where n is a
number you specify: tail -n 10 file1.txt
The head command prints the first n lines of a file, where n is a
number you specify : head -n 10 file1.txt
touch updates the access and modification timestamps of a
file/create new file.
nano filename.txt to create or edit text files from command line.
^X = Ctrl + X.
mkdir my_directory creates a new directory inside the current
directory.
The less command is a file pager used to view the contents
of a file one screen at a time — without opening it in a text
editor.
Navigation in less
space Go forward one page
Enter Go down one line
b Go back one page
/word Search for "word" forward
n / N Next / previous search result
g Go to beginning of file
G Go to end of file
q Exits less
mv moves a file or directory from one location to another /
rename a file. You can’t move the directory you’re working on.
Renaming a file: mv some_file.txt some_other_name.txt
Moving a file from the current directory to another nested
directory: mv some_file.txt some_directory/some_file.txt
rm some_file.txt deletes a file or empty directory
-R - "Recursive", meaning also apply the changes to
everything inside the directory
rm -r some_directory delete a directory and all of its
contents
Moving a file from the current directory to the parent
directory: mv some_file.txt ../some_file.txt
cp source_file.txt destination/ it copies a file from one
location to another: cp
~/worldbanc/private/transactions/12.csv
~/worldbanc/private/transactions/backups/
cp -R my_dir new_dir You can also copy a directory and
all of its contents recursively by adding the -R flag:
If you don't want to rename the file and you're just moving
it to a different directory, you can omit the filename: mv
some_file.txt some_directory/
grep "error" log.txt OR
grep "error"~/worldbanc/private/transactions/12.csv
search for a string in a file.
You can also search multiple files at once. For example,
if we wanted to search for the word "hello"
in hello.txt and hello2.txt, we could run: grep "hello"
hello.txt hello2.txt
You can also search an entire directory, including all
subdirectories. For example, to search for the word "hello"
in the current directory and all subdirectories: grep -r
"hello”.
Find command
The find command is a powerful tool for finding files and directories
by name, not by their contents. This also goes through the sub-
directories of the LAST specified directory. Do not forget to put “*X
” / “*X*”
find some_directory -name hello.txt Find a file by name
find some_directory -name "*.txt" search for files that
match a pattern
find some_directory -name "*chad*" find all filenames that
contain the word "chad"
Permissions command
drwxrwxrwx
-: Regular file (e.g. -rwxrwxrwx)
d: Directory (e.g. drwxrwxrwx)
permissions keys: owner(user), group, others
r=read
w=write
x=execute
chmod -R u=rwx, g=, o= directory name (This
command lets you change the permissions of a file or
directory).can also be done on the file, omit -R
In the command above, u means "user" (aka
"owner"), g means "group", and o means "others".
The = means "set the permissions to the following", and
the rwx means "read, write and execute".
The g= and o= mean "set group and other permissions
to nothing". The -R means "recursively", which means
"do this to all of the contents of the directory as well".
chmod -x genids.sh To simplify remove the
permission to execute, - to remove and + add
permission.
chmod u-x genids.sh You can also specify the
permission being changed whether for user, grp or
other, if you don’t the permission will be applied to all.
ls -l This command tells you who can access the
directory and what permissions do they have; it displays
the above string.
.sh Files with a .sh extension are shell scripts.
They're just text files that contain shell commands. You
can run a file in your shell by typing its filepath:
mydir/program.sh OR ./program.sh
The dot (.) is an alias for the current directory
Chown Change owner, allows you to change
the owner of the file/ directory so you can have
admin access to it.
Absolute vs. Relative Paths
Relative lifepaths:
vehicles
├── cars
│ ├── fords
│ │ ├── mustang.txt
│ │ └── focus.txt
When inside the top-level vehicles directory, the relative path to
the mustang.txt file is: cars/fords/mustang.txt, don’t count vehicles
directory.
Absolute path:
Starts at the root (/) of the filesystem
So, if vehicles is in the root of filesystem root the absolute
path of mustang.txt is / vehicles/cars/ fords/mustang.txt
Programs