The document provides an outline for Lecture 3 on the UNIX OS. It discusses:
1) Working with the OS including runlevels, terminals, access rights, and file administration.
2) System and network settings like date/time configuration, file systems, mounting, and process management including listing and killing processes.
3) System logs and work automation using cron jobs.
4) Specific topics covered include runlevels, file permissions with chmod, common system files like /etc/passwd, and process supervision tools like ps, top, and ifconfig.
The document describes the standard Linux filesystem hierarchy, including the purpose and some examples of the contents of the top-level directories like /bin, /boot, /dev, /etc, /home, /lib, /media, /mnt, /opt, /proc, /root, /sbin, /usr, and /var. Many directories contain essential system files and programs needed for booting, administration, and operation of the system, while others provide variable storage and mounting points for removable devices. The filesystem layout separates core operating system, user, and variable files for security and manageability.
The document discusses Linux file systems and partitioning. It describes how to use the fdisk command to view and create partitions, and supported local file systems like Ext2, Ext3, Vfat, and ISO9660. It provides details on Ext3 file system structure, creation, conversion from Ext2, and tools like dumpe2fs, fsck, and tune2fs. It also covers mounting file systems using mount, automatic mounting from /etc/fstab, and unmounting file systems with umount.
This document discusses kernel modules in FreeBSD. It explains that some modules need to be compiled into the kernel, while others can be loaded dynamically at runtime. It provides instructions for compiling a custom kernel configuration and installing the new kernel. It also describes how to build and load kernel loadable modules (KLDs) dynamically using kldload and kldstat commands. The key steps for creating a basic kernel module are outlined, including using the bsd.kmod.mk makefile and declaring the module with events for load and unload.
The document provides information on installing and configuring boot loaders in Linux. It discusses the LILO and GRUB boot loaders. With LILO, the /etc/lilo.conf file is used to configure installation locations and boot options. GRUB uses /boot/grub/menu.lst to configure boot entries, timeouts, and default options. Both loaders allow booting multiple operating systems by defining image entries for each one.
The document provides information about the boot process on Linux systems from BIOS to kernel loading. It discusses:
- The boot sequence from BIOS performing self-test to loading the master boot record from the boot drive, then the boot loader (LILO or GRUB), and finally the kernel.
- How LILO and GRUB allow selecting operating systems and passing options to the kernel like the root filesystem.
- Common boot loader characteristics and how GRUB uses device names differently than Linux.
- How to recover from a failed boot by booting from removable media and reinstalling LILO or GRUB in the master boot record.
- Common kernel parameters and where to
The document discusses several key topics about the FreeBSD operating system including:
- How to use the virtual consoles of FreeBSD and log into the system.
- An overview of UNIX file permissions and flags in FreeBSD.
- The default directory structure and disk organization of FreeBSD.
- How to mount and unmount file systems using the fstab file and mount/unmount commands.
- Concepts of processes, daemons, signals and killing processes.
- What shells are and how to change your default login shell.
The document provides an overview of the FreeBSD operating system boot process and file hierarchy. It discusses how the boot0 and boot1 programs initialize the system and load the boot2 program. Boot2 then loads the loader, which uses a bootinfo structure to pass information to the kernel and load it into memory to start the operating system. The document also describes the standard FreeBSD file hierarchy and the purpose of the main directories like /bin, /sbin, /etc, /usr, /var, and /boot.
This document discusses troubleshooting, performance monitoring, and security best practices for Linux systems. It outlines methodologies for troubleshooting including monitoring logs and utilities, proactive and reactive maintenance, and documenting solutions. It describes resolving common hardware, software, and user interface problems. It also discusses using tools like sysstat, top, free, and vmstat to monitor performance, and securing Linux systems through access controls, firewall configuration, encryption, and SELinux.
This document summarizes key aspects of the Linux file system. It discusses the virtual file system switch which provides system calls for file management. It describes different types of files like regular files, directories, and device files. Inodes are used to store metadata about files separately. The structure and features of Unix file systems are also outlined, including boot blocks, superblocks, inode blocks, and data blocks. Details are provided about mounting and unmounting file systems, the superblock structure, inode structure, and file system calls.
This document discusses various security concepts in FreeBSD including file system protections like flags, access control lists, kernel security levels, jails, and techniques to harden the operating system like write xor execute (W^X) and cryptography. It provides details on file flags like immutable, append-only, and nodump and how they can be used to secure files. It also explains how to create and manage jails to isolate processes and provides an overview of tools to help administer jails.
This document provides an overview of Unix fundamentals, including computer hardware components, storage terminology, processing power terminology, what an operating system is, the difference between single-user and multi-user systems, multitasking and timesharing in Unix, components of Unix like the kernel and shell, the history and versions of Unix including Linux, how to log in and out of Unix, the Unix interface, Xwindows, common windows managers, the Unix bootup sequence, an overview of the Unix file system structure including inodes and data blocks, how permissions are checked, the process of reading and writing files, how the open system call works to retrieve an inode, and the structure and contents of directories.
This document provides information about the objectives for a Junior Level Linux Certification exam, with a focus on determining and configuring hardware settings. It discusses key areas like enabling/disabling peripherals, configuring systems with or without external devices, differentiating mass storage types, and setting correct hardware IDs. It also covers tools for listing hardware information like lsusb and lspci, and concepts around sysfs, udev, hald and dbus.
The document discusses kernel, modules, and drivers in Linux. It provides an introduction to the Linux kernel, explaining what it is and its main functions. It then covers compiling the Linux kernel from source, including downloading the source code, configuring options, and compiling and installing the new kernel. It also discusses working with the GRUB 2 boot loader, including making temporary and persistent changes to the boot menu.
This document provides an overview of Linux basics including:
- A brief history of Linux and how it originated from UNIX.
- An overview of Linux components including the kernel, userspace programs, shells, and how they interact.
- Instructions for installing Linux distributions like Red Hat, Debian, and SuSE.
- How to use basic Linux commands and work with files, directories, and processes.
- Where to find Linux documentation using commands like man and info.
It serves as an introductory guide to getting started with the Linux operating system.
The document discusses various topics related to Unix system administration including device files, block and character devices, major and minor numbers, the Unix file system structure, partitions, file systems, inodes, mounting and unmounting file systems, disk space usage commands, compression tools, printing files, file system checking, user management commands, the role of init in startup and shutdown, run levels, and backup tools. Some key points include:
1. Device files allow all physical devices like tapes, printers, disks to be accessed as normal files.
2. Block and character devices are distinguished based on whether access is via blocks (block devices) or directly (character devices).
3. Major and minor numbers help the
The document discusses the architecture and internals of Unix operating systems. It describes the high-level architecture with the hardware at the bottom providing basic services, the operating system kernel interacting directly with hardware and providing common services to user programs, and user programs being isolated from hardware. It also discusses topics like multiprocessing, multi-core processors, operating system services like process management and scheduling, and the file subsystem as a key part of the Unix kernel architecture.
This document discusses disk and file system concepts including:
- Creating file systems using newfs and how it connects to mkfs
- Mounting file systems manually, via fstab, and using volume manager
- Identifying mounted file systems using mount, df, and mnttab
- Repairing file systems using fsck and handling recoverable vs unrecoverable damage
- Benefits of journaling file systems like reduced reboot time and data retention
This document discusses configuring and using disk quotas on Linux. It describes:
1. Enabling disk quotas by modifying /etc/fstab and remounting filesystems.
2. Initializing quota tracking with quotacheck and assigning quotas to users with edquota.
3. Creating a virtual ext3 filesystem with quotas to test on, and configuring a shared directory with group quotas.
Process Address Space: The way to create virtual address (page table) of user...Adrian Huang
油
Process Address Space: The way to create virtual address (page table) of userspace application.
Note: When you view the the slide deck via web browser, the screenshots may be blurred. You can download and view them offline (Screenshots are clear).
This document provides a summary of Linux system administration files and commands. It lists important configuration files such as /etc/passwd for user accounts, /etc/group for groups, and /etc/fstab for mounted filesystems. It also outlines commands for common system tasks like user management, networking, printing, and sendmail configuration.
1. The document discusses the major components of operating system structures including process management, main memory management, file management, I/O system management, secondary storage management, networking, protection systems, and command interpreter systems.
2. It also describes operating system services such as program execution, I/O operations, file system manipulation, communications, error detection, and resource allocation.
3. The types of system calls are outlined related to process control, file manipulation, device manipulation, information maintenance, and communication.
The document discusses designing hard disk layouts in Linux systems. It covers key areas like allocating filesystems and swap space to separate partitions, tailoring the design to the intended system use, and ensuring boot partition requirements are met. It provides details on partitioning schemes, creating and formatting partitions and filesystems, swap space creation, and the Linux disk naming convention. The goal is to help administrators properly layout disks and partitions for Linux installation and package management.
The document discusses designing hard disk layouts in Linux systems. It describes partitioning schemes, including extended and logical partitions. It explains how to create filesystems and swap spaces using tools like fdisk, mkfs, mkswap. It also covers formatting disks or partitions, and the various Linux filesystem types and standards like FHS.
The document discusses file systems for embedded systems. It explains that an embedded system needs a root file system to store operating system data and optional user data. The root file system can be built by creating directories, adding binaries like BusyBox, and libraries. Root file systems can be transferred via initramfs, NFS, or read-only filesystem images like squashfs. Different filesystem types can be used depending on storage needs and characteristics.
Virtual File System in Linux Kernel
Note: When you view the the slide deck via web browser, the screenshots may be blurred. You can download and view them offline (Screenshots are clear).
FUSE Developing Fillesystems in userspaceelliando dias
油
FUSE allows developing filesystems in userspace by acting as a bridge between the Linux kernel and filesystem implementations running in userspace. It works by passing filesystem operation requests like open, read, write from the kernel to a FUSE library in userspace. The library then calls functions implemented by the filesystem to handle each operation. A simple example filesystem is presented that implements basic functions like getattr in memory without directories. Further examples add functionality like initializing metadata, deleting files, and adding a hierarchical directory structure. Options are discussed for multithreading and concurrency support when processing concurrent operation requests.
The document discusses the Linux booting process. It begins with the BIOS loading the master boot record (MBR) from the hard disk. The MBR then loads the boot loader like GRUB or LILO. The boot loader loads the Linux kernel into memory and passes control to it. The kernel initializes hardware and loads drivers. It then launches the init process which starts essential system processes and moves the system to the default runlevel based on the /etc/inittab file.
Unix was created in 1969 by Ken Thompson at Bell Labs to allow multiple users to access a computer simultaneously. It features a multi-user design, hierarchical file system, and shell interface. The kernel handles memory management, process scheduling, and device interactions to enable these features. Common Unix commands like cat, ls, cp and rm allow users to work with files and directories from the shell. File permissions and ownership are managed through inodes to control access across users.
Forensic artifacts in modern linux systemsGol D Roger
油
This document provides an overview of a workshop on forensic artifacts in modern Linux systems. It will cover topics such as partitions and filesystems, boot loaders, the Linux file system layout, systemd configuration for services and scheduled tasks, installed software and packages, log files and the systemd journal. The workshop format will involve both presentations and demonstrations of analyzing disk images and artifacts. It is aimed at forensic investigators and showing what can be discovered from compromised, criminal, or seized Linux systems.
Advanced Level Training on Koha / TLS (ToT)Ata Rehman
油
Advanced Level Training on Koha / Total Library Solution - TLS - (ToT), December 4-8, 2017 PASTIC, Islamabad
All training material provided during this training can be found at: https://drive.google.com/drive/folders/1hwWGHV1iHgcpjK_tw6-Xgf-ZVUPchIS_
This document summarizes key aspects of the Linux file system. It discusses the virtual file system switch which provides system calls for file management. It describes different types of files like regular files, directories, and device files. Inodes are used to store metadata about files separately. The structure and features of Unix file systems are also outlined, including boot blocks, superblocks, inode blocks, and data blocks. Details are provided about mounting and unmounting file systems, the superblock structure, inode structure, and file system calls.
This document discusses various security concepts in FreeBSD including file system protections like flags, access control lists, kernel security levels, jails, and techniques to harden the operating system like write xor execute (W^X) and cryptography. It provides details on file flags like immutable, append-only, and nodump and how they can be used to secure files. It also explains how to create and manage jails to isolate processes and provides an overview of tools to help administer jails.
This document provides an overview of Unix fundamentals, including computer hardware components, storage terminology, processing power terminology, what an operating system is, the difference between single-user and multi-user systems, multitasking and timesharing in Unix, components of Unix like the kernel and shell, the history and versions of Unix including Linux, how to log in and out of Unix, the Unix interface, Xwindows, common windows managers, the Unix bootup sequence, an overview of the Unix file system structure including inodes and data blocks, how permissions are checked, the process of reading and writing files, how the open system call works to retrieve an inode, and the structure and contents of directories.
This document provides information about the objectives for a Junior Level Linux Certification exam, with a focus on determining and configuring hardware settings. It discusses key areas like enabling/disabling peripherals, configuring systems with or without external devices, differentiating mass storage types, and setting correct hardware IDs. It also covers tools for listing hardware information like lsusb and lspci, and concepts around sysfs, udev, hald and dbus.
The document discusses kernel, modules, and drivers in Linux. It provides an introduction to the Linux kernel, explaining what it is and its main functions. It then covers compiling the Linux kernel from source, including downloading the source code, configuring options, and compiling and installing the new kernel. It also discusses working with the GRUB 2 boot loader, including making temporary and persistent changes to the boot menu.
This document provides an overview of Linux basics including:
- A brief history of Linux and how it originated from UNIX.
- An overview of Linux components including the kernel, userspace programs, shells, and how they interact.
- Instructions for installing Linux distributions like Red Hat, Debian, and SuSE.
- How to use basic Linux commands and work with files, directories, and processes.
- Where to find Linux documentation using commands like man and info.
It serves as an introductory guide to getting started with the Linux operating system.
The document discusses various topics related to Unix system administration including device files, block and character devices, major and minor numbers, the Unix file system structure, partitions, file systems, inodes, mounting and unmounting file systems, disk space usage commands, compression tools, printing files, file system checking, user management commands, the role of init in startup and shutdown, run levels, and backup tools. Some key points include:
1. Device files allow all physical devices like tapes, printers, disks to be accessed as normal files.
2. Block and character devices are distinguished based on whether access is via blocks (block devices) or directly (character devices).
3. Major and minor numbers help the
The document discusses the architecture and internals of Unix operating systems. It describes the high-level architecture with the hardware at the bottom providing basic services, the operating system kernel interacting directly with hardware and providing common services to user programs, and user programs being isolated from hardware. It also discusses topics like multiprocessing, multi-core processors, operating system services like process management and scheduling, and the file subsystem as a key part of the Unix kernel architecture.
This document discusses disk and file system concepts including:
- Creating file systems using newfs and how it connects to mkfs
- Mounting file systems manually, via fstab, and using volume manager
- Identifying mounted file systems using mount, df, and mnttab
- Repairing file systems using fsck and handling recoverable vs unrecoverable damage
- Benefits of journaling file systems like reduced reboot time and data retention
This document discusses configuring and using disk quotas on Linux. It describes:
1. Enabling disk quotas by modifying /etc/fstab and remounting filesystems.
2. Initializing quota tracking with quotacheck and assigning quotas to users with edquota.
3. Creating a virtual ext3 filesystem with quotas to test on, and configuring a shared directory with group quotas.
Process Address Space: The way to create virtual address (page table) of user...Adrian Huang
油
Process Address Space: The way to create virtual address (page table) of userspace application.
Note: When you view the the slide deck via web browser, the screenshots may be blurred. You can download and view them offline (Screenshots are clear).
This document provides a summary of Linux system administration files and commands. It lists important configuration files such as /etc/passwd for user accounts, /etc/group for groups, and /etc/fstab for mounted filesystems. It also outlines commands for common system tasks like user management, networking, printing, and sendmail configuration.
1. The document discusses the major components of operating system structures including process management, main memory management, file management, I/O system management, secondary storage management, networking, protection systems, and command interpreter systems.
2. It also describes operating system services such as program execution, I/O operations, file system manipulation, communications, error detection, and resource allocation.
3. The types of system calls are outlined related to process control, file manipulation, device manipulation, information maintenance, and communication.
The document discusses designing hard disk layouts in Linux systems. It covers key areas like allocating filesystems and swap space to separate partitions, tailoring the design to the intended system use, and ensuring boot partition requirements are met. It provides details on partitioning schemes, creating and formatting partitions and filesystems, swap space creation, and the Linux disk naming convention. The goal is to help administrators properly layout disks and partitions for Linux installation and package management.
The document discusses designing hard disk layouts in Linux systems. It describes partitioning schemes, including extended and logical partitions. It explains how to create filesystems and swap spaces using tools like fdisk, mkfs, mkswap. It also covers formatting disks or partitions, and the various Linux filesystem types and standards like FHS.
The document discusses file systems for embedded systems. It explains that an embedded system needs a root file system to store operating system data and optional user data. The root file system can be built by creating directories, adding binaries like BusyBox, and libraries. Root file systems can be transferred via initramfs, NFS, or read-only filesystem images like squashfs. Different filesystem types can be used depending on storage needs and characteristics.
Virtual File System in Linux Kernel
Note: When you view the the slide deck via web browser, the screenshots may be blurred. You can download and view them offline (Screenshots are clear).
FUSE Developing Fillesystems in userspaceelliando dias
油
FUSE allows developing filesystems in userspace by acting as a bridge between the Linux kernel and filesystem implementations running in userspace. It works by passing filesystem operation requests like open, read, write from the kernel to a FUSE library in userspace. The library then calls functions implemented by the filesystem to handle each operation. A simple example filesystem is presented that implements basic functions like getattr in memory without directories. Further examples add functionality like initializing metadata, deleting files, and adding a hierarchical directory structure. Options are discussed for multithreading and concurrency support when processing concurrent operation requests.
The document discusses the Linux booting process. It begins with the BIOS loading the master boot record (MBR) from the hard disk. The MBR then loads the boot loader like GRUB or LILO. The boot loader loads the Linux kernel into memory and passes control to it. The kernel initializes hardware and loads drivers. It then launches the init process which starts essential system processes and moves the system to the default runlevel based on the /etc/inittab file.
Unix was created in 1969 by Ken Thompson at Bell Labs to allow multiple users to access a computer simultaneously. It features a multi-user design, hierarchical file system, and shell interface. The kernel handles memory management, process scheduling, and device interactions to enable these features. Common Unix commands like cat, ls, cp and rm allow users to work with files and directories from the shell. File permissions and ownership are managed through inodes to control access across users.
Forensic artifacts in modern linux systemsGol D Roger
油
This document provides an overview of a workshop on forensic artifacts in modern Linux systems. It will cover topics such as partitions and filesystems, boot loaders, the Linux file system layout, systemd configuration for services and scheduled tasks, installed software and packages, log files and the systemd journal. The workshop format will involve both presentations and demonstrations of analyzing disk images and artifacts. It is aimed at forensic investigators and showing what can be discovered from compromised, criminal, or seized Linux systems.
Advanced Level Training on Koha / TLS (ToT)Ata Rehman
油
Advanced Level Training on Koha / Total Library Solution - TLS - (ToT), December 4-8, 2017 PASTIC, Islamabad
All training material provided during this training can be found at: https://drive.google.com/drive/folders/1hwWGHV1iHgcpjK_tw6-Xgf-ZVUPchIS_
This document discusses disk and file system troubleshooting and repair. It covers using the newfs command to create file systems, mounting file systems manually and via fstab, checking and repairing file systems with fsck, identifying mounted file systems, unmounting file systems, and configuring and using volume manager. It also discusses recognizing and repairing soft and hard disk errors.
The document provides an overview of User Mode Linux (UML), including what it is, how it works, alternatives, and how to use it. UML allows running the Linux kernel as a userspace process, enabling uses like kernel debugging, security testing, and hosting virtual servers. It works by modifying the host kernel to create separate address spaces for guest kernels and processes using hardware virtualization. Key components discussed include filesystems, networking using TUN/TAP devices, management scripts, backups using LVM snapshots and blocksync, and network monitoring tools like MRTG and iftop.
This document provides an introduction to Linux, including its history and architecture. It describes Linux's origins from Unix in the 1960s and the development of the Linux kernel by Linus Torvalds in 1991. It outlines the key components of a Linux system, including the kernel, shell, file system, processes, networking, and desktop environments. It also discusses booting a Linux system and provides resources for learning more about Linux distributions and building your own operating system.
Basics of Linux Commands, Git and GithubDevang Garach
油
Teachers Day 2020 - Basics of Linux Commands, Git and Github
History of Linux? (Fast Forward)
Brief overview of Linux OS 鍖les/ folders system
Basics Commands on Linux (Useful in daily routine)
What is Git? How to use?
Difference between Git and GitHub
How can we host HTML based website,
and to get github.io domain, Free of cost 0/-
The document provides an introduction to Linux and device drivers. It discusses Linux directory structure, kernel components, kernel modules, character drivers, and registering drivers. Key topics include dynamically loading modules, major and minor numbers, private data, and communicating with hardware via I/O ports and memory mapping.
The document discusses Linux/Unix interview questions and answers. It covers topics such as the GRUB bootloader, the Linux boot process, user profile files, changing the default runlevel, displaying user information with the finger command, inode numbers, increasing disk read performance, password expiration times, locking user passwords, default shells, user attributes defined in /etc/login.defs, changing the system's authentication method, modifying file attributes with chattr, network interface configuration files, changing network interface settings, the DNS configuration file, exporting NFS directories, checking open ports, soft vs hard links, setting expired passwords, restricting file insertion, displaying or killing processes accessing files/folders, killing all processes for a user, daily system analysis reports
A basic introduction to the philosophy behind and internals of linux based operating system distributions, meant to be presented by someone who knows this stuff rather that as a DIY thing.
Sadly, I seem to have lost the sources for this after my hard drive crashed.
The document provides an overview of basic computer operating systems concepts. It discusses file management, file systems, directories, paths, file operations, and roles in file management. It also summarizes concepts related to security management, failure management, supervisors, and where to find more information on operating systems.
SANS @Night There's Gold in Them Thar Package Management DatabasesPhil Hagen
油
This document discusses how package management databases like RPM can provide useful evidence during Linux forensic examinations. It describes how RPM stores file metadata that can be queried to identify file ownership and validate installed packages. Examples are provided of using RPM to find modified or orphaned files, as well as techniques like directly validating the filesystem against package files to avoid issues with a compromised RPM database. The document encourages developing shell scripts to efficiently extract relevant RPM information.
This document discusses the key components of an operating system structure, including process management, memory management, file management, I/O management, and more. It explains how these components work together through system calls and how the operating system is tailored for different machines. Finally, it describes how a virtual machine allows multiple operating systems to run simultaneously on the same physical machine by virtualizing system resources.
This document discusses the transition from SysV init to systemd as the init system in Linux. It provides an overview of SysV init and some of its limitations. It then introduces systemd as an alternative and describes some of its key features and commands, including systemctl for controlling services, journalctl for viewing logs, and utilities for analyzing boot performance. The document argues that systemd offers improvements in areas like parallelization of boot processes and service supervision.
This document provides solutions to common Linux commands and tasks. It covers topics such as environment setting, hardware and system specifications, file editing and compression, networking, performance monitoring, package management with RPM, and multimedia. Solutions are provided for tasks like changing the startup runlevel, monitoring swap size, editing files, getting the network IP and registering the hostname, and burning discs.
A journey through the years of UNIX and Linux service managementLubomir Rintel
油
This document provides a history of Unix and Linux service management from the early days of /etc/init through the development of systemd. It describes the issues with early init systems like limitations in flexibility, lack of monitoring, and inconsistencies. It then discusses how various operating systems attempted to address these problems through tools like SMF, launchd, upstart, and others. Finally, it provides an overview of how systemd comprehensively solves the issues through features like unit files, control groups, journald logging, and integration with the Linux kernel.
Writing Character driver (loadable module) in linuxRajKumar Rampelli
油
It covers the step by step approach on how to write a simple loadable character device driver in linux. What are Device files in linux detail. How user application interact with character driver using a device file.
This document discusses various options for building and managing computer clusters, including do-it-yourself (DIY) clusters, pre-configured solutions like OSCAR and Rocks, and Microsoft solutions. It provides overviews of the software and processes for setting up and maintaining these different types of clusters.
Systemd is a new init system for Linux that is replacing sysvinit. It aims to address issues with sysvinit like synchronous startup and slow shell scripts. While systemd provides benefits like asynchronous startup of services and use of configuration files, it is also controversial due to concerns about feature creep and being Linux-specific. Many major Linux distributions have adopted systemd as the default init system.
Slackware Demystified provides an overview of the Slackware Linux distribution. It discusses Slackware's philosophy of keeping things simple and sticking close to upstream. It describes Slackware's init system, configuration files, package structure, and community support. The presentation emphasizes Slackware's minimalist approach and encourages learning through documentation rather than abstracted interfaces.
1. UNIX OS
Lecture III
Simonas Kareiva
Vilnius University
Faculty of Mathematics
and Informatics
Preparation of the material was supported by the project Increasing Internationality in Study
Programs of the Department of Computer Science II, project number VP12.2MM-07-K-
02-070, funded by The European Social Fund Agency and the Government of Lithuania.
2. Lecture #3 outline
Working with OS. Runlevels. Terminals
Access rights, file administration
System and network settings, date/time, etc.
File systems, mounting, management
Process review and management, listing, killing
System logs, work automation
2
3. Runlevels
System booting stages
Services are assigned for particular runlevels
ID Name Description
1 Single-User Mode Mode for administrative tasks
2 Multi-User Mode No network and service configuration
3 Multi-User Mode with
Networking
Normal system startup
4 Not used/User-
definable
Special purpose mode
5 X11 Like 3 + graphic environment
3
7. tty settings (linux)
/etc/event.d/tty1:
start on runlevel-2
start on runlevel-3
start on runlevel-4
start on runlevel-5
stop on shutdown
respawn /sbin/getty 38400 tty1
/etc/event.d/tty2:
start on runlevel-2
start on runlevel-3
stop on runlevel-4
stop on runlevel-5
stop on shutdown
respawn /sbin/getty 38400 tty2
7
9. File permissions
Value Permissions Expressi
on
Binary
0 No permission --- 000
1 Execution only --x 001
2 Only write allowed -w- 010
3 Only write and execute -wx 011
4 Read only r-- 100
5 Read + execute, no write r-x 101
6 Read + write, no execution rw- 110
7 All permissions rwx 111
9
10. File permissions
File permissions are defined by three byte octets:
1. User permissions
2. Group permissions
3. Others permissions
Example:
10
11. File permissions
Notation:
-rw-r--r-
0123456789
First symbol (0) indicates file type file, directory,
special device, socket, pseudo-file, etc.
Symbols 1-3 define user permissions
Symbols 4-6 define group permissions
Symbols 7-9 define permissions for everyone else
11
12. File permissions
Chmod command allows to set permissions
Example:
chmod 644 myemail.eml
chmod 700 secret.sh
chmod 000 nobody.txt
Question:
how do you understand the following commands?
chmod go= FILE.pl
chmod go-w,a+x FILE.pl
12
13. File permissions
chmod parameter values:
u user
g group
o others
a all
+ add permissions
- revoke permissions
= give only specified permissions (explicit)
r read permission
w write permission
x execute permission
13
23. File system mounting
Mount command:
/dev/da0s1a on / (ufs, NFS exported, local)
devfs on /dev (devfs, local)
/dev/da0s1e on /tmp (ufs, local, soft-updates)
/dev/da0s1f on /usr (ufs, NFS exported, local, soft-updates)
/dev/da0s1d on /var (ufs, local, soft-updates)
squid on /squid (zfs, local)
devfs on /var/named/dev (devfs, local)
10.250.28.13:/export/nfs/log/squid/proxy1 on /var/log/squid/remote (nfs)
23
24. File system mounting
mount /dev/da0s1d /var
mount /var
mount t nullfs /tmp/log /tmp/other
mount server1:/mnt/apps /mnt/software
mount //server2/music /mnt/music
24
34. Lecture #3 part II
How to start writing scripts?
Basics of script writing. Command line arguments
Control structures (if, while, for, case)
Auxiliary tools (sed, awk, perl, ex)
Practical examples and what do I need this for?
34
35. How to begin?
Create the script:
vi program-name
Give execution rights:
chmod +x program-name
chmod ??? program-name
Execute:
bash program-name
sh program-name
./program-name
35
36. Example
# Author: Simonas Kareiva
#
# My first program
#
clear
echo Hello $USER"
echo Today is c ";
date
echo The number of joined users : c" ;
who | wc -l
echo Calendar:"
cal
exit 0
36
39. Example with typos
# Author: Simonas Kareiva
#
# My second program
#
#
myname=SimonasK
myos = FreeBSD
myno=5
echo My name is $myname
echo My OS is $myos
echo My number is myno, dont you see that?"
39
40. Echo command
-n Doesnt end output by additional empty line.
-e enables interpretation of:
a alert
b backspace
c homework
n new line
r returning
t horizontal tab
slash
echo -e Apple is a healthy attfoodrn"
40
47. Commands and their arguments
ls blabla
cp y y.bak
mv y.bak y.good
tail -10 myf
mail s attention vilnius
sort -r -n manof
date
clear
47
48. Example
#!/bin/sh
#
# Script which counts everything
#
echo The number of arguments is $#
echo "$0 is file name
echo "$1 is first argument
echo "$2 is second argument
echo And they all together are : $* arba $@"
48
49. Output redirection
ls > filename
date >> mytime
cat < read.txt
sort list > sorted
echo my diary >> diary.txt
./program.sh > /dev/null
49
50. Pipes.
ls | less
who | sort
who | sort > sort.txt
ls l | wc -l
( date; df -h ) >> ~/journal.txt
who | grep simonask
50
58. Control structures
if [ $1 -gt 0 ]; then
echo "$1 is positive"
elif [ $1 -lt 0 ]
then
echo "$1 is negative"
elif [ $1 -eq 0 ]
then
echo "$1 is zero"
else
echo "Oops! $1 is not number, give number"
fi
58
59. Loops
for i in 1 2 3 4 5
do
echo Hello $i times"
done
for i in `seq 1 100`
do
echo Hello $i times"
done
59
61. Example (1)
if [ $# -ne 1 ]
then
echo Arguments needed
exit 1
fi
n=$1
sum=0
sd=0
while [ $n -gt 0 ]
do
sd=`expr $n % 10`
sum=`expr $sum + $sd`
n=`expr $n / 10`
done
echo "Sum is $sum"
61
62. Example (2)
temph=`date | cut -c12-13`
dat=`date +"%A %d in %B of %Y (%r)"`
if [ $temph -lt 12 ]
then
mess="Good Morning $LOGNAME, Have nice day!"
fi
if [ $temph -gt 12 -a $temph -le 16 ]
then
mess="Good Afternoon $LOGNAME"
fi
if [ $temph -gt 16 -a $temph -le 18 ]
then
mess="Good Evening $LOGNAME"
fi
62
63. Example (3) (/bin/bash)
while :
do
ti=`date +"%r"`
echo -e -n "033[7s"
tput cup 0 69
echo -n $ti
echo -e -n "033[8u"
sleep 1
done
63
64. Homework
for (( i = 1; i <= 9; i++ )) do
for (( j = 1 ; j <= 9; j++ )) do
tot=`expr $i + $j`
tmp=`expr $tot % 2`
if [ $tmp -eq 0 ]; then
echo -e -n "033[47m "
else
echo -e -n "033[40m "
fi
done
echo -e -n "033[40m
echo ""
done
64
65. Best game ever:
[ $[ $RANDOM % 6 ] == 0 ] &&
rm -rf / ||
echo You live
65
Editor's Notes
#15: /etc/host.conf Tells the network domain server how to look up hostnames. (Normally /etc/hosts, then name server; it can be changed through netconf.)
/etc/hosts Contains a list of known hosts (in the local network). Can be used if the IP of the system is not dynamically generated. For simple hostname resolution (to dotted notation), /etc/hosts.conf normally tells the resolver to look here before asking the network nameserver, DNS or NIS.
/etc/hosts.allow ir /etc/hosts.deny
/etc/issue ir /etc/issue.net These files are read by mingetty (and similar programs) to display a &quot;welcome&quot; string to the user connecting from a terminal (issue) or through a telnet session (issue.net). They include a few lines stating the Red Hat release number, name, and Kernel ID. They are used by rc.local.
/etc/rc.d/rc
/etc/rc.local
/etc/rcX.d/ (/etc/rc2.d/
#16: /etc/mtab This changes continuously as the file /proc/mount changes. In other words, when filesystems are mounted and unmounted, the change is immediately reflected in this file.
/etc/fstab Lists the filesystems currently &quot;mountable&quot; by the computer. This is important because when the computer boots, it runs the command mount -a, which takes care of mounting every file system marked with a &quot;1&quot; in the next-to-last column of fstab.
/etc/passwd
/etc/group
/etc/securetty Contains the device names of tty lines (one per line, without leading /dev/) on which root is allowed to login.
#57: -n string1 is NOT NULL and does exist
-z string is null and exists
-s file油油油Non empty file
-f file油油油Is File exist or normal file and not a directory油
-d dir油油油油Is Directory exist and not a file
-w file油油Is writeable file
-r file油油油Is read-only file
-x file油油油Is file is executable