Fundamentals of Linux PDF
Document Details
Uploaded by AngelicTangent8127
2020
Tags
Summary
This document provides an introduction to Linux, including key features, architecture, and directory structure.
Full Transcript
1 v1.2 Fundamentals of Linux Further information | 00 Example 2020 Trainer Name 2 v1.2 What is Linux It’s a Kernel, core of the operating system “Linux” often refers to group of operating system distributions build around the Linux...
1 v1.2 Fundamentals of Linux Further information | 00 Example 2020 Trainer Name 2 v1.2 What is Linux It’s a Kernel, core of the operating system “Linux” often refers to group of operating system distributions build around the Linux Kernel Developed by Linus Torvalds Kernel version 0.01* was released on September 1991 Major release version 1.0.0 on March 1994 Latest Kernel release version 5.8.7 (05-09-2020) source: https://github.com/kalamangga-net/linux-0.01 3 v1.2 Key Features of Linux Kernel as core component Open Source Multiuser capability and Multitasking Hierarchical File System Portable 4 v1.2 Linux Distributions 5 v1.2 The Shell Command interpreter on Linux systems The shell is not part of system kernel, but uses the system kernel to execute programs, create files etc Several Shells are available for Linux: – BASH (Bourne-Again SHell) – CSH (C SHell) – KSH (Korn SHell) – Zsh Shell Find out the Shell apnic@pod01:~$ echo $SHELL /bin/bash 6 v1.2 Linux based OS Architecture User applications (DBs, Web, Net Tools) System USER SPACE Libraries Shells Tools Daemons Shared Libraries Linux Kernel KERNEL SPACE Scheduler, Drivers, Security, Networking 7 v1.2 Directory Structure The Filesystem Hierarchy Standard (FHS) defines the directory structure and directory contents in Linux distributions In the FHS, all files and directories appear under the root directory / 8 v1.2 Directory Structure Directory Description Example / –> Root Every single file and directory starts from the root directory /bin –> Users Binaries Contains binary executables ls, ping, mv, cp /sbin –> System Binaries Contains binary executables iptables, fdisk, ifconfig like /bin /etc –> Configuration Files Contains start up and /etc/resolv.conf shutdown shell scripts used to /etc/hostname start/stop individual programs /dev –> Device Files Contains devices files /dev/tty1 /var –> Variables Files The content of the files that /var/log are expected to grow can be found under this directory 9 v1.2 Directory Structure Directory Description Example /tmp –> Temporary Files Temporary files created by system and users. /home –> Home Directories Store their personal files for all /home/apnic users /boot –> Boot Loader Files Contains bootloader related initrd.img-5.4.0-45-generic files. /opt –> Optional add-on Contains add-on applications installed under either /opt/ or Applications from individual vendors /opt/ sub-directory /mnt –> Mount Directory Temporary mount directory where sysadmins can mount filesystems 10 v1.2 Users and Groups Two types of users – System users – Regular users Super user – Also knows as root user – Has the ability to override any file ownership, permission restrictions and make system-wide changes – Just like “Administrator” in your PC – We can create user with “superuser rights” /etc/passwd list all the users and related information apnic:x:1001:1001:APNIC,,,:/home/apnic:/bin/bash 11 v1.2 Users and Groups Groups are collections of zero or more users A user belongs to a default group, and can also be a member of any of the other groups /etc/group list all the group and related information sudo:x:27:apnic apnic:x:1001: 12 v1.2 Ownership and Permissions All files and directories in Linux have a standard set of access permissions These access permissions control who can access what files Provides a fundamental level of security to the files and directories in a system Command(s) to modify ownership and permission: chown chgrp chmod 13 v1.2 Ownership and Permissions Permission Groups Permission Description Owner Permissions used by the assigned owner of the file or directory Group Permissions used by members of the group that owns the file or directory Other Permissions used by all users other than the file owner, and members of the group that owns the file or the directory 14 v1.2 Ownership and Permissions Permission Set Permission Access for File Access for a Directory Read (r) (4) File contents and copy the file List the directory contents Write (w) (2) Modify the file contents Modify the contents of a directory Execute (x) (1) Execute the file Access the directory. If read permission, will be able to list contents d rwx rwx rwx rwx } Execute Other Write Group Permissions Classes Read User File Type 15 v1.2 Ownership and Permissions We can use ls -lah command to get the list of files with details information 16 v1.2 Examples of Modes & Permissions -rw------- A file that is only accessible by its owner -rwxr-xr-x A file that is executable by every user on the system. A “world- executable” file -rw-rw-rw- A file that is open to modification by every user on the system. A “world-writable” file drwxr-xr-x A directory that every user on the system can read and access drwxrwx--- A directory that is modifiable (including its contents) by its owner and group drwxr-x--- A directory that is accessible by its group 17 v1.2 bash Scripts A Bash script is a plain text file which contains a series of commands. These commands are a mixture of commands we would normally type ourselves on the command line Anything you can run normally on the command line can be put into a script and it will do exactly the same thing Sample Bash Script: #!/bin/bash echo "Hello World" 18 v1.2 CRON – Task Schedule CRON is a task scheduler (a daemon) which runs commands at predetermined times and intervals A cron job can be used to send emails, to backup data, to update with the latest security patches, etc #.---------------- minute (0 - 59) # |.------------- hour (0 - 23) # | |.---------- day of month (1 - 31) # | | |.------- month (1 - 12) OR jan,feb,mar,apr... # | | | |.---- day of week (0 - 6) (Sunday=0 or 7) OR sun,mon,tue,wed,thu,fri,sat # | | | | | # * * * * * user-name command to be executed There are crontab syntax generators can make the job easier – https://crontab.guru/ – https://crontab-generator.org/ 19 v1.2 Text Editor(s) A text editor is a program used for editing text files Most configuration of Linux systems is done by editing text files All Linux distributions ship with multiple text editors included There are two types of text editors in Linux: – Command Line editors : vi, nano, pico – GUI editors : gedit (for GNOME), KWrite (for KDE) It’s really important to get comfortable with text editor 20 v1.2 man (manual) page A man page (short for manual page) is a form of software documentation Accessible via man command from CLI. Example: man ifconfig 21 v1.2 Thank You! 22 v1.2