32
Secure System Administration & Secure System Administration & Certification Certification The Linux System Administrator’s Guide The Linux System Administrator’s Guide (Ch. 1-6) (Ch. 1-6) Jerry Dawkins (Project Leader) Jerry Dawkins (Project Leader) Stephen I. Khan Stephen I. Khan Michael Oglesby Michael Oglesby University of Tulsa University of Tulsa Department of Mathematical & Computer Sciences Department of Mathematical & Computer Sciences CS 5493/7493 Secure System Administration & CS 5493/7493 Secure System Administration & Certification Certification Dr. Mauricio Papa Dr. Mauricio Papa

Secure System Administration & Certification The Linux System Administrator’s Guide (Ch. 1-6) Jerry Dawkins (Project Leader) Stephen I. Khan Michael Oglesby

Embed Size (px)

Citation preview

Page 1: Secure System Administration & Certification The Linux System Administrator’s Guide (Ch. 1-6) Jerry Dawkins (Project Leader) Stephen I. Khan Michael Oglesby

Secure System Administration & CertificationSecure System Administration & Certification

The Linux System Administrator’s Guide (Ch. 1-6)The Linux System Administrator’s Guide (Ch. 1-6)

Jerry Dawkins (Project Leader)Jerry Dawkins (Project Leader)Stephen I. KhanStephen I. KhanMichael OglesbyMichael Oglesby

University of TulsaUniversity of TulsaDepartment of Mathematical & Computer SciencesDepartment of Mathematical & Computer Sciences

CS 5493/7493 Secure System Administration & CertificationCS 5493/7493 Secure System Administration & CertificationDr. Mauricio PapaDr. Mauricio Papa

Page 2: Secure System Administration & Certification The Linux System Administrator’s Guide (Ch. 1-6) Jerry Dawkins (Project Leader) Stephen I. Khan Michael Oglesby

Secure System Administration & CertificationSecure System Administration & Certification

The Linux System Administrator’s Guide (Ch. 1-6)The Linux System Administrator’s Guide (Ch. 1-6)

Jerry Dawkins (Project Leader)Jerry Dawkins (Project Leader)Stephen I. KhanStephen I. KhanMichael OglesbyMichael Oglesby

University of TulsaUniversity of TulsaDepartment of Mathematical & Computer SciencesDepartment of Mathematical & Computer Sciences

CS 5493/7493 Secure System Administration & CertificationCS 5493/7493 Secure System Administration & CertificationDr. Mauricio PapaDr. Mauricio Papa

Page 3: Secure System Administration & Certification The Linux System Administrator’s Guide (Ch. 1-6) Jerry Dawkins (Project Leader) Stephen I. Khan Michael Oglesby

Chapter 1. IntroductionChapter 1. Introduction

1.1. The guide…The guide…- describes the system administration aspects of using Linux.- describes the system administration aspects of using Linux.- is intended for people who know “next to nothing” about system - is intended for people who know “next to nothing” about system administration.administration.- doesn’t tell you how to install Linux.- doesn’t tell you how to install Linux.- is not targeted at any one given distribution.- is not targeted at any one given distribution.- is not as good as it would be if a “wizard” had been paid “handsomely” to - is not as good as it would be if a “wizard” had been paid “handsomely” to write it. write it.

2. 2. system administrationsystem administration: covers all things that you have to do to keep a : covers all things that you have to do to keep a computer system in usable order (includes items like backups, program computer system in usable order (includes items like backups, program installations and creating user accounts).installations and creating user accounts).

3. A system administrator is “3. A system administrator is “just a user with special privileges and dutiesjust a user with special privileges and duties”.”.

4. Get familiar with the 4. Get familiar with the manual pagesmanual pages (man pages). (man pages).

Page 4: Secure System Administration & Certification The Linux System Administrator’s Guide (Ch. 1-6) Jerry Dawkins (Project Leader) Stephen I. Khan Michael Oglesby

Chapter 2. About This BookChapter 2. About This Book

• Joanna Oja Joanna Oja [email protected] [email protected]

• Joanna would “really like to hear from you” regarding ideas on how to make the Joanna would “really like to hear from you” regarding ideas on how to make the guide “better”; i.e., bad language, factual errors, new ares to cover, etc.guide “better”; i.e., bad language, factual errors, new ares to cover, etc.

2.1 Acknowledgements2.1 Acknowledgements

2.1.1 Joanna’s Acknowledgements2.1.1 Joanna’s Acknowledgements

2.1.2 Stephen’s Acknowledgements2.1.2 Stephen’s Acknowledgements

• Stephen Stafford Stephen Stafford [email protected] [email protected]

• Stephen claims that there are likely to be “some minor inaccuracies” and Stephen claims that there are likely to be “some minor inaccuracies” and sections that may be “out of date”. He invites everyone to email him with these sections that may be “out of date”. He invites everyone to email him with these corrections @ [email protected] @ [email protected].

2.2. Typographical Conventions2.2. Typographical Conventions

• Filenames Filenames /usr/share/doc/foo/usr/share/doc/foo

• Command names Command names fsckfsck

• Email addresses Email addresses <<[email protected]@clothcat.daemon.co.uk>>

• ULRs ULRs http://www.linuxdoc.orghttp://www.linuxdoc.org

Page 5: Secure System Administration & Certification The Linux System Administrator’s Guide (Ch. 1-6) Jerry Dawkins (Project Leader) Stephen I. Khan Michael Oglesby

Chapter 3. Overview Of A Linux SystemChapter 3. Overview Of A Linux System

3.1. Various Parts Of An Operating System3.1. Various Parts Of An Operating System

1. 1. kernelkernel: Keeps track of files on the disk, starts programs and runs them : Keeps track of files on the disk, starts programs and runs them concurrently, assigns memory and other resources to various processes, concurrently, assigns memory and other resources to various processes, processes network packets, provides tools with which all services can be built, processes network packets, provides tools with which all services can be built, prevents anyone from accessing the hardware directly, etc.prevents anyone from accessing the hardware directly, etc.

2.2. system programssystem programs: Use the tools provided by the kernel to implement the : Use the tools provided by the kernel to implement the various services required from an operating system, run `on top of the kernel‘ various services required from an operating system, run `on top of the kernel‘ ((user modeuser mode) and needed to get the system working.) and needed to get the system working.

3. 3. application programsapplication programs: intended for getting useful things done (or for playing, : intended for getting useful things done (or for playing, if it happens to be a game).if it happens to be a game).

4. An 4. An operating systemoperating system can also contain compilers and their corresponding can also contain compilers and their corresponding libraries (i.e., the C/C++ libraries), documentation and sometimes even games. libraries (i.e., the C/C++ libraries), documentation and sometimes even games. Traditionally, the operating system has been defined by the contents of the Traditionally, the operating system has been defined by the contents of the installation media; with Linux “it is not as clear since it is spread all over the FTP installation media; with Linux “it is not as clear since it is spread all over the FTP sites of the world” (many different distributions).sites of the world” (many different distributions).

Page 6: Secure System Administration & Certification The Linux System Administrator’s Guide (Ch. 1-6) Jerry Dawkins (Project Leader) Stephen I. Khan Michael Oglesby

Chapter 3. Overview of a Linux System (cont…)Chapter 3. Overview of a Linux System (cont…)

3.2. Important Parts Of The Kernel3.2. Important Parts Of The Kernel

1. The Linux kernel consists of several important parts: 1. The Linux kernel consists of several important parts: process managementprocess management, , memory managementmemory management, , hardware device drivershardware device drivers, , file system driversfile system drivers, , network network managementmanagement, etc., etc.

2. 2. memory managementmemory management: takes care of assigning memory areas and swap : takes care of assigning memory areas and swap space areas to processes, parts of the kernel, and for the buffer cache.space areas to processes, parts of the kernel, and for the buffer cache.

3. 3. process managementprocess management: creates processes and implements multitasking by : creates processes and implements multitasking by switching the active process on the processor.switching the active process on the processor.

4. At the lowest level, the kernel contains a 4. At the lowest level, the kernel contains a hardware device driverhardware device driver for each kind for each kind of hardware it supports.of hardware it supports.

5. Class abstraction is useful, as the services the kernel provides have similar 5. Class abstraction is useful, as the services the kernel provides have similar properties; i.e., the various network protocols using a single prgramming interface properties; i.e., the various network protocols using a single prgramming interface - the BSD socket library. Another example is the - the BSD socket library. Another example is the virtual file systemvirtual file system (VFS) layer (VFS) layer that abstracts the file system operations away from their implementation.that abstracts the file system operations away from their implementation.

Page 7: Secure System Administration & Certification The Linux System Administrator’s Guide (Ch. 1-6) Jerry Dawkins (Project Leader) Stephen I. Khan Michael Oglesby

Figure 3-1. Some of the more important parts of the Linux kernel.Figure 3-1. Some of the more important parts of the Linux kernel.

Page 8: Secure System Administration & Certification The Linux System Administrator’s Guide (Ch. 1-6) Jerry Dawkins (Project Leader) Stephen I. Khan Michael Oglesby

Chapter 3. Overview of a Linux System (cont…)Chapter 3. Overview of a Linux System (cont…)

3.3. Major Services In A UNIX System3.3. Major Services In A UNIX System

3.3.1. INIT3.3.1. INIT

1. The single most important service in a UNIX system is provided by 1. The single most important service in a UNIX system is provided by initinit..

2. 2. initinit is started as the first process of every UNIX system (last thing the kernel is started as the first process of every UNIX system (last thing the kernel does when it boots).does when it boots).

3. When 3. When initinit starts, it continues the boot process by doing various startup chores starts, it continues the boot process by doing various startup chores (checking and mounting file systems, starting daemons, etc. – depending on the (checking and mounting file systems, starting daemons, etc. – depending on the distribution).distribution).

4. 4. initinit provides the concept of provides the concept of single user modsingle user mode e and and multi-user modemulti-user mode. Some . Some distributions generalize this as distributions generalize this as run levelrun levelss (i.e., single and multi-user modes are (i.e., single and multi-user modes are considered to be two run levels – the contents of considered to be two run levels – the contents of /etc/inittab/etc/inittab usually provides usually provides hints of the predefined run levels).hints of the predefined run levels).

5. 5. initinit ensures ensures gettygetty is working (to allow users to log in), and will adopt orphan is working (to allow users to log in), and will adopt orphan processes.processes.

6. When the system is shut down, 6. When the system is shut down, initinit is in charge of killing all other processes, is in charge of killing all other processes, unmounting all file systems, stopping the processor, along with anything else it unmounting all file systems, stopping the processor, along with anything else it has been configured to do.has been configured to do.

Page 9: Secure System Administration & Certification The Linux System Administrator’s Guide (Ch. 1-6) Jerry Dawkins (Project Leader) Stephen I. Khan Michael Oglesby

Chapter 3. Overview of a Linux System (cont…)Chapter 3. Overview of a Linux System (cont…)

3.3.3. SYSLOG3.3.3. SYSLOG

3.2.2. Logins From Terminals3.2.2. Logins From Terminals

1. The 1. The gettygetty program provides the capability to login from terminals (via serial program provides the capability to login from terminals (via serial lines) and the console (when not running X).lines) and the console (when not running X).

2. 2. initinit starts a separate instance of starts a separate instance of gettygetty for each terminal login, reads the for each terminal login, reads the username and runs the username and runs the loginlogin program. program. loginlogin runs the shell if the login credentials runs the shell if the login credentials are correct. are correct. initinit detects shell termination (i.e., user logout, bad password, etc.) detects shell termination (i.e., user logout, bad password, etc.) and starts a new instance of and starts a new instance of gettygetty..

3. The kernel has no notion of logins, this is all handled by the 3. The kernel has no notion of logins, this is all handled by the system system programprogramss..

1. 1. syslogsyslog is a program that writes errors, warnings and other messages produced is a program that writes errors, warnings and other messages produced by the kernel or other by the kernel or other system programssystem programs to a file. to a file.

2. It can be configured to sort the messages to different files according to degree 2. It can be configured to sort the messages to different files according to degree of importance (i.e., kernel messages are typically the most important).of importance (i.e., kernel messages are typically the most important).

Page 10: Secure System Administration & Certification The Linux System Administrator’s Guide (Ch. 1-6) Jerry Dawkins (Project Leader) Stephen I. Khan Michael Oglesby

Chapter 3. Overview of a Linux System (cont…)Chapter 3. Overview of a Linux System (cont…)

3.3.5. Graphical User Interface3.3.5. Graphical User Interface

3.3.4. Periodic Command Execution: CRON and AT3.3.4. Periodic Command Execution: CRON and AT

1. The 1. The croncron service is used to run commands periodically. Typically used for service is used to run commands periodically. Typically used for maintenance; i.e., cleaning up files in maintenance; i.e., cleaning up files in /tmp/tmp and and /var/tmp/var/tmp..

2. The 2. The atat service is similar to service is similar to croncron, but the command is executed at the given , but the command is executed at the given time, but it is not repeated.time, but it is not repeated.

1. Not incorporated into the kernel.1. Not incorporated into the kernel.

2. Implemented by user level programs.2. Implemented by user level programs.

3. Makes the system more flexible, but has the disadvantage of making the 3. Makes the system more flexible, but has the disadvantage of making the system harder to learn since it is simple to implement a different user interface for system harder to learn since it is simple to implement a different user interface for each program.each program.

4. The graphical environment primarily used with Linux is called the 4. The graphical environment primarily used with Linux is called the X Window X Window SystemSystem..

Page 11: Secure System Administration & Certification The Linux System Administrator’s Guide (Ch. 1-6) Jerry Dawkins (Project Leader) Stephen I. Khan Michael Oglesby

Chapter 3. Overview of a Linux System (cont…)Chapter 3. Overview of a Linux System (cont…)

3.3.7. Network Logins3.3.7. Network Logins

3.3.6. Networking3.3.6. Networking

1. 1. networkingnetworking: act of connecting two or more computers so that they can : act of connecting two or more computers so that they can communicate with each other.communicate with each other.

2. Some basic network services: access to centralized file systems, printing, 2. Some basic network services: access to centralized file systems, printing, backups, etc.backups, etc.

3. Lower costs and better fault tolerance in available due to centralized 3. Lower costs and better fault tolerance in available due to centralized administration.administration.

1. For each person logging in via the network, there is a separate virtual network 1. For each person logging in via the network, there is a separate virtual network connection, and there can be X number of these.connection, and there can be X number of these.

2. Some different ways to log in via a network - 2. Some different ways to log in via a network - telnettelnet and and rloginrlogin being the major being the major ones in TCP/IP networks.ones in TCP/IP networks.

3. Instead of a herd of 3. Instead of a herd of gettygettys, there is a single daemon that listens for all s, there is a single daemon that listens for all incoming login attempts for each remote login mechanism. The separate incoming login attempts for each remote login mechanism. The separate daemons start a new instance of themselves to handle a single login attempt daemons start a new instance of themselves to handle a single login attempt while the original instance continues to listen for other attempts.while the original instance continues to listen for other attempts.

Page 12: Secure System Administration & Certification The Linux System Administrator’s Guide (Ch. 1-6) Jerry Dawkins (Project Leader) Stephen I. Khan Michael Oglesby

Chapter 3. Overview of a Linux System (cont…)Chapter 3. Overview of a Linux System (cont…)

3.3.8. Network File Systems3.3.8. Network File Systems

3.3.9. Mail3.3.9. Mail

1. One of the more useful things that can be done with networking services is 1. One of the more useful things that can be done with networking services is sharing files via a sharing files via a network file systemnetwork file system [i.e., Network File System (NFS - [i.e., Network File System (NFS - developed by Sun].developed by Sun].

2. Another popular way of sharing files is 2. Another popular way of sharing files is SambaSamba http://www.samba.orghttp://www.samba.org..

1. The delivery of mail to local or remote mailboxes is done by one program (the1. The delivery of mail to local or remote mailboxes is done by one program (the mail transfer agentmail transfer agent (MTA), i.e., (MTA), i.e., sendmailsendmail oror smailsmail).).

2. The2. The mail user agentmail user agentss (MUA) (programs users use) are many and varied, i.e., (MUA) (programs users use) are many and varied, i.e., pinepine, , muttmutt oror elmelm).).

3. The mailboxes are usually stored in3. The mailboxes are usually stored in /var/spool/mail/var/spool/mail..

3.3.10. Printing3.3.10. Printing

1. The printer is managed by software that implements a 1. The printer is managed by software that implements a print queuprint queuee..

2. This relieves the users from fighting over control of the printer.2. This relieves the users from fighting over control of the printer.

3. The print queue software also 3. The print queue software also spoolsspools the printouts on disk.the printouts on disk.

Page 13: Secure System Administration & Certification The Linux System Administrator’s Guide (Ch. 1-6) Jerry Dawkins (Project Leader) Stephen I. Khan Michael Oglesby

Chapter 3. Overview of a Linux System (cont…)Chapter 3. Overview of a Linux System (cont…)

3.3.11. The File System Layout3.3.11. The File System Layout

1. The file system is divided into many parts; usually along the lines of a root file 1. The file system is divided into many parts; usually along the lines of a root file system (system (//) with ) with /bin/bin, , /lib/lib, , /etc/etc, , /dev/dev, , /usr/usr (programs and unchanging data), (programs and unchanging data), /var/var [changing data (such as log files)], [changing data (such as log files)], /home/home (personal files), etc. (personal files), etc.

2. The layout depends on the hardware configuration and the decisions of the 2. The layout depends on the hardware configuration and the decisions of the system administrator.system administrator.

Page 14: Secure System Administration & Certification The Linux System Administrator’s Guide (Ch. 1-6) Jerry Dawkins (Project Leader) Stephen I. Khan Michael Oglesby

Chapter 4. Overview of the Directory TreeChapter 4. Overview of the Directory Tree

4.1. Background4.1. Background

1. Linux directory tree is based on the 1. Linux directory tree is based on the File System Hierarchy StandardFile System Hierarchy Standard (FHS - (FHS -standard for how the directory tree in a Linux system is organized) standard for how the directory tree in a Linux system is organized)

2. Not all Linux distributions follow this standard “slavishly”.2. Not all Linux distributions follow this standard “slavishly”.

3. The full directory tree is intended to be breakable into smaller parts, each 3. The full directory tree is intended to be breakable into smaller parts, each capable of being on its own disk or partition, to accommodate to disk size limits capable of being on its own disk or partition, to accommodate to disk size limits and to ease backup and other system administration tasks.and to ease backup and other system administration tasks.

4. Major parts…4. Major parts…

- The - The root file systemroot file system contains the files that are necessary for booting contains the files that are necessary for booting the system up and to bring it up to such a state that the other file the system up and to bring it up to such a state that the other file systems systems may be mounted.may be mounted.

- The - The /usr file system/usr file system contains all commands, libraries, manual pages, contains all commands, libraries, manual pages, and other unchanging files needed during normal operation.and other unchanging files needed during normal operation.

- The - The /var file system/var file system contains files that change, such as spool contains files that change, such as spool directories, log files, formatted manual pages, and temporary files.directories, log files, formatted manual pages, and temporary files.

- The - The /home file system/home file system contains the users' home directories, i.e., all contains the users' home directories, i.e., all the real data on the system.the real data on the system.

Page 15: Secure System Administration & Certification The Linux System Administrator’s Guide (Ch. 1-6) Jerry Dawkins (Project Leader) Stephen I. Khan Michael Oglesby

Chapter 4. Overview of the Directory Tree (cont…)Chapter 4. Overview of the Directory Tree (cont…)

4.2. The Root File System4.2. The Root File System

1. The 1. The root file systemroot file system should generally be small since it contains very critical should generally be small since it contains very critical files. A small, infrequently modified file system has a better chance of not getting files. A small, infrequently modified file system has a better chance of not getting corrupted. Some common items in the corrupted. Some common items in the root file systemroot file system::

- - /bin/bin : contains files needed during the boot process. : contains files needed during the boot process.

-- /root /root : home directory for user root. : home directory for user root.

-- /lib/lib : : shared libraries needed by the programs on the root file system.shared libraries needed by the programs on the root file system.

- - /tmp/tmp : : temporary files.temporary files.

- - /mnt/mnt : : mount point for temporary mounts by the system administrator. mount point for temporary mounts by the system administrator.

4.3. The /etc Directory4.3. The /etc Directory

1. The 1. The /etc directory/etc directory contains “a lot of files” including many network configuration contains “a lot of files” including many network configuration files. Some common subdirectories in the files. Some common subdirectories in the /etc directory/etc directory::

- - /etc/passwd, /etc/shadow/etc/passwd, /etc/shadow : : the user database containing the the user database containing the username, real name, home directory, encrypted password, and other username, real name, home directory, encrypted password, and other information about each user.information about each user.

- - /etc/inittab/etc/inittab : : Configuration file for Configuration file for initinit..

Page 16: Secure System Administration & Certification The Linux System Administrator’s Guide (Ch. 1-6) Jerry Dawkins (Project Leader) Stephen I. Khan Michael Oglesby

Chapter 4. Overview of the Directory Tree (cont…)Chapter 4. Overview of the Directory Tree (cont…)

4.3. The /etc Directory (cont…)4.3. The /etc Directory (cont…)

- - /etc/fstab/etc/fstab : lists the file systems mounted automatically at startup. : lists the file systems mounted automatically at startup.

- - /etc/group/etc/group : similar to : similar to /etc/passwd/etc/passwd (describes groups). (describes groups).

- - /etc/motd/etc/motd : the message of the day, automatically output after a : the message of the day, automatically output after a successful login.successful login.

- - /etc/mtab/etc/mtab : list of currently mounted file systems. : list of currently mounted file systems.

- - /etc/profile/etc/profile, , /etc/csh.login/etc/csh.login, , /etc/csh.cshrc/etc/csh.cshrc : files executed at login or : files executed at login or startup time by the Bourne or C shells.startup time by the Bourne or C shells.

- - /etc/shells/etc/shells : lists trusted shells. : lists trusted shells.

4.4. The /dev Directory4.4. The /dev Directory

1. The 1. The /dev directory/dev directory contains the special device files for all the devices. The contains the special device files for all the devices. The /dev/MAKEDEV/dev/MAKEDEV script can be used to create device files not created during script can be used to create device files not created during original installation. The original installation. The /dev/MAKEDEV.local/dev/MAKEDEV.local filefile is a script used to create local-is a script used to create local-only device files or links [i.e. those that are not part of the standard only device files or links [i.e. those that are not part of the standard MAKEDEV MAKEDEV (like non-standard device drivers)].(like non-standard device drivers)].

Page 17: Secure System Administration & Certification The Linux System Administrator’s Guide (Ch. 1-6) Jerry Dawkins (Project Leader) Stephen I. Khan Michael Oglesby

Chapter 4. Overview of the Directory Tree (cont…)Chapter 4. Overview of the Directory Tree (cont…)

4.5. The /usr File System4.5. The /usr File System

1. The 1. The /usr file system/usr file system is often large, since all programs are installed there. All is often large, since all programs are installed there. All files in files in /usr/usr usually come from a Linux distribution. This makes it possible to usually come from a Linux distribution. This makes it possible to update the system from a new version of the distribution, or even a completely update the system from a new version of the distribution, or even a completely new distribution, without having to install all programs again. Some common new distribution, without having to install all programs again. Some common items in the items in the /usr file system/usr file system::

- - /usr/X11R6/usr/X11R6 :: the X Window System, all files.the X Window System, all files.

- - /usr/bin/usr/bin : almost all user commands (some commands are in : almost all user commands (some commands are in /bin/bin or in or in /usr/local/bin/usr/local/bin).).

- - /usr/lib/usr/lib : unchanging data files for programs and subsystems. : unchanging data files for programs and subsystems.

- - /usr/local/usr/local : : the place for locally installed software and other files.the place for locally installed software and other files.

Page 18: Secure System Administration & Certification The Linux System Administrator’s Guide (Ch. 1-6) Jerry Dawkins (Project Leader) Stephen I. Khan Michael Oglesby

Chapter 4. Overview of the Directory Tree (cont…)Chapter 4. Overview of the Directory Tree (cont…)

4.6. The /var File System4.6. The /var File System

1. The 1. The /var file system/var file system contains data that is changed when the system is running contains data that is changed when the system is running normally. It is specific for each system, i.e., not shared over the network with normally. It is specific for each system, i.e., not shared over the network with other computers. Some common items in the other computers. Some common items in the /var file system/var file system::

- - /var/games/var/games : variable data belonging to games. : variable data belonging to games.

- - /var/lock/var/lock : lock files. : lock files.

- - /var/log/var/log : log files from various programs [i.e., login and logouts : log files from various programs [i.e., login and logouts ((/var/log/wtmp/var/log/wtmp) and syslog () and syslog (/var/log/messages/var/log/messages)].)].

- - /var/mail/var/mail : this is the FHS approved location for user mailbox files : this is the FHS approved location for user mailbox files (could be in (could be in /var/spool/mail/var/spool/mail).).

- - /var/spool/var/spool : directories for news, printer queues, and other queued : directories for news, printer queues, and other queued work.work.

Page 19: Secure System Administration & Certification The Linux System Administrator’s Guide (Ch. 1-6) Jerry Dawkins (Project Leader) Stephen I. Khan Michael Oglesby

Chapter 4. Overview of the Directory Tree (cont…)Chapter 4. Overview of the Directory Tree (cont…)

4.7. The /proc File System4.7. The /proc File System

• The The /proc file system/proc file system does not exist on a disk - it is located in memory. It is does not exist on a disk - it is located in memory. It is used to provide information about the system. Some common items in the used to provide information about the system. Some common items in the /proc /proc file systemfile system::

- - /proc/cpuinfo/proc/cpuinfo : information about the processor. : information about the processor.

- - /proc/devices/proc/devices : list of device drivers currently running. : list of device drivers currently running.

- - /proc/filesystems/proc/filesystems : file systems configured into the kernel. : file systems configured into the kernel.

- - /proc/ioports/proc/ioports : which I/O ports are in use at the moment. : which I/O ports are in use at the moment.

- - /proc/kcore/proc/kcore : an image of the physical memory of the system. : an image of the physical memory of the system.

- - /proc/meminfo/proc/meminfo : information about memory usage. : information about memory usage.

- - /proc/net/proc/net : status information about network protocols. : status information about network protocols.

- - /proc/uptime/proc/uptime : the time the system has been up. : the time the system has been up.

- - /proc/version/proc/version : the kernel version. : the kernel version.

Page 20: Secure System Administration & Certification The Linux System Administrator’s Guide (Ch. 1-6) Jerry Dawkins (Project Leader) Stephen I. Khan Michael Oglesby

Chapter 5. Device FilesChapter 5. Device Files

5.1. The MAKEDEV Script5.1. The MAKEDEV Script

5.2. The MAKNOD Command5.2. The MAKNOD Command

• All devices are accessed as if they were files, including reading and writing.

• The complete list of devices is available in usr/src/linux/Documentation/devices.txt.

• The MAKEDEV script is used to create the device file. Most times the device file will already be created and ready for use after installing Linux.

• #/dev/MAKEDEV –v [device name]

• Use mknod if MAKEDEV does not know how to create the device. (more work)

• #mknod /dev/ttys0 c 4 64 #chown root.dialout /dev/ttys0 #chmod 0644 /dev/ttys0

Page 21: Secure System Administration & Certification The Linux System Administrator’s Guide (Ch. 1-6) Jerry Dawkins (Project Leader) Stephen I. Khan Michael Oglesby

Chapter 5. Device Files (cont…)Chapter 5. Device Files (cont…)

5.3. Device List5.3. Device List

• /dev/fd0The first floppy drive

• /dev/hdaMaster IDE drive on the primary channel

• /dev/lp0Parallel printer

• /dev/zeroZero character generator

• /dev/loop0Loopback device

• /dev/nullBit-bucket

• /dev/psauxPS/2 mouse port

• /dev/dspDigital Signal Processor

Page 22: Secure System Administration & Certification The Linux System Administrator’s Guide (Ch. 1-6) Jerry Dawkins (Project Leader) Stephen I. Khan Michael Oglesby

Chapter 6. Using Disks and Other Storage MediaChapter 6. Using Disks and Other Storage Media

• Format your disk. This does various things to prepare it for use, such as checking for bad sectors. (Formatting is nowadays not necessary for most hard disks.)

• Partition a hard disk, if you want to use it for several activities that aren't supposed to interfere with one another. One reason for partitioning is to store different operating systems on the same disk. Another reason is to keep user files separate from system files, which simplifies back-ups and helps protect the system files from corruption.

• Make a file system (of a suitable type) on each disk or partition. The disk means nothing to Linux until you make a file system; then files can be created and accessed on it.

• Mount different file systems to form a single tree structure, either automatically, or manually as needed.

Page 23: Secure System Administration & Certification The Linux System Administrator’s Guide (Ch. 1-6) Jerry Dawkins (Project Leader) Stephen I. Khan Michael Oglesby

Chapter 6. Using Disks and Other Storage Media (cont…)Chapter 6. Using Disks and Other Storage Media (cont…)

6.2. Hard Disks6.2. Hard Disks

• Consists of one or more platters of which either or both surfaces are coated with a magnetic substances.

• Surfaces are divided into concentric rings called tracks.

• Tracks are divided into sectors.

• Typical sector holds 512 bytes of data.

• A sector is the smallest file size. Cannot split across files.

• Read/Write head rides a cushion of air.

Page 24: Secure System Administration & Certification The Linux System Administrator’s Guide (Ch. 1-6) Jerry Dawkins (Project Leader) Stephen I. Khan Michael Oglesby

Figure 6-1. A schematic picture of a hard disk.Figure 6-1. A schematic picture of a hard disk.

Page 25: Secure System Administration & Certification The Linux System Administrator’s Guide (Ch. 1-6) Jerry Dawkins (Project Leader) Stephen I. Khan Michael Oglesby

Chapter 6. Using Disks and Other Storage Media (cont…)Chapter 6. Using Disks and Other Storage Media (cont…)

6.4. CD-ROMs6.4. CD-ROMs

• Optical read plastic coated disk. Data is encoded in small holes along a spiral from the center to the outer edge.

• Most common file system for CD-ROMs is ISO 9660.

• To accommodate additional features the “Rock Ridge extension” was developed.

6.3. Floppies6.3. Floppies

• Similar to a hard diskPlatter, sectors, tracks, read/write access

• DifferenceRead/write head touches disk, smallerdifferent size disks read by the samedrive

• setfdprm (modify floppy drive parameters)

Page 26: Secure System Administration & Certification The Linux System Administrator’s Guide (Ch. 1-6) Jerry Dawkins (Project Leader) Stephen I. Khan Michael Oglesby

Chapter 6. Using Disks and Other Storage Media (cont…)Chapter 6. Using Disks and Other Storage Media (cont…)

6.7. Partitions6.7. Partitions

• One hard disk into many• Creates virtual hard disks• Implemented in software

– OS Convention• Stored in Master Boot Record (MBR)

– First sector of the first track on the first disk surface– Loaded by BIOS

• fdisk –l /dev/hda • Labeling

– 1-4 primary partitions– 5+ logical partitions– Example

• /dev/hda1 – first primary partition on the first IDE hard disk• /dev/sdb7 - the third extended partition on the second SCSI hard disk

Page 27: Secure System Administration & Certification The Linux System Administrator’s Guide (Ch. 1-6) Jerry Dawkins (Project Leader) Stephen I. Khan Michael Oglesby

Chapter 6. Using Disks and Other Storage Media (cont…)Chapter 6. Using Disks and Other Storage Media (cont…)

6.7.2. Extended And Logical Partitions6.7.2. Extended And Logical Partitions

• Limited to 4 partitions

– Original design

• Extended partitions

– Partitioning partitions into sub-partitions

• Extended partition

• Logical partition

Page 28: Secure System Administration & Certification The Linux System Administrator’s Guide (Ch. 1-6) Jerry Dawkins (Project Leader) Stephen I. Khan Michael Oglesby

Chapter 6. Using Disks and Other Storage Media (cont…)Chapter 6. Using Disks and Other Storage Media (cont…)

6.8. File Systems6.8. File Systems

• Methods and data structures that an operating system uses to keep track of files on a disk or partition; that is, the way the files are organized on the disk• General Structure

– Superblock• Contains information about the file system

– Inode• Contains all information about a file, except its name

– Directory block• Contains filename and the number of the inode along with

– Data block• Used to store data in the file• Limited in number

– Indirection block• A pointer to dynamically allocated data blocks to store additional data

Page 29: Secure System Administration & Certification The Linux System Administrator’s Guide (Ch. 1-6) Jerry Dawkins (Project Leader) Stephen I. Khan Michael Oglesby

Chapter 6. Using Disks and Other Storage Media (cont…)Chapter 6. Using Disks and Other Storage Media (cont…)

6.8.2. File Systems Galore6.8.2. File Systems Galore

• Ext2– Native Linux file system.– Upward compatible

• Ext3– Includes journaling (tracks all transactions for rollbacks)

• Minix – the oldest • Xia – modified minix• FAT – old DOS• FAT32 – Windows 95• NTFS – Windows NT• Many more…

• /proc

• Access to kernel data structures

– ie process table

• In memory

Page 30: Secure System Administration & Certification The Linux System Administrator’s Guide (Ch. 1-6) Jerry Dawkins (Project Leader) Stephen I. Khan Michael Oglesby

Chapter 6. Using Disks and Other Storage Media (cont…)Chapter 6. Using Disks and Other Storage Media (cont…)

6.8.5. Mounting And Unmounting6.8.5. Mounting And Unmounting

• Enables a device file system to be accessed

– Looks like the contents of the new file system are the contents of an existing subdirectory in some already mounted file system.

Page 31: Secure System Administration & Certification The Linux System Administrator’s Guide (Ch. 1-6) Jerry Dawkins (Project Leader) Stephen I. Khan Michael Oglesby

Chapter 6. Using Disks and Other Storage Media (cont…)Chapter 6. Using Disks and Other Storage Media (cont…)

6.8.5. Mounting And Unmounting (cont…)6.8.5. Mounting And Unmounting (cont…)

• Mount takes two arguments– Device file corresponding to the disk or partition– Directory below which it will be mounted

• Mount point– Mounted-on directory

• Mount attempts to guess the type of file system– The file system can be specified by the –t option

• Umount– Unmounts the file system– Data is not necessarily written to the floppy until you unmount it!

Page 32: Secure System Administration & Certification The Linux System Administrator’s Guide (Ch. 1-6) Jerry Dawkins (Project Leader) Stephen I. Khan Michael Oglesby

Chapter 6. Using Disks and Other Storage Media (cont…)Chapter 6. Using Disks and Other Storage Media (cont…)

6.9. Disks Without File Systems6.9. Disks Without File Systems

• Has advantages– More of the disk is usable– Compatibility

• tar file format is the same on all platforms• Reason

– Swap partition– Disk images