THEORY TRAINING Of Operating System TUTOR: Shan Chao 01/07/2023 1/48 C ONTENTS 01 Overview of Operating System 02 Linux Operating System 01 অপারেট িং সিরেম: ওএস (OS) কম্পিউটারে চালিত সবরচর়ে গুরুত্বপূর্ ণ প্রাগ্রাম। অন্যান্য প্রাগ্রাম এবং অযালিরকশন্ চািারন্াে জন্য রলতটট কম্পিউটারে অবশযই একটট অপারেটটং লসরেম থাকরত হরব। লেরসাসগুলি ণ হ'ি ররসসে, প্মমলে, ফাইি এবং আই / ও লিভাইস। একট অপারেট িং সিরেম হ'ল ব্যব্হােকােী এব্িং মমসিরেে মরযয ম াগার উপায়। 3/48 01 একট অপারেট িং সিরেম হ'ল ব্যব্হােকােী এব্িং মমসিরেে মরযয ম াগার উপায়। 4/48 01 অপারেটটং লসরেম মযারন্জরমন্ট কাজ প্ররিিে মযারেজরমন্টঃ যা লসলপইউরত যাও়োে আরে কাজগুলি গুলির়ে োরে এবং CPU প্ত প্রের্ কোে পূরব ক ণ াজ সিন্ন কোে জন্য রস্তুত করে। মমমসে মযারেজরমন্টঃ যাে মাধ্যরম (এরিারমরিা-অযারেস প্মমলে) প্থরক প্িটা সমন্ব়ে করে এবং ভাচচণ়োি প্মমলেে রর়োজন্ী়েতা লন্ধ্াের্ ণ করে। সিভাইি মযারেজরমন্টঃ যা সংযুক্ত লিভাইসগুলিে মরধ্য প্যাোরযাে স্থাপন্ করে। মোরেজ মযারেজরমন্টঃ যা স্থা়েী প্িটা প্োরেজ পলেচািন্া করে। অযাসিরকিেঃ যা সফ্টও়েযাে এবং আপন্াে কম্পিউটারেে মরধ্য প্যাোরযারেে মাধ্যম লহরসরব কাজ করে। ইউজাে ইন্টােরেিঃ যা বযাবহােকালেরক কম্পিউটারেে সারথ প্যাোরযাে কেরত প্ে়ে। 5/48 01 অপারেট িং সিরেরমে োিংিে ১। এটট কম্পিউটােরক বুট করে ২। এটট কম্পিউটারেে প্মৌলিক কাজগুলি সিােন্ করে। ৩। এটট বযবহােকােী এবং কম্পিউটাে এে সারথ প্যাোরযাে এে মাধ্যম। ৪। এটট লবলভন্ন অযালিরকশন্ বা প্পলেরফোি লিভাইস দ্বাো কম্পিউটারেে প্মমলে এবং প্সন্ট্রাি ররসলসং ইউলন্ট (লসলপইউ) লসরেমগুলি পলেচািন্া করে। ৫। এটট ফাইি মযারন্জরমন্ট এ সহা়েতা করে। যা অপারেটটং লসরেমটট কীভারব প্িটা মযালন্পুরিট করে, সঞ্চ়ে করে, পুন্রুদ্ধাে করে এবং সংেক্ষর্ করে তা প্বাঝাা়ে। ৬। তররুটট এডারন্াে জন্য যেন্ই রর়োজন্ হ়ে এটট রলতরোধ্মূিক বযবস্থা গ্রহর্ করে। 6/48 01 অপারেট িং সিরেরমে সব্ব্র্তে কম্পিউ াে সিরেরমে সব্কাি এব্িং ব্যব্হােকােীো কীভারব্ মিগুসল ব্যব্হাে করে র্াে উপে িিূর্ তসেভতেকরে। ১৯৭০ িারলে পে os এ পসেব্র্তে 1971: Intel announces the microprocessor 1972: IBM comes out with VM: the Virtual Machine Operating System 1973: UNIX 4th Edition is published 1973: Ethernet 1974 The Personal Computer Age begins 1974: Gates and Allen wrote BASIC for the Altair 1976: Apple II August 12, 1981: IBM introduces the IBM PC 1983 Microsoft begins work on MS-Windows 1984 Apple Macintosh comes out 1990 Microsoft Windows 3.0 comes out 1991 GNU/Linux 1992 The first Windows virus comes out 1993 Windows NT 2007: iOS 7/48 2008: Android OS C ONTENTS 01 Overview of Operating System 02 Linux অপারেটটং লসরেম 02 প্বশ কর়েকটট লিন্াে লিলিলবউশন্ ের়েরি, যা সাধ্াের্ত "লিরিাস(distros)" ন্ারম পলেলচত। Linux রকােরভে •Ubuntu Linux •Red Hat Enterprise Linux •Linux Mint •Debian •Fedora 9/48 02 Hardware: Kernel: Shell: Utilities: 10/48 02 1. লিন্াে লবন্ামূরিয এবং ইন্টােরন্ট প্থরক িাউন্রিাি কো যা়ে। 2লিন্াে ন্মন্ী়ে অথাৎ ণ লিন্াে প্য প্কান্ হািণও়েযারে ইন্েি কো যা়ে। 3লিন্াে এমন্ভারব প্িরভিপ কো হর়েরি যারত এটট লেবুট ন্া করেই সব সম়ে চিরত পারে। 4লিন্ারেে জন্য বাস্তবাল়েত লন্োপত্তা মরিিটট ইউলন্রেে উপে লভলত্ত করে, এটট ইন্টােরন্ট এবং অন্যান্য আক্রমরর্ে লবরুরদ্ধও েুব লন্োপে। 5লিন্াে রর়োজন্ অন্ুযা়েী কােমাইজ কো প্যরত পারে। 11/48 02 লিন্াে মূিত সাভণারে বযবহৃত হ়ে। ইন্টােরন্রটে রা়ে 90% লিন্াে সাভণাে দ্বাো চালিত হ়ে। কাের্ লিন্াে েলতসিন্ন , লন্োপে এবং লবন্ামূরিয পাও়ো যাই ! উইরডাজ সাভণাে বযবহারেে রধ্ান্ সমসযা হি এটট বযা়েবহচি। লিন্াে সাভণাে বযবহাে করে এই সমসযাে সমাধ্ান্ কো হ়ে। লবরেে রা়ে ৮০% স্মাটণ রফারন্ প্য অপারেটটং লসরেম চরি Android। Android ও Linux Kernel প্থরক ততলে। লবরেে প্বলশেভাে ভাইোস উইরডারজ েুব সহরজ আক্রমন্ কেরত পারে, লকন্তু লিন্ারে তা সম্ভব হই ন্া! 12/48 02 File and Directory cd cat mkdir df file rmdir du find grep pwd ln tail mount mv sed rm more tar stat cp gzip ls which bzip2 umount whereis User and directory permissions Groupadd groupdel useradd userdel chown chgrp chmod passwd Network ifconfig route ping telnet dig netstat tcpdump iptables signal halt service top dd poweroff rpm Other common commands man vi date ps dmesg uptime kill exit reboot killall reboot setup mkfs export fdisk 13/48 02 pwd The “pwd” command displays the present working directory. When you first start the terminal, you are in the logged in user’s home directory, which is /home/ravi, in my case. 14/48 02 ls In order to list out the files and directories in the current working directory, we use the “ls” command. Most commands have more than one option that you can add in order to modify the behavior of the command. These options usually consists of single letters preceded by a hyphen. For example, the ls command has many options like –a, –l, –t, etc. Adding these options will bring out additional features for example, by using the –a option, all the files and directories are displayed including the hidden ones. 15/48 02 cd The cd command is used to change the working directory of the shell environment i.e. it takes you to the specified directory. For example, from the above ls command output, we have several directories in our home directory like Documents, Downloads, Music, Pictures, etc. If you want to go to Pictures, then simple enter cd Pictures The directory names are case sensitive i.e. “pictures” and “Pictures” are different. Also, if your folder name consists of any spaces, then using it directly will give you an error. For example, you have a folder named “my folder”, then you have use the following format. cd my\ folder 16/48 02 mkdir If you want to create a new directory, then use the command mkdir. For example, mkdir NewDir will create a new folder in the pwd with name NewDir. Follow the above mentioned convention if your directory name consists of any space. 17/48 02 rmdir and rm If you have an empty directory and you want to delete it, then you can use the command rmdir. If there are any files (or directories) in the directory you want to delete, then rmdir will not work and you have to use rm command. By default, the rm command will only delete the files. But if you want to remove folders which are not empty, then use the command rm –r foldername 18/48 02 man The man command is one of the very useful commands in Linux. It shows the manual pages of a command. The argument to the man command can be a program, a utility or a function. For example, if you want bring up the “man” page of ls command, simply enter man ls. To come out of the man page, you can enter q. 19/48 02 --help The --help command displays a small explanation about how to a command and also displays the list of available options. Most GNU commands support the – -help option. For example, the cd command doesn’t have a man page but for more information on the cd command, you can use the – -help option as shown below. cd --help 20/48 02 touch Every file in a Linux system is associated with a timestamp i.e. it contains the information like last access time, last modification time and last change time. But if you want to update the access or modification times of a file, then you can use the touch command. touch filename By default, the touch command will change both the access and modification timestamps if the file is already existing. If the file doesn’t exist, then touch command will create an empty file. 21/48 02 cp The cp command is used to copy files and directories through terminal. The first argument is the source of the file and the second argument is the destination to where the file (or directory) must be copied to. Eg. cp /home/file1 /tmp Single file or multiple files can be copied by adding multiple source arguments and a single destination argument. mv If you want to move or rename the files, then you can use the mv command. If both the arguments are file names, then the mv command will rename the file. But if the second argument is a directory, then the files will be moved from source to destination folder. Eg1. mv file1 file2 Eg2. mv file1 /tmp 22/48 02 cat The cat command is used to concatenate files and display the contents of a file on standard output i.e. the terminal. It is an easy way to view the contents of a file without the worry of making any changes to the file. For example, you have a simple text file called newfile.txt and to instantly view its contents, just use the cat command. 23/48 02 echo The echo command is used to display a line of text on the terminal. You can also move some text data into a file using the echo command. If you have an empty text file and want to add a line of text to it, then use echo “text to be inserted” > filename.txt. 24/48 02 df The df command or the disk free command is used to display the information about partitions and their mounted file systems (logical). Just enter the command df and the result will be details about various file systems, their sizes, used size, available size, percentage of usage and mount point. By default, the results will be displayed in KB. 25/48 02 du The du or the disk usage command is used to display the disk usage information of a file or directory. For example, if you want to know the disk usage of the Documents directory, simply enter du Documents. If the du command is followed by no options and no arguments, then it displays the information about all the directories starting from the current working directory as parent directory. 26/48 02 sudo The sudo command (short for superuser do or switch user do) allows users to execute commands with root or administrator privileges. Generally, you require root privileges to install software, make any system configurations, update the system software (like OS) etc. For example, apt-get install packagename will install the corresponding package (like python, for example) in Ubuntu. But without root privileges, this action will fail. So, you have to enter sudo aptget install python3.6 to install Python3.6 in your system. Once this command is entered, the system will ask for the user’s password and authenticate the user. su command is short for substitute user. This command is used to switch from one user to other user. 27/48 02 tar The tar command, which is short for tape archiver, is used to create, view, extract tar archives as well as various other compressed file formats like gzip, bzip2, etc. For example to archive different files as a tarball (archive created with tar), then you have use the following command. tar –cvf test.tar file1 file2 file3 The options c, v and f are used to create a .tar archive, view the progress (verbosely) and indicate that next argument is the name of the archive. To extract a .tar file, use tar –xvf test.tar. There are other options like –j for .bz2 (bzip2) archives, -z for .gz (gzip) archives, -t to view the contents of the archive, etc. 28/48 02 hostname If you want to know the system’s hostname, you can use the hostname command. Using this command, you can also set the hostname. 29/48 02 chmod Using chmod command, you can change the access permissions of a file (or a directory). But before making any changes, to view the current permissions, you can use the ls –l command. The first three values after the ‘– ‘ are permissions related to the user, the next three value are related to the group and the last three values are related to everyone else. Here, r is for read, w is for write (to modify) and x is for execute. Now to modify these permissions, you can use the chmod command. For example, you have a shell script file test.sh with current permissions as follows. If you want to modify it to user – rwx, group – r-x, others – r-x, then use the following command. chmod 755 tesh.sh Here, 755 indicates the octal values of the permissions. For user, the permissions are rwx, so 111. Its octal equivalent is 7. Similarly for the rest. 30/48 02 rm The rm command is used to delete files or directories along with the contents within them. If you only want to delete the directory — as an alternative to rmdir — use rm -r. 31/48 02 ps The full form of ps is process status. It is a command used to find information about currently running processes on Linux. ps is a very important command of Linux. User can check the UID (User ID), PID (process ID), PPID (parent process ID), CMD (command used to run the process) and some other information about all the running processes with command “ps -ef”. 32/48 02 kill The kill command is a powerful way to stop processes that are stuck due to resource constraints. As you grow your Linux system skills, you will come to know the essence and importance of this command. Often presented in lists of funny Linux commands, the kill command is as mighty as its name. The command is to kill the process with given pid. Eg. “kill 1789” killall — Kill processes by name. Eg. “killall kruler” 33/48 02 ifconfig ifconfig stands for interface configuration, and it can do many networking related things, literally. Some basic use for beginners could be like checking which network interfaces are connected and their respective IP address. Or you can find out how much data passed through a specific interface, all could be done just by running the ifconfig command. 34/48 02 ping The ping command lets you verify that you have network connectivity with another network device. It is commonly used to help troubleshoot networking issues. To use ping, provide the IP address or machine name of the other device. ping 192.168.4.18 The ping command will run until you stop it with Ctrl+C. 35/48 02 route traceroute command in Linux prints the route that a packet takes to reach the host. This command is useful when you want to know about the route and about all the hops that a packet takes. Below image depicts how traceroute command is used to reach the Google(172.217.26.206) host from the local machine and it also prints detail about all the hops that it visits in between. 36/48 02 shutdown shutdown schedules a time for the system to be powered down. reboot reboot instructs the system to restart. poweroff poweroff sends an ACPI signal which instructs the system to power down. 37/48 02 Linux has a multiuser option that means more than one user can use Linux at the same time. Managing multiple users is the job of the system administrator. System Admin can add or remove a user. So, if you are a system admin continue reading to know how to add a user to your Linux system. Two ways of adding a user in Linux From shell/terminal using “useradd” From GUI using system setting 38/48 02 1. For getting information about host, • hostname: It will display a machine hostname. • hostname -i: It will display the IP address for the current machine. 2. For knowing the connection to and fro with the host, • netstat -g: It will display all the multicast network subscribed by this network. • netstat -l: will display all listening ports. • netstat -t: will display all TCP connections. 3. To check connections with hosts and IP address if that is alive of not by sending packets, ping www.google.co.in Here, we saw 0% packet loss, which means that the connection is established and working properly. 39/48 02 4. To know current network configurations: ifconfig -a: view all configuration and settings. 5. To discover the hostname and IP address: nslookup www.google.co.in 6. To know the number of hops and response time to get to a remote system or website: traceroute www.goole.co.in 40/48 02 Process status(ps): displays all the process in execution To list all process in the background using ‘ps –f’ and to know more info on process use ‘ps -ef’ 41/48 02 Here’s an example of a list of the process using ‘ps –ef’ •First column: User Id •Second column: PID (process Id) – this is the 5-digit number assigned by OS for a process. No PID can be the same. •Third column: PPID (parent process Id) – PID of the parent process •Fourth column: CPU utilization of process •Fifth column: STIME – Process start time •Sixth column: TTY – the Terminal type associated with the process •Seventh column: CMD – the command that started that process •kill: Used to a process whose PID is known. To kill a process forcefully and unconditionally use •“kill -9 PID” 42/48 02 Five types of Process in Linux 1. Parent process: The process created by the user on the terminal. All processes have a parent process, If it was created directly by user then the parent process will be the kernel process. 2. Child process: The process created by another process (by its parent process). All child processes have a parent process. 3. Orphan process: Sometimes when the parent gets executed before its own child process then the child process becomes an orphan process. The orphan process have “Init” process (PID 0) as their PPID (parent process ID) 4. Zombie process: The processes which are already dead but shows up in process status is called Zombie process. Zombie processes have Zero CPU consumption. 5. Daemon process: These are system-related processes that run in the background. A Daemon process can be recognized if it has “?” in its TTY field (6th column) 43/48 02 A file can be created either using the command line or by using the file manager 1. Using Touch Command Syntax:$ touch filename.filetype 2. Creating File with Redirection Operator Syntax :$ > test2.txt 3. Using Cat Command to Create File Syntax:$ cat > cat.txt 4. Using Echo Command to Create File Syntax: $ echo “ Linux is simple and easy to learn” > echosample.txt 44/48 45/48