1 / 25

Operating Systems and Linux

Operating Systems and Linux. Partha Sarathi Dasgupta MIS Group Indian Institute of Management Calcutta. Partitions. Major partitions on a Linux system: data partition : normal Linux system data, including the root partition containing all the data to start up and run the system

thyra
Télécharger la présentation

Operating Systems and Linux

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Operating Systems and Linux Partha Sarathi Dasgupta MIS Group Indian Institute of Management Calcutta

  2. Partitions • Major partitions on a Linux system: • data partition: normal Linux system data, including the root partition containing all • the data to start up and run the system • swap partition: expansion of the computer's physical memory, extra memory on hard • disk. • Usually, systems contain a root partition, one or more data partitions and one or more • swap partitions. • fdisk • Swap space is only accessible for the system itself, and is hidden from view during • normal operation. Any problem with using the swap partition? • Typically, system data is separate from user data. Programs that offer services are kept • in a different place than the data handled by this service. Different partitions created: • a partition with all data necessary to boot the machine • a partition with configuration data and server programs • one or more partitions containing the database tables, user mails, an ftp archive etc. • a partition with user programs and application • one or more partitions for the user specific files (home directories) • one or more swap partitions

  3. How to check the mounted Partitions? nettech:> df -h . Filesystem Size Used Avail Use% Mounted on /dev/hda7 980M 163M 767M 18% / /dev/hda8 496M 183M 288M 39% / /dev/hda1 124M 8.4M 109M 8% /boot /dev/hda5 19G 15G 2.7G 85% /opt /dev/had6 7.0G 5.4G 1.2G 81% /usr /dev/had7 3.7G 2.7G 867M 77% /var

  4. Init process The kernel, once it is loaded, finds init in sbin and executes it. When init starts, it becomes the parent or grandparent of all of the processes that start up automatically on Linux system. The first thing init does, is reading its initialization file, /etc/inittab. This instructs init to read an initial configuration script for the environment, which sets the path, starts swapping, checks the file systems, and so on. Basically, this step takes care of everything that system needs to have done at system initialization: setting the clock, initializing serial ports and so forth. Then init continues to read the /etc/inittab file, which describes how the system should be set up in each run level and sets the default run level. A run level is a configuration of processes. All UNIX-like systems can be run in different process configurations, such as the single user mode, which is referred to as run level 1 or run level S (or s). In this mode, only the system administrator can connect to the system. It is used to perform maintenance tasks without risks of damaging the system or user data.

  5. Init process What is init 6?

  6. How login is initiated The idea behind operating different services at different run levels essentially revolves around the fact that different systems can be used in different ways. Some services cannot be used until the system is in a particular state, or mode, such as being ready for more than one user or having networking available. There are times in which you may want to operate the system in a lower mode. Examples are fixing disk corruption problems in run level 1 so no other users can possibly be on the system, or leaving a server in run level 3 without an X session running. In these cases, running services that depend upon a higher system mode to function does not make sense because they will not work correctly anyway. By already having each service assigned to start when its particular run level is reached, you ensure an orderly start up process, and you can quickly change the mode of the machine without worrying about which services to manually start or stop. Shutdown UNIX was not made to be shut down, but if you really must, use the shutdown command. After completing the shutdown procedure, the -h option will halt the system, while -r will reboot it.

  7. Links Hard links to a file Soft links to a file SUID

  8. Inodes in File systems In a file system, a file is represented by an inode, a serial number. Every partition has its own set of inodes; throughout a system with multiple partitions, files with the same inode number can exist. Each inode describes a data structure on the hard disk. When a hard disk is initialized to accept data storage, usually during the initial system installation process or when adding extra disks to an existing system, a fixed number of inodes per partition is created. This number will be the maximum amount of files, of all types (including directories, special files, links etc.) that can exist at the same time on the partition.

  9. Inode Data Structure • At the time a new file is created, it gets a free inode. • Inode contains the following information: • Owner and group owner of the file. • File type (regular, directory, ...) • Permissions on the file • Date and time of creation, last read and change. • Date and time this information has been changed in the inode. • Number of links to this file • File size • An address defining the actual location of the file data.

  10. Path names and Files Absolute path names Relative path names Copy a file or create a link to a file Deleting files and directories

  11. Default files Standard input Standard Output Standard error

  12. Linux Processes: Birth and Death

  13. Linux Processes: Some facts • State: The execution state of the process (executing, ready, suspended, stopped, zombie) • Scheduling information: Information needed by Linux to schedule processes. A process can be normal or real-time and has a priority. Real-time processes are scheduled before normal processes, and within each category, relative priorities can be used. A counter keeps track of the amount of time a process is allowed to execute. • Identifiers: Each process has a unique identifier and also has user and group identifiers.

  14. Linux Processes: Some facts • IPC: Processes can interact with each other. • Links: Each process includes a link to its parent process, links to its siblings, and links to all of its children. • Times and timers: includes process creation time and the amount of process time so far consumed by a process. • File system: pointers to any file opened by this process, as well as pointers to the current and root directories for this process. • Address space: Virtual address space assigned to the process. • Processor-specific context: Registers and stack info constituting the context of the process.

  15. Linux Process States • Running: Process is either running or Ready to run • Interruptible: A blocked state and process is waiting for an event, such as • end of an I/O operation, availability of a resource, or a signal from another • process. • Uninterruptible: A blocked state. Process is waiting directly on hardware • conditions and will not handle any signals. • Stopped: Process halted and can be restarted only by some other process. • E.g., a process that is being debugged can be stopped. • Zombie: Process has been terminated, but its structural information is still • in the process table.

  16. Linux Process Cycle Stopped Signal Signal Running state Creation Termination Ready Scheduling Executing Zombie Event Uninterruptible Signal or Event Interruptible

  17. Input-Output Redirection • Output redirection with > and | • Redirecting "nothing" to an existing file is equal to emptying • the file • same redirection to an nonexistent file will create a new empty file with the given name • To find a word within some text, display all lines matching pattern1, or exclude lines also matching pattern2 from being displayed: • grep pattern1 file | grep -v pattern2

  18. Input-Output Redirection • To display output of a directory listing one page at a time: • ls -la | less • To find a file in a directory: • ls -l | grep part_of_file_name • who | wc –l • aspell < text.txt > error.log • cat afile >> bfile • File descriptors • ls > dirlist 2>&1 • set -o noclobber

  19. Automatic Processes: Daemons • Daemons are server processes that run continuously. • Most of the time, they are initialized at system startup and • then wait in the background until their service is required. • A typical example is the networking daemon, xinetd, which is • started in almost every boot procedure. After the system is • booted, the network daemon just sits and waits until a client • program, such as an FTP client, needs to connect.

  20. Processes at [options] time Execute commands at a specified time and optional date. The commands are taken from standard input or from a file. Example: $at 1:00 am tomorrow < scriptfile By default, only a privileged user can execute the command. Role of script files, e.g., /etc/profile

  21. Cron and Crontab • The cron system is managed by the cron daemon. • It gets information about which programs and when to run them from the • system's and users' crontab entries. • Only the root user has access to the system crontabs, while each user • should only have access to his own crontabs. On some systems (some) • users may not have access to the cron facility. • At system startup the cron daemon searches /var/spool/cron/ for crontab • entries which are named after accounts in /etc/passwd, it searches • /etc/cron.d/, /etc/crontab, then uses this information every minute to check • if there is something to be done. It executes commands as the user who • owns the crontab file and mails any command output to the owner.

  22. Cron and Crontab Users are supposed to edit their crontabs in a safe way using the crontab e command. The default editor is vi This crontab entry reminds bob to go to his sports club every Thursday night: bob:~> crontab -l # (/tmp/crontab.18185 installed on Wed Sep 19 16:37:08 2001) 38 16 * * 3 mail -s "sports evening" bob

  23. TCP/IP Testing and Troubleshooting • ping • The IP protocol includes control messages called (Internet Control Message Protocol) ICMP packets. One type of ICMP packet is called an ``echo request,'' and the IP rules require its recipient to send back an ``echo reply.'' These are incredibly useful because you can determine (1) whether the remote host is up and talking to the network, (2) the time required for a packet to make a round-trip to the host, and (3) (by sending a few dozen echo requests) what fraction of the packets sent between the hosts get lost somewhere along the way. The ping command (named after the sound of an active sonar system) sends echo requests to the host one specifies on the command line, and lists the responses received their round trip time. When terminated ping (probably by hitting control-C) it summarizes the results, giving the average round trip time and the percent packet loss. This command is used constantly to determine whether there is a problem with the network connection between two hosts.

  24. TCP/IP Testing and Troubleshooting • ping [options] host • ping –a: makes response audible every time it is received. • ping –i wait: wait for wait seconds between sending packets • ping –w n: exit ping after n seconds.

  25. TCP/IP Testing and Troubleshooting • traceroute [options] host [packetsize] • TCP/IP command. While ping gives information about the performance of the network path between two hosts, traceroute will actually show the route. It attempts to list the series of hosts through which sender’s packets travel on their way to a given destination. By observing the output of this command, and especially by following it up with pings of specific hosts on the route, the exact location of a bad (high error or latency) link can be discovered. • Attempts tracing by launching UDP probe packets with a small TTL, then listening for an ICMP “time exceeded” gateway. Host is the dest hostname/IP address. Packetsize is the #bytes of probe datagrams.

More Related