Linux Basics/The structure of Linux

From Wikibooks, open books for an open world
Jump to navigation Jump to search
  • Basically it's CLI
    • like DOS and Windows's command prompt
  • There are graphical user interfaces too (GUI)

Filesystem[edit]

FAT structure
  • There are no letters at disks, like in DOS/Windows -> Everything is under /
  • It mounts (connects) the external storages
    • Nowadays Windows is also capable of it
    • The /etc/fstab file contains the automatical mount point of partitions and settings associated with them.
    • fdisk or fdisk -l commands, latter one lists the partitions.
    • Under /mnt we can find the mounted mediums (but that's not true mostly because in modern partitions the automatically mounted mediums like flash drives usually get mounted to /media, but that's true that /mnt is created to mount partitions there)
EXT structure

FAT-table contains entries for every cluster on a continuous area of the medium. Every entry contains the next cluster's number in a file or the EOF (end of file), unused disk space and the specially reserved space of the disk. It only can do soft-link.

EXT filesystem: It uses inode(Index node) table. In inode there are the files' description and the place of the data blocks, wihtout filename. There is only one inode for each file. Files with bigger size may contain multiple catalog-entries, which contains the filename. Inode contains the name, description, creation date, permissions, owner(UID), group(GID), and how many links are attached to it. (so it can do much more than FAT) It can do soft-link and hard-link, which is one of the biggest advantage of EXT file system to FAT.

  • Soft-link: shortcut, if the original gets deleted, then it deletes itself, or it says error that it doesn't find the executable.
  • Hard-link: A copy of the file, but if we change the original one, then the content of the copy changes, but the file will only disappear eventually, if all the copies are deleted.

Properties of filesystem[edit]

  • It attaches permissions separately to every file
  • It limits permission to the owner or groups
  • Read, write, execute permissions

File managers[edit]

Midnight Commander under Fedora 29.

Kernel[edit]

Kernel = system core, the "soul" of the OS

Tasks of it: handling peripherals, handling filesystem, implementing directory structure, taking control of processor

Types of kernels:

  • Monolithic: The kernel consists of one unbreakable unit module. It's common for older Linuxes (older than 2.0) and UNIX systems.
  • Hybrid: like Windows – permissions can be set. Hybrid kernels are basically microkernels in which some "not important" code parts have been moved from user level (userspace) to kernel level (kernelspace) using fewer abstractions to run faster.
  • Microkernel: Kernel is in multiple small programs, not in one big module.
  • Modular: The modular kernel tries to fix the monolithic kernel's problems. Parts of the kernel - physical and logical - and modules created by this, which are mostly drivers can be loaded into memory. It saves the size of the kernel, but both together becomes bigger and bigger (its size is relative though, it depends how many drivers do you want to add, complete kernels are mostly around 100 MB or above, but if you are minimalist, it can be under 10 MB). We put modern Linux systems under the modular term (to be punctual, Linux kernel is monolithical modular). The kernel modules can be found in /lib/modules/kernel-version folder.

Place of kernel: It's in the /boot folder, and there are soft-links to vmlinuz and initrd in the root.

Filesystems[edit]

At filesystems arrays have huge role in Linux.

Virtual filesystems (for the system)

  • SMBFS, SSHFS, NFS, etc.

Supported filesystems:

  • ext2, ext3, ext4 (own filesystem of Linux)
  • ReiserFS, Btrfs, ZFS, XFS
  • FAT32, NTFS
  • stb.

Directory structure[edit]

  • Hierarchical
    • directories (folders)
    • files

Single-level directory: Commodore floppy; magnetic tape

  • Path
    • Root: /
    • e.g.: /home/joe/myfile.txt
  • Connected (mounted) media
    • e.g. /mnt/usb
  • Mounting:
    • mount /dev/scd -t ISO9660 /mnt/cdrom (if we want to use CD-ROM)
    • mount /dev/sdb -ta /mnt/[name], where -ta indicates automatic detection of the media's type.
    • The sda,sdb, sdc… indicates the HDD,SSDs, and modern distros mount them to /media/[partition name].
  • Unmount / disconnect: umount /dev/sdb

Main folders[edit]

  • /bin, /sbin
    • executable, binary files (only admin can run sbin programs), no file extension needed
  • /boot
    • system startup files: GRUB, LILO, kernel (/boot/vmlinuz)
  • /cdrom, /media, /mnt
    • media mounting: USB, Floppy, CD/DVD
  • /dev
    • we can reach the devices through files e.g.: /dev/dsp (soundcard) /dev/cdrom (CD) /dev/sda2 (first HDD/SSD's 2nd partition)
  • /etc
    • configuration file
    • sysadmin has only access to it
    • global configuration folder
  • /home
    • users' folder
    • user's files
    • settings, configuration files, folders
    • for eg.: /home/peter /home/peter/documents
  • /lib
    • shared objects, libraries
    • like DLL files in Windows
    • kernel modules
  • /lost+found
    • damaged files
    • recoverables
  • /proc
    • currently running operations - numbered by files and informations of the system(processor, memory etc)
    • example command (processor information): cat /proc/cpuinfo
  • /tmp
    • location of temporary files
    • both system and user level
  • /usr
    • location of user files
    • programok installed programs
    • libraries
    • sources (kernel): /usr/src
    • documentations: /usr/share/doc, /usr/doc
    • icons, and so on.
  • /var
    • collection of services
    • cache(temporary storage): /var/cache
    • log files: /var/log/maillog
    • email accounts (mailbox): /var/mail/root
    • www folder: the default webpage folder of apache (/var/www)

Users[edit]

  • system administrator: root
  • users: „root” user creates them basically
  • users can be grouped
  • permissions can be given in the filesystem
    • e.g.: /home/joe/myfile.txt 26 joe joe -rwxrwxrwx
  • The first user has also root permissions (which you set in the installation) - but this depends on distribution, e.g. Debian users have no root permission by default, and there is no sudo.