Skip to content
DBDeependra Bhatta~/notes
Linux#virtualbox · #bash · #ssh · #linux

Introduction to Linux: Kernel, Shell, File System and SSH Login

The Linux foundations behind DevOps work: kernel and shell, distributions, the directory layout, the seven file types, and SSH login to a VirtualBox VM.

· updated · 7 min read
ON THIS PAGE

Docker, Jenkins, Kubernetes and Ansible all run on Linux servers, so every DevOps workflow eventually depends on reading a Linux system correctly. This first part of the series explains how the kernel and shell divide the work, where files live in the directory tree, which file types exist, and how to open an SSH session to a VirtualBox VM.

What Linux is

An operating system (OS) is the software layer between you and the hardware. It manages the processor, memory, disks and input/output devices, so programs do not have to talk to the hardware directly.

A few design principles explain most of Linux's behaviour:

  • Everything is a file, including hardware devices (for example a disk is /dev/sda).
  • Configuration lives in plain text files, mostly under /etc, so you can edit, copy and version it.
  • Small programs that do one job are combined with pipes to solve bigger tasks.
  • It is open source, free to use, and backed by a large community. Most servers, cloud VMs and containers run Linux.

Architecture: hardware, kernel, shell, applications

Layered diagram with hardware at the centre, then kernel, shell, and applications such as vi, grep and date on the outside

Linux is built in layers:

  • Kernel: the core of the OS. It controls the hardware and lets applications use it (memory, CPU scheduling, devices, file systems).
  • Shell: a command-line interpreter. It reads what you type, asks the kernel to do the work, and prints the result. Common shells are bash, zsh, sh, ksh and tcsh. A shell starts when you log in or open a terminal.
  • Applications and commands: programs such as vi, grep and date that run on top.

Key terms

TermWhat it meansExamples
Distribution (distro)The Linux kernel plus tools, a package manager and defaultsUbuntu, Debian, Red Hat Enterprise Linux, Fedora, CentOS Stream, SUSE, Kali
Boot loaderProgram that loads the kernel when the machine startsGRUB, ISOLINUX
Service (daemon)Program that runs in the backgroundsshd, httpd, nfsd
File systemMethod used to store and organise files on a diskext4, XFS, FAT, NTFS
X Window SystemBase layer for graphical interfaces on LinuxX11 (Wayland is the newer replacement)
Desktop environmentFull graphical interface on top of the OSGNOME, KDE, Xfce

The examples in this series use Ubuntu, a Debian-based distro. It is well documented and available as an image on every major cloud provider, including Amazon EC2.

The Linux directory structure

Everything starts at the root directory /. Linux has no drive letters like C:; additional disks are mounted into directories inside this tree. The directories below come up most often in server work:

DirectoryWhat it holdsExamples
/Root of the whole tree. Only root can write here
/rootHome directory of the root user (not the same as /)
/homeHome directories of normal users/home/deependra
/bin, /usr/binCommands for all usersls, cp, grep, ping
/sbin, /usr/sbinCommands for system administrationfdisk, reboot, useradd, sshd
/etcSystem and application configuration files/etc/passwd, /etc/resolv.conf
/varData that grows: logs, caches, mail, spools/var/log/syslog, /var/lib
/tmpTemporary files, usually cleared on reboot
/usrInstalled programs, libraries and documentation/usr/lib, /usr/local (software built from source)
/optOptional third-party applications/opt/apache-tomcat
/bootKernel, initrd and GRUB filesvmlinuz-*, initrd.img-*
/libShared libraries for the programs in /bin and /sbinlibc.so.6
/devDevice files/dev/sda, /dev/tty1
/procVirtual files with live kernel and process information/proc/uptime, /proc/<pid>/
/mnt, /mediaMount points for extra disks and removable media/media/cdrom
/srvData served by the system, such as website files/srv/www

The seven Linux file types

The first character of ls -l output shows the file type:

SymbolTypeWhat it is
-Regular fileText, scripts, binaries, images
dDirectoryA folder that contains other files
lSymbolic linkA pointer to another file
cCharacter deviceDevice that sends data one character at a time, such as a terminal
bBlock deviceDevice that reads and writes data in blocks, such as a disk
sSocketEndpoint for communication between processes
pNamed pipe (FIFO)Connects the output of one process to the input of another

List files of each type with these commands:

terminal
$ ls -l /dev | grep "^c"
$ ls -l /dev | grep "^b"
$ ls -l /dev | grep "^l"
$ sudo find / -type s -ls
$ sudo find / -type p -ls
$ sudo find / -type l -ls | less

grep "^c" keeps only lines that start with c. find -type searches by file type. Both commands are covered in Essential Linux Commands for DevOps.

Logging in from a terminal

After you enter your username and password, the shell shows a prompt. The last character tells you who you are:

TXTPlain text
[dipen@example.com ~]$     normal user
[root@example.com ~]#      root user

To log out, type exit or press Ctrl+D.

Remote login to a VM over SSH

SSH (Secure Shell) opens an encrypted terminal on another machine. In my lab, it replaced the VirtualBox console window: the Ubuntu VM was managed from PowerShell on the host laptop.

  1. Set the VM network to Bridged Adapter. VirtualBox uses NAT by default. With NAT the VM gets a private address (usually 10.0.2.15) that the host cannot reach directly. With a bridged adapter, the VM gets an address on the host's local network.

  2. Find the VM's IP address inside the VM:

    terminal
    $ ip -4 addr show
  3. Confirm the SSH server is running in the VM. On Ubuntu the service is called ssh:

    terminal
    $ sudo systemctl is-active ssh
    $ sudo systemctl start ssh
    $ sudo systemctl status ssh

    If the service does not exist, install it with sudo apt install openssh-server.

  4. Connect from the other machine (PowerShell, a Linux terminal or macOS Terminal) and enter the VM user's password when asked:

    terminal
    $ ssh username@192.168.1.50

    Replace username with the user on the VM and the IP with the address from step 2.

Key takeaways

  • The kernel controls the hardware; the shell passes your commands to the kernel.
  • Everything in Linux is a file, and configuration is plain text under /etc.
  • Logs go to /var/log, third-party apps to /opt, user files to /home.
  • The first character of ls -l tells you the file type.
  • To SSH into a VirtualBox VM, use a bridged adapter (or NAT with port forwarding) and make sure ssh is running.

Next in this series: Essential Linux Commands for DevOps.