🎧 New: AI-Generated Podcasts Turn your study notes into engaging audio conversations. Learn more

PROG1225-06 Lecture-Operating System Admin.pdf

Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...

Full Transcript

1225 Unit Six: Operating System Administration Overview Operating system administration deals with the configuration and management of computer resources:     Manage Tasks Monitor Performance Monitor Reliability Additional Administrative Activities (Linux) Note: most Linux commands require su...

1225 Unit Six: Operating System Administration Overview Operating system administration deals with the configuration and management of computer resources:     Manage Tasks Monitor Performance Monitor Reliability Additional Administrative Activities (Linux) Note: most Linux commands require superuser (administrator or root user) privileges.  su Command (Switch User or Super User or Substitute User): used by itself will allow the user to switch to the  root user (administrator) if allowed by the distribution (must have a root user password set). sudo Command (Super User Do): prefix any command that requires administrative rights with this command. sudo mount -t vfat /dev/sdc1 /media/usb [example using sudo with the mount command] Manage Tasks Using task management tools in Windows and Linux will allow you to explore the factors that effect your computers performance. Windows 10 Use Task Manager to monitor active applications and processes – you can also stop applications and processes that have stopped responding or responding slowly.       Process Tab: shows currently running processes and resource utilization o Running processes are sorted first by applications, then non-Windows background processes, and then Windows processes. o Resource utilization includes CPU, Memory, Disk, and Network. You can sort by any of these resources to see which process is take the most of a particular resource. Colour coding is also used – low resource utilization is shown in pale yellow, while darker shades of yellow and orange represent greater resource utilization – red indicates critical resource utilization. o End Task Button: used to kill unresponsive applications and processes. Note that some processes will restart automatically. Performance Tab: a quick view of CPU, memory, disk, and network usage. App History Tab: by default – shows usage history for Windows Store applications only. o Use the Options menu to “Show history of all processes” Startup Tab: shows which programs start automatically during system log-in. o Right-click any column heading to choose additional details not shown by default. o You can stop certain programs from starting up by right-clicking on the process and selecting ‘disable’. Users Tab: shows the resources that your account is using, shows other users on the system, and allows you to switch to other user sessions. o Tab not available if connected to a domain network (like the college). Details Tab: displays more information about all the processes that are running on the system.  Services Tab: view and manage (start, stop, or restart) services that are running. o Services are system programs that run in the background and provide the core operating system functionality. o The services window can be opened by clicking on the ‘open services’ option at the bottom of the window.  In the services window, double click on any service to get more details, including dependencies, for that service. Linux Most Linux environments provide some type of system monitor as well as having command line tools to monitor applications and processes. The following will outline the GNOME (GNU Network Object Model Environment) System Monitor…   System Monitor: monitors current system processes, view graphs, and manipulate running applications. Can be accessed via the GUI or CLI (gnome-system-monitor). o Processes Tab: lists all the processes running on the system.  End Process button allows you to stop the selected process.  View menu (button at top right with 3 parallel lines on it) allows control of which process are displayed. If you select Dependencies option, the parent processes are indicated by a diamond symbol to the left of the process name.  The commands to display information for system processes are ps and top. o Resources Tab: displays usage history of your CPU, memory, swap memory, and network.  The command to display resources is free. o File Systems Tab: includes information about how much space is used, which drive is attached (mounted) to which directory, and the type of file system used. Process Command (ps): lists the system processes that are running, who owns them, and the amount of system resources being used. o Whenever a program or command is executed, the kernel assigns an identification number called a PID (Process ID) to the process. This PID can then be used by other commands to control the process.  -e option selects all processes  -f option displays a full, detailed listing  -p option selects specific processes by PID  -t option selects processes associated with a particular tty. TTY (Teletypewriter) – physical connection to the computer, like a keyboard, mouse, or monitor.  -u option selects processes by user  Options can be combined: ps -fu User01  [shows all process by the specified user (User01) in a detailed listing] kill Command: used to stop a process. o o o kill PID – will stop the process with the specified PID kill -9 PID – (kill number nine) a ‘stronger’ kill command – used when the basic kill command does not work kill -SIGHUP PID – stops a process with the ‘hang up’ signal which is ‘cleaner’ because it cleans up all associated processes as well Monitor Performance By using performance monitoring tools for real-time and periodic observation, you can get important information about the health of your system. A performance baseline is typically used – the level of performance you can expect during typical usage and workloads. A bottleneck is anything that slows down a systems performance – investigating bottlenecks is important in determining the source of potential system problems. Windows 10 Use Performance Monitor to collect and view real-time data about a system’s usage activities. In the Performance Monitor screen, click on the green plus sign to add a particular counter (each counter watches a particular computer resource).    Disk Performance: add a ‘Physical Disk’ object counter – the three most common counters used here are… o % Disk Time: how busy the disk is. o Disk Reads/sec & Disk Writes/sec Managing Memory: add a ‘Memory’ object counter – the four most common counters used here are… o Available Mbytes: the amount of memory left after operating system is loaded – if the value drops too low, your computer may have a memory shortage. o Cache Bytes: bytes used by the file system cache – if the value gets too high (> ~4 MB), you may need more RAM (memory). o Pages/sec: how often the hard drive is used to store or retrieve memory associated data. A high degree of page file activity indicates that more RAM is required.  Paging occurs when the virtual machine accesses the hard drive to store or retrieve a memory page – some paging is ok (it allows an OS to use more memory then it actually has), but too much paging is a drain on performance (hard drives are slower than memory). o Page Faults/sec: how often requested information must be retrieved from another memory location or the page file. Again, too often and you may need more memory. Processor Use: add a ‘Processor’ object counter – the three most common counters used here are… o % Processor Time: how much time the processor actually spends working on productive threads versus how often it is busy servicing requests. Exceeding 85% may require a processor upgrade. o Interrupts/sec: the average rate at which the processor receives and services hardware interrupts.  Interrupts are signals sent to the processor to indicate that something needs access to the CPU. Interrupts can come from either hardware or software. o Processor Queue Length: number of threads in the processor queue that are ready to be executed – a sustained processor queue of less than 12 threads per processor is normally acceptable.  This counter is found under the ‘System’ object. Linux The directory /proc is actually a pseudo-file system – it doesn’t contain any real files but contains runtime system information which directly interfaces with the kernel and is stored in memory. Commands also exist that will give valuable information on system performance.  /proc – use the cat command to view the contents of the following ‘files’ (the output is very technical) … o iomem: memory input/output statistics o mounts: mounted file system statistics o stat: process status in readable format o diskstats: disk statistics o swaps: swap file statistics (virtual memory) o loadavg: the average number of processes ready to run during the last 1, 5, and 15 minutes cat swaps   [shows on the screen the swap file statistics] top Command: displays system statistics in real time (5 sec delay by default). Just type top for general output. free Command: displays the amounts of free, used, and swap memory (in KB for the first two items, use -m option for MB). Just type free for general output.    watch free Command Line: repeatedly runs free to produce real-time statistics. Ctrl+C to quit. vmstat Command: reports on process status, memory consumption, paging activity, I/O operations, and CPU usage. It typically provides an average since the last reboot, or it can report usage for a current period of time if you specify the time interval. The basic fields displayed by the vmstat command are: o procs – number of processes running and sleeping o swap – amount of memory paged for input and output o us – percentage of total processor time consumed by user space  User space refers to programs that are executed by the user o sy – percentage of total processor time consumed by the kernel space  Kernel space refers to programs that are executed by the kernel o wa – percentage of total processor time spent in I/O wait (waiting for input or output operations) o id – percentage of total processor time spent idle uptime Command: displays the amount of time since the last system reboot, shows the CPU average load for the past 1, 5, and 15 minutes, and shows how many users are logged on. Simply type uptime to use. Monitor Reliability Reliability monitoring relies on tools that report hardware and software problems and other change to your computer.   Reliability Monitor (Windows): measures hardware and software problems and other changes to your computer – it also provides a stability index from 1 (unstable) to 10 (most stable). o Events monitored include Windows updates – software installations and uninstalls – device driver installations, updates, rollbacks, and uninstalls – application hangs and crashes – device drivers that fail to load or unload – disk and memory failures – windows failures, including boot failures, system crashes, and sleep failures. o Recent events will only be displayed after 24 hours have passed. Automatic Bug Reporting Tool (ABRT) (Linux): a set of utilities for reporting software problems as well as providing useful crash statistics. o When a crash occurs, the ABRT daemon (a background process) collects the crash-related data and an alert appears. Additional Administrative Activities (Linux) Common Linux Directories            / – this directory contains the main file system. Every file system is attached directly or indirectly to this directory. /bin – contains executable commands (sometimes called binary files). /boot – contains the kernel and boot files. /dev – contains all the devices installed on the system, including DVD and USB device which look like files but are actually physical or virtual hardware devices. /etc – contains the system configuration files. /home – contains all of the home directories of the users on the system. /lib and /lib64 – contains the shared program libraries /lost+found – contains damaged files that have been recovered by the OS. /media – functions as a temporary mount directory for removable devices. /mnt – contains various mount points for user file systems. /opt – contains optional add-on applications.         /proc – virtual directory containing status information. Virtual means that no actual disk space is associated with the file system – it is entirely contained in memory. /root – the home directory of the superuser (also known as the root user). /sbin – contains system executables (binaries), which are typically used by the system in the background or by system administrators. /srv – contains service-related data. /sys – provides device and driver information. /tmp – contains temporary files. /usr – contains executables (binaries), libraries, documentation, ad source code for user level programs. /var – contains files that normally vary in size, such as log files. Managing File Systems    File System Checking and Repair: o Sometimes power losses or abrupt shutdowns can cause file corruption and OS errors because the OS cannot synchronize the file system buffer cache with the contents of the disk. A buffer cache is a special memory region used for quick access to stored data items. o fsck Command: used to check for file system errors and repair them. (Equivalent to the chkdsk command in Windows.) o The file system is normally checked while unmounted (not attached to a directory), mounted read-only, or with the system in a special maintenance mode. Disk Usage Management: o df Command: used to report the disk space usage of a file system. o du Command: used to specify disk usage of each file or recursively for directories. Mounting a File System o The act of mounting is the process by which a file system becomes available for use by attaching it to a directory. Certain partitions are created and mounted by default at installation and are automatically mounted when the OS boots. o mount Command: used to attach a file system on a storage device to a directory. mount <file system type> <the device to be mounted> <mount point>    file system type: use -t option with the file system type (Examples: -t ext4 or -t ntfs or -t vfat) the device to be mounted: use one of the standard Linux device names. All devices are defined in the /dev directory. The /dev directory contains files used to access hardware resources (think of these files as being like device drivers). o hda: the first PATA device (old type of hard drive connector) o hda1: the first partition on the first PATA device  Partitions are separate file systems on a same device – only certain devices can have multiple partitions. o sda: the first SATA device (also used for SCSI and SAS devices used in some servers) o sda1: the first partition on the first SATA device o sdb1: the first partition on the second SATA device o fdisk -l Command: used to determine which device to use (must pick it out from a fair amount of information) mount point: directory to attach the file system mount -t vfat /dev/sdc1 /media/usb o o [an example of mounting an USB flash drive] umount Command: used to unmount a device based on mount point (Example: umount /media/usb) /etc/fstab: create a mount entry in this file for other storage devices to be automatically mounted Configuration Files and Environment Variables Linux stores two types of configuration files: user and system.   User configuration files store settings that apply to individual users and are stored in the users’ home directory. These may include things like users; desktop icon placements, window manager preferences, and scripts that run automatically when starting a command prompt shell. o .bashrc: This file is located in the users’ home directory (when using the BASH shell). Since it starts with a dot (.), this file is hidden from the user when they use the default ls command (they must use the ls -a option). This file is a script (a simple text-based program) that is run whenever a bash shell runs. This file controls many aspects of the users’ bash shell – like default environment variables. System configuration files control the entire system. Some of these provide defaults for users’ configurations, but others control the system as a whole. If there is a problem with some of these files, the system may misbehave quite seriously, or possibly even fail to boot. o /etc/profile: This file is executed when a user logs in. It contains environment variable settings and programs that should be run whenever a user logs in. Note that a user configuration file runs after any system configuration files – hence some of settings done is a system configuration file can be changed by a user’s configuration file. Environment variables contain data used by one or more application. Common environment variables include:     PATH – a colon-separated list of directories to be searched for programs SHELL – the shell that is the current default PS1 – the default shell prompt USER – the user’s account name Common Commands used with Environment Variables:    set – displays a list of environment variables export – sets an environment variable echo $VARIABLE – displays the value of the environment variable (ex. echo $PATH) Other Shell Features  Tab Completion: a way to quickly enter a long filename or directory name. Example:   rm this<tab> [rm thisisalongfilename – assuming this filename exists] History: the last 1000 commands entered at the command line – set with the HISTFILESIZE environment variable and stored in the file .bash_history (for the BASH shell) as determined by the environment variable HISTFILE. o Using the up or down arrows on your keyboard will recall the commands previously used. o Using the history command will bring up a list of the commands previously used. o You can use bang notation to execute a command line in the history list:  !<history number> – executes that command line  !<command or partial command line> – executes the most recent command line using that command Alias: a command that will substitute one string of characters for another. o alias <string entered by user> = <string substituted by the shell>  Note: if the string contains spaces, then double quotation marks (“ ”) must be used around the string. o The alias command is common in start-up scripts. The Shell Start-up Process:    a number of configuration files are executed when a user logs into Linux and also when a Shell is started. When a user logs in (BASH shell): o /etc/profile – for all users o ~/.profile (or ~/.bash_profile) – specific to the user logging in When a BASH Shell is started (BASH is the default Linux Shell): o /etc/bashrc – for all users o ~/.bashrc – specific to the user starting the Shell Soft & Hard Links:   Soft Link (of Symbolic Link): a filename associated with another file (like a Windows shortcut). o ln Command: used to create a symbolic link (shortcut). ln -s <existing file> <symbolic link filename> Hard Links: multiple copies of the same file (they can even use different names) that are linked together so when one file is changed, the other is changed as well. Deleting one of the hard linked files will not remove the other linked files. Log Files To identify and troubleshoot problems on a Linux system, you must view the events that occur over time that are stored as files – these files are known as log files and are stored in the /var/log directory. Common log files are:           boot.log – basic information regarding daemon startup obtained during system initialization. cron – information and error messages generated by the cron and at daemons. dimesg – detected hardware information obtained during system startup secure – information and error messages regarding network access generated by daemons such as sshd and xinetd. wtmp – a history of all login sessions. rpmpkgs – a list of packages installed by the Red Hat Package Manager and related error messages. dpkg.log – a list of packages installed by the Debian Package Manager and related error messages. Xorg.0.log and XFree86 – information and error messages generated by X Windows lastlog – a list of users and their last login time – must be viewed using the lastlog command. messages and syslog – detailed information regarding daemon startup and system messages. Software Install Software for Linux can consist of binary files that have been precompiled to run on certain hardware architectures such as 64-bit Intel (x86_64), or as source code, which must be compiled on the local computer before use.   A package manager provides a standard format for distributing programs as well as a central database to store information about software packages installed on the system – this allows software packages to be queried and easily uninstalled. The two most common package managers are Red Hat Package Manager (RPM – uses the rpm command) and Debian Package Manager (DPM – uses the dpkg command).

Use Quizgecko on...
Browser
Browser