Fundamentals of Linux

by Faruk CEBECI

What is Linux?

  • Linux is not an operating system.
  • Linux is an open-source unix-like operating system kernel.
  • It was created by Linus Torvalds in 1991.
  • It is the most popular operating system kernel in the world.
  • It is used in wide range of devices from supercomputers to embedded systems.
  • Android is based on Linux kernel.
by Faruk CEBECI

What is an Operating System?

  • An operating system is a software that manages computer hardware resources and provides common services for computer
    programs.
  • It consists of a kernel and system programs.
  • Generally, GNU/Linux is used to refer to the combination of Linux kernel and GNU system programs.
  • There are many distributions of Linux that combine Linux kernel with different system programs.
by Faruk CEBECI

Common Linux Distributions

Distribution Package Manager Init System Desktop Env
LFS None None None
Gentoo emerge OpenRC None
Ubuntu / Debian apt Systemd Gnome
Fedora dnf Systemd Gnome
CentOS yum Systemd Gnome
Arch Linux pacman Systemd None
Alpine Linux apk OpenRC None
by Faruk CEBECI

What is an Operating System Kernel?

  • A kernel (or operating system kernel) is a software that provides a bridge between applications and the actual hardware.
  • It is responsible for managing system resources, such as memory, CPU, and I/O devices.
  • It provides system calls for applications to interact with hardware.
by Faruk CEBECI

Major Components of Linux

  • Virtual File System
  • Process Management
  • Memory Management
  • Device Drivers
  • Network Stack
  • Security
by Faruk CEBECI

Root File System

by Faruk CEBECI

File System Hierarchy

by Faruk CEBECI

Common System Calls

by Faruk CEBECI

Hello World in C

#include <stdio.h>

int main() {
    printf("Hello, World!\n");
    return 0;
}
by Faruk CEBECI

Hello World in C (with system calls)

#include <unistd.h>

int main() {
    write(1, "Hello, World!\n", 14);
    return 0;
}
by Faruk CEBECI

Hello World in x86 Assembly

.section .data
msg:
    .ascii "Hello, World!\n"
    len = . - msg

.section .text
.globl _start
_start:
    mov $4, %eax
    mov $1, %ebx
    mov $msg, %ecx
    mov $len, %edx
    int $0x80

    mov $1, %eax
    mov $0, %ebx
    int $0x80
by Faruk CEBECI

Booting Process

by Faruk CEBECI

Everything is a File

by Faruk CEBECI

Stdout, Stdin, Stderr

by Faruk CEBECI

Pipes

by Faruk CEBECI

Signals

by Faruk CEBECI

Threads

by Faruk CEBECI

Sockets

by Faruk CEBECI

IPC

by Faruk CEBECI

Shell

by Faruk CEBECI

Shell Scripting

by Faruk CEBECI

Package Management

by Faruk CEBECI

Systemd

by Faruk CEBECI

Executables

by Faruk CEBECI

Common Commands

Command Description Example
ls List files and directories ls -lah .
cd Change directory cd /
pwd Print working directory pwd
cp Copy files cp a b
mv Move files mv a b
rm Remove files rm a
mkdir Create directory mkdir a
touch Create file touch a
cat Concatenate cat a
less View file less a
head First lines head a
tail Last lines tail a
by Faruk CEBECI

Common Commands

Command Description Example
ping Send ICMP packets ping
netstat Network statistics netstat
ifconfig Network interfaces ifconfig
route Routing table route
traceroute Trace route traceroute
dig DNS lookup dig
nslookup DNS lookup nslookup
ps List processes ps
top List processes top
htop List processes htop
kill Kill process kill
by Faruk CEBECI