Summary

This document provides an introduction to operating systems. It covers their functions and types. Including resource management, process management, and security, and other aspects. The text describes the role of an operating system as a vital part of any computer system, with an emphasis on concepts like user interface and system calls.

Full Transcript

INTRODUCTION: WHAT IS AN OPERATING SYSTEM Operating System a type of system software. It basically manages all the resources of the computer. An operating system acts as an interface between the software and different parts of the computer or the computer hardware. The operating system is designed...

INTRODUCTION: WHAT IS AN OPERATING SYSTEM Operating System a type of system software. It basically manages all the resources of the computer. An operating system acts as an interface between the software and different parts of the computer or the computer hardware. The operating system is designed in such a way that it can manage the overall resources and operations of the computer. Operating System is a fully integrated set of specialized programs that handle all the operations of the computer. It controls and monitors the execution of all other programs that reside in the computer, which also includes application programs and other system software of the computer. Examples of Operating Systems are Windows, Linux, Mac OS, etc. An Operating System (OS) is a collection of software that manages computer hardware resources and provides common services for computer programs. In this article we will see basic of operating system in detail. WHAT IS THE OPERATING SYSTEM IS USED FOR? The operating system helps in improving the computer software as well as hardware. Without OS, it became very difficult for any application to be user-friendly. The Operating System provides a user with an interface that makes any application attractive and user-friendly. The operating System comes with a large number of device drivers that make OS services reachable to the hardware environment. Each and every application present in the system requires the Operating System. The operating system works as a communication channel between system hardware and system software. The operating system helps an application with the hardware part without knowing about the actual hardware configuration. It is one of the most important parts of the system and hence it is present in every device, whether large or small device. FUNCTIONS OF THE OPERATING SYSTEM Resource Management: The operating system manages and allocates memory, CPU time, and other hardware resources among the various programs and processes running on the computer. Process Management: The operating system is responsible for starting, stopping, and managing processes and programs. It also controls the scheduling of processes and allocates resources to them. Memory Management: The operating system manages the computer’s primary memory and provides mechanisms for optimizing memory usage. Security: The operating system provides a secure environment for the user, applications, and data by implementing security policies and mechanisms such as access controls and encryption. Job Accounting: It keeps track of time and resources used by various jobs or users. File Management: The operating system is responsible for organizing and managing the file system, including the creation, deletion, and manipulation of files and directories. Device Management: The operating system manages input/output devices such as printers, keyboards, mice, and displays. It provides the necessary drivers and interfaces to enable communication between the devices and the computer. Networking: The operating system provides networking capabilities such as establishing and managing network connections, handling network protocols, and sharing resources such as printers and files over a network. User Interface: The operating system provides a user interface that enables users to interact with the computer system. This can be a Graphical User Interface (GUI), a Command-Line Interface (CLI), or a combination of both. Backup and Recovery: The operating system provides mechanisms for backing up data and recovering it in case of system failures, errors, or disasters. Virtualization: The operating system provides virtualization capabilities that allow multiple operating systems or applications to run on a single physical machine. This can enable efficient use of resources and flexibility in managing workloads. Performance Monitoring: The operating system provides tools for monitoring and optimizing system performance, including identifying bottlenecks, optimizing resource usage, and analyzing system logs and metrics. Time-Sharing: The operating system enables multiple users to share a computer system and its resources simultaneously by providing time-sharing mechanisms that allocate resources fairly and efficiently. System Calls: The operating system provides a set of system calls that enable applications to interact with the operating system and access its resources. System calls provide a standardized interface between applications and the operating system, enabling portability and compatibility across different hardware and software platforms. Error-detecting Aids: These contain methods that include the error messages, and other debugging and error-detecting methods. OBJECTIVES OF OPERATING SYSTEM Convenient to use: One of the objectives is to make the computer system more convenient to use in an efficient manner. User Friendly: To make the computer system more interactive with a more convenient interface for the users. Easy Access: To provide easy access to users for using resources by acting as an intermediary between the hardware and its users. Management of Resources: For managing the resources of a computer in a better and faster way. Controls and Monitoring: By keeping track of who is using which resource, granting resource requests, and mediating conflicting requests from different programs and users. Fair Sharing of Resources: Providing efficient and fair sharing of resources between the users and programs. TYPES OF OPERATING SYSTEM 1. Batch Operating System In the 1970s, Batch processing was very popular. In this technique, similar types of jobs were batched together and executed in time. People were used to having a single computer which was called a mainframe. In Batch operating system, access is given to more than one person; they submit their respective jobs to the system for the execution. The system put all of the jobs in a queue on the basis of first come first serve and then executes the jobs one by one. The users collect their respective output when all the jobs get executed. The purpose of this operating system was mainly to transfer control from one job to another as soon as the job was completed. It contained a small set of programs called the resident monitor that always resided in one part of the main memory. The remaining part is used for servicing jobs. Advantages of Batch OS o The use of a resident monitor improves computer efficiency as it eliminates CPU time between two jobs. Disadvantages of Batch OS 1. Starvation Batch processing suffers from starvation. For Example: There are five jobs J1, J2, J3, J4, and J5, present in the batch. If the execution time of J1 is very high, then the other four jobs will never be executed, or they will have to wait for a very long time. Hence the other processes get starved. 2. Not Interactive Batch Processing is not suitable for jobs that are dependent on the user's input. If a job requires the input of two numbers from the console, then it will never get it in the batch processing scenario since the user is not present at the time of execution. 2. Multiprogramming Operating System Multiprogramming is an extension to batch processing where the CPU is always kept busy. Each process needs two types of system time: CPU time and IO time. In a multiprogramming environment, when a process does its I/O, The CPU can start the execution of other processes. Therefore, multiprogramming improves the efficiency of the system. Advantages of Multiprogramming OS o Throughout the system, it increased as the CPU always had one program to execute. o Response time can also be reduced. Disadvantages of Multiprogramming OS o Multiprogramming systems provide an environment in which various systems resources are used efficiently, but they do not provide any user interaction with the computer system. 3. Multiprocessing Operating System In Multiprocessing, Parallel computing is achieved. There are more than one processors present in the system which can execute more than one process at the same time. This will increase the throughput of the system. In Multiprocessing, Parallel computing is achieved. More than one processor present in the system can execute more than one process simultaneously, which will increase the throughput of the system. Advantages of Multiprocessing operating system: o Increased reliability: Due to the multiprocessing system, processing tasks can be distributed among several processors. This increases reliability as if one processor fails, the task can be given to another processor for completion. o Increased throughout: As several processors increase, more work can be done in less. Disadvantages of Multiprocessing operating System o Multiprocessing operating system is more complex and sophisticated as it takes care of multiple CPUs simultaneously. 4. Multitasking Operating System The multitasking operating system is a logical extension of a multiprogramming system that enables multiple programs simultaneously. It allows a user to perform more than one computer task at the same time. Advantages of Multitasking operating system o This operating system is more suited to supporting multiple users simultaneously. o The multitasking operating systems have well-defined memory management. Disadvantages of Multitasking operating system o The multiple processors are busier at the same time to complete any task in a multitasking environment, so the CPU generates more heat. 5. Network Operating System An Operating system, which includes software and associated protocols to communicate with other computers via a network conveniently and cost-effectively, is called Network Operating System. Advantages of Network Operating System o In this type of operating system, network traffic reduces due to the division between clients and the server. o This type of system is less expensive to set up and maintain. Disadvantages of Network Operating System o In this type of operating system, the failure of any node in a system affects the whole system. o Security and performance are important issues. So trained network administrators are required for network administration. 6. Real Time Operating System In Real-Time Systems, each job carries a certain deadline within which the job is supposed to be completed, otherwise, the huge loss will be there, or even if the result is produced, it will be completely useless. The Application of a Real-Time system exists in the case of military applications, if you want to drop a missile, then the missile is supposed to be dropped with a certain precision. Advantages of Real-time operating system: o Easy to layout, develop and execute real-time applications under the real-time operating system. o In a Real-time operating system, the maximum utilization of devices and systems. Disadvantages of Real-time operating system: o Real-time operating systems are very costly to develop. o Real-time operating systems are very complex and can consume critical CPU cycles. 7. Time-Sharing Operating System In the Time Sharing operating system, computer resources are allocated in a time-dependent fashion to several programs simultaneously. Thus it helps to provide a large number of user's direct access to the main computer. It is a logical extension of multiprogramming. In time-sharing, the CPU is switched among multiple programs given by different users on a scheduled basis. A time-sharing operating system allows many users to be served simultaneously, so sophisticated CPU scheduling schemes and Input/output management are required. Time-sharing operating systems are very difficult and expensive to build. Advantages of Time Sharing Operating System o The time-sharing operating system provides effective utilization and sharing of resources. o This system reduces CPU idle and response time. Disadvantages of Time Sharing Operating System o Data transmission rates are very high in comparison to other methods. o Security and integrity of user programs loaded in memory and data need to be maintained as many users access the system at the same time. 8. Distributed Operating System The Distributed Operating system is not installed on a single machine, it is divided into parts, and these parts are loaded on different machines. A part of the distributed Operating system is installed on each machine to make their communication possible. Distributed Operating systems are much more complex, large, and sophisticated than Network operating systems because they also have to take care of varying networking protocols. Advantages of Distributed Operating System o The distributed operating system provides sharing of resources. o This type of system is fault-tolerant. Disadvantages of Distributed Operating System o Protocol overhead can dominate computation cost. ARCHITETURE OF LINUX Linux operating system history In 1991, the Linux history started with the starting of a particular project by the Finland student Linus Torvalds for creating a new free OS kernel. The final Linux Kernel was remarked by continuous development throughout the history since then. o Linux was proposed by the Finland student Linus Torvalds in 1991. o HP-UX (Hewlett Packard) 8.0 version was published. o Hewlett Packard 9.0 version was published in 1992. o FreeBSD 1.0 version and NetBSD8 version was released in 1993. o Red Hat Linux was proposed in 1994. Caldera was detected by Ransom love and Bryan Sparks and NetBSD 1.0 version published. o HP-UX 10.0 version and FreeBSD 2.0 version was released in 1995. o K Desktop Environment was established by Matthias Ettrich in 1996. o HP-UX 11.0 version was released in 1997. o The IRIX 6.5 version, i.e., the fifth SGI UNIX generation, Free BSD 3.0 version, and Sun Solaris 7 OS was released in 1998. o The Caldera System agreement with professional services division and SCO server software division was released in 2000. o Linus Torvalds published the Linux version 2.4 source code in 2001. o Microsoft filed the Trademark collection against Lindows.com in 2001. o Lindows name was modified to Linspire in 2004. o The first publication of Ubuntu was published in 2004. o The openSUSE project started a free distribution from the community of Novell In 2005. o Oracle published its Red Hat distribution in 2006. o Dell begun laptop distribution with Ubuntu which was pre-installed on it in 2007. o Linux kernel version 3.0 was released in 2011. o Linux-based android of Google insisted 75% of the market share of the Smartphone, based on the number of phones exported in 2013. o Ubuntu insisted on 20000000+ users in 2014. Architecture of Linux system The Linux operating system's architecture mainly contains some of the components: the Kernel, System Library, Hardware layer, System, and Shell utility. 1. Kernel:- The kernel is one of the core section of an operating system. It is responsible for each of the major actions of the Linux OS. This operating system contains distinct types of modules and cooperates with underlying hardware directly. The kernel facilitates required abstraction for hiding details of low-level hardware or application programs to the system. There are some of the important kernel types which are mentioned below: o Monolithic Kernel o Micro kernels o Exo kernels o Hybrid kernels 2. System Libraries:- These libraries can be specified as some special functions. These are applied for implementing the operating system's functionality and don't need code access rights of the modules of kernel. 3. System Utility Programs:- It is responsible for doing specialized level and individual activities. 4. Hardware layer:- Linux operating system contains a hardware layer that consists of several peripheral devices like CPU, HDD, and RAM. 5. Shell:- It is an interface among the kernel and user. It can afford the services of kernel. It can take commands through the user and runs the functions of the kernel. The shell is available in distinct types of OSes. These operating systems are categorized into two different types, which are the graphical shells and command-line shells. The graphical line shells facilitate the graphical user interface, while the command line shells facilitate the command line interface. Thus, both of these shells implement operations. However, the graphical user interface shells work slower as compared to the command-line interface shells. There are a few types of these shells which are categorized as follows: o Korn shell o Bourne shell o C shell o POSIX shell Linux Operating System Features Some of the primary features of Linux OS are as follows: o Portable: Linux OS can perform different types of hardware and the kernel of Linux supports the installation of any type of hardware environment. o Open source: Linux operating system source code is available freely and for enhancing the capability of the Linux OS, several teams are performing in collaboration. o Multiprogramming: Linux OS can be defined as a multiprogramming system. It means more than one application can be executed at the same time. o Multi-user: Linux OS can also be defined as a multi-user system. It means more than one user can use the resources of the system such as application programs, memory, or RAM at the same time. o Hierarchical file system: Linux OS affords a typical file structure where user files or system files are arranged. o Security: Linux OS facilitates user security systems with the help of various features of authentication such as controlled access to specific files, password protection, or data encryption. o Shell: Linux operating system facilitates a unique interpreter program. This type of program can be applied for executing commands of the operating system. It can be applied to perform various types of tasks such as call application programs and others. Drawbacks of Linux o Hardware drivers: Most of the users of Linux face an issue while using Linux. Various companies of hardware prefer to build drivers for Mac or Windows due to they contain several users than Linux. Linux has small drivers for peripheral hardware than windows. o Software alternative: Let's take the Photoshop example which is a famous tool for graphic editing. Photoshop exists for Windows; however, it is not available in Linux. Also, there are some other tools for photo editing but the Photoshop tool is more powerful as compare to others. Another example is MS office which is not present for Linux users. o Learning curve: Linux isn't a very user-friendly operating system. Hence, it might be confusing for many beginners. Getting begun with Windows is efficient and easy for many beginners; however, understanding Linux working is complex. We have to understand the command line interface and finding for newer software is a little bit complex as well. When we face any issue in the OS, the searching solution is very problematic. Also, there are various experts for Mac and Windows as compare to Linux. o Games: Several games are developed for Windows but unfortunately not for Linux. Because the platform of Windows is used widely. So, the developers of the games are more interested in windows. User mode vs Kernel mode o The code of kernel component runs in a unique privilege mood known as kernel mode along with complete access to every computer resource. This code illustrates an individual process, runs in an individual address space, and don't need the context switch. Hence, it is very fast and efficient. o Kernel executes all the processes and facilitates various services of a system to the processes. Also, it facilitates secured access to processes to hardware. o The support code that is not needed to execute in kernel mode is inside the system library. The user programs and other types of system programs are implemented in the user mode. o It includes no access to kernel mode and system hardware. User utilities/programs use the system libraries for accessing kernel functions to obtain low-level tasks of the system. LINUX FILE HIERARCHY The Linux File Hierarchy Structure or the Filesystem Hierarchy Standard (FHS) defines the directory structure and directory contents in Unix-like operating systems. It is maintained by the Linux Foundation. In the FHS, all files and directories appear under the root directory /, even if they are stored on different physical or virtual devices. Some of these directories only exist on a particular system if certain subsystems, such as the X Window System, are installed. Most of these directories exist in all UNIX operating systems and are generally used in much the same way; however, the descriptions here are those used specifically for the FHS and are not considered authoritative for platforms other than Linux. 1. / (Root): Primary hierarchy root and root directory of the entire file system hierarchy. Every single file and directory start from the root directory. The only root user has the right to write under this directory. /root is the root user’s home directory, which is not the same as / 2. /bin : Essential command binaries that need to be available in single-user mode; for all users, e.g., cat, ls, cp. Contains binary executables. Common linux commands you need to use in single-user modes are located under this directory. Commands used by all the users of the system are located here e.g. ps, ls, ping, grep, cp 3. /boot : Boot loader files, e.g., kernels, initrd. Kernel initrd, vmlinux, grub files are located under /boot Example: initrd.img-2.6.32-24-generic, vmlinuz-2.6.32-24-generic 4. /dev : Essential device files, e.g., /dev/null. These include terminal devices, usb, or any device attached to the system. Example: /dev/tty1, /dev/usbmon0 5. /etc : Host-specific system-wide configuration files. Contains configuration files required by all programs. This also contains startup and shutdown shell scripts used to start/stop individual programs. Example: /etc/resolv.conf, /etc/logrotate.conf. 6. /home : Users’ home directories, containing saved files, personal settings, etc. Home directories for all users to store their personal files. example: /home/kishlay, /home/kv 7. /lib: Libraries essential for the binaries in /bin/ and /sbin/. Library filenames are either ld* or lib*.so.* Example: ld-2.11.1.so, libncurses.so.5.7 8. /media: Mount points for removable media such as CD-ROMs (appeared in FHS-2.3). Temporary mount directory for removable devices. Examples, /media/cdrom for CD-ROM; /media/floppy for floppy drives; /media/cdrecorder for CD writer 9. /mnt : Temporarily mounted filesystems. Temporary mount directory where sysadmins can mount filesystems. 10. /opt : Optional application software packages. Contains add-on applications from individual vendors. Add-on applications should be installed under either /opt/ or /opt/ sub-directory. 11. /sbin : Essential system binaries, e.g., fsck, init, route. Just like /bin, /sbin also contains binary executables. The linux commands located under this directory are used typically by system administrators, for system maintenance purposes. Example: iptables, reboot, fdisk, ifconfig, swapon 12. /srv : Site-specific data served by this system, such as data and scripts for web servers, data offered by FTP servers, and repositories for version control systems. srv stands for service. Contains server specific services related data. Example, /srv/cvs contains CVS related data. 13. /tmp : Temporary files. Often not preserved between system reboots and may be severely size restricted. Directory that contains temporary files created by system and users. Files under this directory are deleted when the system is rebooted. 14. /usr : Secondary hierarchy for read-only user data; contains the majority of (multi-)user utilities and applications. Contains binaries, libraries, documentation, and source-code for second level programs. /usr/bin contains binary files for user programs. If you can’t find a user binary under /bin, look under /usr/bin. For example: at, awk, cc, less, scp /usr/sbin contains binary files for system administrators. If you can’t find a system binary under /sbin, look under /usr/sbin. For example: atd, cron, sshd, useradd, userdel /usr/lib contains libraries for /usr/bin and /usr/sbin /usr/local contains user’s programs that you install from source. For example, when you install apache from source, it goes under /usr/local/apache2 /usr/src holds the Linux kernel sources, header-files and documentation. 15. /proc: Virtual filesystem providing process and kernel information as files. In Linux, it corresponds to a procs mount. Generally, automatically generated and populated by the system, on the fly. Contains information about system process. This is a pseudo filesystem that contains information about running processes. For example: /proc/{pid} directory contains information about the process with that particular pid. This is a virtual filesystem with text information about system resources. For example: /proc/uptime LINUX DIRECTORY STUCTURE In Linux/Unix operating system everything is a file even directories are files, files are files, and devices like mouse, keyboard, printer, etc are also files. Here we are going to see the Directory Structure in Linux. Types of files in the Linux system. 1. General Files – It is also called ordinary files. It may be an image, video, program, or simple text file. These types of files can be in ASCII or Binary format. It is the most commonly used file in the Linux system. 2. Directory Files – These types of files are a warehouse for other file types. It may be a directory file within a directory (subdirectory). 3. Device Files – In a Windows-like operating system, devices like CD-ROM, and hard drives are represented as drive letters like F: G: H whereas in the Linux system devices are represented as files. As for example, /dev/sda1, /dev/sda2, and so on. We know that in a Windows-like operating system, files are stored in different folders on different data drives like C: D: E: whereas in the Linux/Unix operating system files are stored in a tree-like structure starting with the root directory as shown in the below diagram. The Linux/Unix file system hierarchy base begins at the root and everything starts with the root directory. These are the common top-level directories associated with the root directory: Directories Description /bin binary or executable programs. /etc system configuration files. /home home directory. It is the default current directory. /opt optional or third-party software. /tmp temporary space, typically cleared on reboot. /usr User related programs. Directories Description /var log files. Some other directories in the Linux system: Directories Description /boot It contains all the boot-related information files and folders such as conf, grub, etc. /dev It is the location of the device files such as dev/sda1, dev/sda2, etc. /lib It contains kernel modules and a shared library. /lost+found It is used to find recovered bits of corrupted files. /media It contains subdirectories where removal media devices are inserted. /mnt It contains temporary mount directories for mounting the file system. It is a virtual and pseudo-file system to contains info about the running processes /proc with a specific process ID or PID. /run It stores volatile runtime data. /sbin binary executable programs for an administrator. /srv It contains server-specific and server-related files. It is a virtual file system for modern Linux distributions to store and allows /sys modification of the devices connected to the system. Exploring directories and their usability: We know that Linux is a very complex system that requires an efficient way to start, stop, maintain and reboot a system, unlike Windows operating system. In the Linux system some well-defined configuration files, binaries, main pages information files are available for every process. Linux Kernel File: /boot/vmlinux – The Linux kernel file. Device Files: /dev/hda – Device file for the first IDE HDD. /dev/hdc – A pseudo-device that output garbage output is redirected to /dev/null. System Configuration Files: Configuration Files Description /etc/bashrc It is used by bash shell that contains system defaults and aliases. /etc/crontab A shell script to run specified commands on a predefined time interval. /etc/exports It contains information on the file system available on the network. /etc/fstab Information of the Disk Drive and their mount point. /etc/group It is a text file to define Information of Security Group. /etc/grub.conf It is the grub bootloader configuration file. /etc/init.d Service startup Script. /etc/lilo.conf It contains lilo bootloader configuration file. /etc/hosts Information of IP and corresponding hostnames /etc/hosts.allow It contains a list of hosts allowed accessing services on the local machine. Configuration Files Description /etc/host.deny List of hosts denied accessing services on the local machine. /etc/inittab INIT process and their interaction at the various run levels. /etc/issue Allows editing the pre-login message. /etc/modules.conf It contains the configuration files for the system modules. /etc/motd It contains the message of the day. /etc/mtab Currently mounted blocks information. /etc/passwd It contains username, password of the system, users in a shadow file. /etc/printcap It contains printer Information. /etc/profile Bash shell defaults. /etc/profile.d It contains other scripts like application scripts, executed after login. /etc/rc.d It avoids script duplication. /etc/rc.d/init.d Run Level Initialisation Script. /etc/resolv.conf DNS being used by System. /etc/security It contains the name of terminals where root login is possible. /etc/skel Script that initiates new user home directory. Configuration Files Description /etc/termcap An ASCII file that defines the behavior of different types of the terminal. /etc/X11 Directory tree contains all the conf files for the X-window System. User Related Files: User Related Files Descriptions /usr/bin It contains most of the executable files. /usr/bin/X11 Symbolic link of /usr/bin. /usr/include It contains standard files used by C program. /usr/share It contains architecture independent shareable text files. /usr/lib It contains object files and libraries. /usr/sbin It contains commands for Super User, for System Administration. Virtual and Pseudo Process Related Files: Virtual and Pseudo Process Related Files Descriptions /proc/cpuinfo CPU Information It keeps useful info about the processes that are currently /proc/filesystems running. it keeps the information about the number of interrupts /proc/interrupts per IRQ. Virtual and Pseudo Process Related Files Descriptions Contains all the Input and Output addresses used by devices /proc/ioports on the server /proc/meminfo It reports the memory usage information. /proc/modules Currently using kernel module. /proc/mount Mounted File-system Information. /proc/stat It displays the detailed statistics of the current system. /proc/swaps It contains swap file information. Version Information File: /version – It displays the Linux version information. Log Files: Log Files Descriptions /var/log/lastlog It stores user’s last login info. /var/log/messages It has all the global system messages /var/log/wtmp It keeps a history of login and logout information. Modes of Operation in the vi editor There are three modes of operation in vi: Here are three modes of operations on the vi editor Vi Command Mode : When vi starts up, it is in Command Mode. This mode is where vi interprets any characters we type as commands and thus does not display them in the window. This mode allows us to move through a file, and delete, copy, or paste a piece of text. Enter into Command Mode from any other mode, requires pressing the [Esc] key. If we press [Esc] when we are already in Command Mode, then vi will beep or flash the screen. Vi Insert mode: This mode enables you to insert text into the file. Everything that’s typed in this mode is interpreted as input and finally, it is put in the file. The vi always starts in command mode. To enter text, you must be in insert mode. To come in insert mode, you simply type i. To get out of insert mode, press the Esc key, which will put you back into command mode. Vi Last Line Mode (Escape Mode): Line Mode is invoked by typing a colon [:], while vi is in Command Mode. The cursor will jump to the last line of the screen and vi will wait for a command. This mode enables you to perform tasks such as saving files and executing commands. HOW TO WRITE, SAVE, EXECUTE A SHELL SCRIPT IN VI EDITOR 1. Open the vi editor Open a terminal and type: bash Copy code vi script_name.sh Replace script_name.sh with your desired file name. The.sh extension is conventional for shell scripts. 2. Write your script Press i to enter Insert mode in vi. Write your shell script. For example: bash Copy code #!/bin/bash echo "Hello, World!" 3. Save the script Press Esc to exit Insert mode. Type :wq and press Enter to write (save) and quit the editor. 4. Make the script executable In the terminal, give execute permissions to your script: bash Copy code chmod +x script_name.sh 5. Execute the script Run the script using: bash Copy code./script_name.sh

Use Quizgecko on...
Browser
Browser