0% found this document useful (0 votes)
147 views

Chapter 5

Operating systems control and manage computer hardware resources, connect users to computers, and coordinate programs; core OS functions include process management, memory management, and file system management. Linux is an open-source, Unix-like operating system that was initially developed by Linus Torvalds as a hobby and provides multitasking, a powerful shell interface, security protections, and can run on various hardware platforms. Key components of an operating system include the kernel which controls hardware and provides system calls, processes for running programs, and a file system for organizing and accessing files.

Uploaded by

Carl Cadalin
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
147 views

Chapter 5

Operating systems control and manage computer hardware resources, connect users to computers, and coordinate programs; core OS functions include process management, memory management, and file system management. Linux is an open-source, Unix-like operating system that was initially developed by Linus Torvalds as a hobby and provides multitasking, a powerful shell interface, security protections, and can run on various hardware platforms. Key components of an operating system include the kernel which controls hardware and provides system calls, processes for running programs, and a file system for organizing and accessing files.

Uploaded by

Carl Cadalin
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 8

Chapter 5: Operating System Basics must provide an access interface,

that is, the system call interface.

Operating System – is a special computer


program that controls the computer, 2.) Library functions: System calls are
connects the computer and the user, and encapsulated as library functions to
coordinates and manages hardware provide simple service logic
resources, including the CPU, drive, interfaces to users. Simple access to
memory, and printer. system resources can be completed
using system calls. Library functions
allow for complex access to system
Core Functions of Operating System resources.
 System Call Interface
 Process Management 3.) Shell: A shell is a special application
 Memory Management program, which is also called the
 File System Management command line interface. It is a
 Driver Management command interpreter in essence. It
can execute texts (scripts) that
comply with the shell syntax. Some
Main Stream OSs shell script statements encapsulate
From the perspective of application field, system calls for convenient use.
OSs are classified into the following types:
4.) Kernel: The kernel controls
 Desktop OS
hardware resources, manages OS
 Server OS
resources, and provides a system call
 Host OS
interface for applications.
 Embedded OS

Based on whether an OS is open source, it Process scheduling and management


is classified as:  The kernel creates and destroys
 Open-Source OS (Linux and Unix) processes and handles their input
 Close Source OS (Windows and Mac and output.
OS)
Memory management

Components of an OS  The kernel creates a virtual address


space for all processes based on
From the perspective of users, an OS
limited available resources.
consists of a kernel and various applications,
that is the kernel space and user space.
File System Management
 The user space is where upper-layer
applications run.  Linux is based on the concept of file
 The kernel is essentially a software system to a large extent. Almost
program used to manage computer anything in Linux can be seen as a
hardware resources and provide a file. The kernel builds a structured
system call interface to run upper- file system on top of unstructured
layer application programs hardware.

1.) System calls: The execution of Device Driver Management


applications depends on resources
 Drivers of all peripherals in the
provided by the kernel, including the
system, such as hard drives,
CPU, storage, and I/O resources. To
keyboards, and tape drives, are
enable upper-layer applications to
embedded in the kernel.
access these resources, the kernel
Network Resource Management he was studying at the University of
Helsinki. Frustrated by MINIX, a
 All routing and address resolution
Unix-like OS for educational
operations are performed in the
purposes, he decided to develop his
kernel.
own OS. The first version was
released in September 1991 with
Generally speaking, user-mode applications only 10,000 lines of code.
can access kernel-mode resources using the  Unix systems are usually compatible
system calls, shell scripts, and library only with specific hardware. This
functions. means that most Unix systems such
as AIX and HP-UX cannot be installed
on x86 servers or PCs. On the
Different Types of OSs contrary, Linux can run on various
hardware platforms.
UNIX
 Unix is commercial software, while
 A multi-user and multi-process OS. It Linux is open source and free of
supports large-scale file system charge.
services and data service
application, provides powerful
Features of LINUX
functions, and ensures high stability
and security. Linux is a popular multitasking and multi-
 Common UNIX OSs: HP-UX, IBM AIX, user OS with the following features:
Solaris, and A/UX

Multitasking: Linux is a multitasking


GNU/LINUX
operating system that allows multiple tasks
 Linux is a general term for Unix-like to run at the same time. DOS is a single-
OSs. Linux runs with high security task OS and cannot run multiple tasks at
and stability and has a complete the same time. When the system executes
permission control mechanism. multiple tasks, the CPU executes only one
 Common Linux OSs: SUSE Linux, task at a time. Linux divides the CPU time
Kylin, Red Flag Linux, CentOS, RHEL, into time slices and allocates them to
and openEuler multiple processes. The CPU runs so quickly
that all programs (processes) seem to be
running at the same time from the user's
Windows
perspective.
 Windows Server is a server OS
released by Microsoft. It is mainly
used on servers and provides a user- Multi-user: Linux is a multi-user OS that
friendly GUI. allows multiple users to use it at the same
 Common Windows Server versions: time. In Linux, each user runs their own or
2000, 2003, 2008, 2012, 2016 and public programs as if they had a separate
2019 machine. DOS is a single-user OS and allows
only one user to use it at a time.

History behind Linux and Unix:


Pipeline: Linux allows the output of a
 Linux is a Unix-like OS with program to be used as the input of the next
optimized functions and user program. Multiple programs are chained
experience. Linux mimics Unix in together as a pipeline. By combining simple
terms of appearance and tasks, you can complete complex tasks,
interaction. improving the operation convenience. Later
 The Linux kernel was initially written versions of DOS learned from Linux and
by Linus Torvalds for a hobby when implemented this mechanism.
Powerful shells: Shells are the command
interpreters of Linux. Linux provides
 /bin - short for binary. This directory
multiple powerful shells, each of which is an
stores the frequently used
interpreted high-level language. Users can
commands.
create numerous commands through
 /boot - stores some core files used
programming.
for booting the Linux OS, including
some links and images.
 /dev - short for device. This
Security protection mechanism: Linux
directory stores peripheral device
provides a powerful security protection
files of Linux. The method of
mechanism to prevent unauthorized access
accessing devices on Linux is the
to the system and its data.
same as that of accessing files.
 /etc - stores all configuration files
and subdirectories required for
POSIX 1.0 compatibility: The Portable
system management.
Operating System Interface (POSIX) is a
 /lib - stores basic shared libraries of
family of standards specified by IEEE. POSIX
the system. A library functions
defines the application programming
similarly to a dynamic link library
interfaces (APIs) of software runs on Unix.
(DLL) file on Windows. Almost all
The family of POSIX standards is formally
applications need to use these
designated as IEEE 1003 and the ISO/IEC
shared libraries.
standard number is ISO/IEC 9945. The name
of POSIX consists of the abbreviation of  /media - Some devices, such as USB
Portable Operating System Interface and an flash drives and CD-ROM drives, are
X that indicates the inheritance of Unix automatically identified and
APIs. mounted to this directory by the
Linux system.
 /mnt - temporary mount point for
Linux File Directory Structure other file systems. You can mount
the CD-ROM drive to /mnt and then
 /bin – Directory for all user program go to this directory to view
binary files  /opt - stores additional software
 /boot – Directory for boot loader installed on the host. For example, if
files you install an Oracle database, you
 /dev – Device File Directory can save the installation package to
 /etc – Configuration File Directory this directory. By default, this
 /lib - System Library Directory directory is empty. the contents in
 /lib64 – 64-bit System Library the CD-ROM.
Directory
 /media – Removable Media Device
Background of openEuler
Directory
 /mnt – Mount Directory  EulerOS is a server OS that runs on
 /opt – Directory for Storing the Linux kernel and supports
Application Software processors of multiple architectures,
such as x86 and ARM. It is ideal for
database, big data, cloud computing,
The core philosophy of Linux is "everything
and artificial intelligence (AI)
is a file", which means that all files,
scenarios.
including directories, character devices,
 Over the past decade, EulerOS has
block devices, sockets, printers, processes,
interconnected with various Huawei
threads, and pipes, can be operated, read,
products and solutions. It is
and written by using functions such as
respected for its security, stability,
fopen(), fclose(), fwrite(), and fread().
and efficiency.
 Cloud computing, in addition to The file system organizes and allocates the
Kunpeng processors, has sparked space on file storage devices, stores files,
the growth of EulerOS to become and
the most powerful software
protects and retrieves the stored files.
infrastructure in the Kunpeng
Specifically, it is responsible for creating files
ecosystem.
for users, saving, reading, modifying, and
 To develop the Kunpeng ecosystem
dumping files, controlling access to files,
and build prosperity of the
and canceling a file that is no longer in use.
computing industry in China and
around the world, the open-source
version of EulerOS was officially
Functions of a file system include
released as openEuler at the end of
2019.  Manages and schedules storage
space of a file.
 Provides the logical structure,
Introduction to openEuler physical structure, and storage
method of the file
 openEuler is a free open-source
 Maps file identifiers to actual
Linux distribution that supports
addresses, controls and accesses
multiple processor architectures
files, shares file information,
including x86, ARM, and RISC-V. All
 Provides reliable file confidentiality
developers, enterprises, and
and protection measures
business organizations can simply
 Provides file security measures.
use the openEuler community
version, or use it to build, develop,
and release their own OS versions.
File Systems on openEuler
 The openEuler kernel is derived
Linux Kernel: from Linux. The Linux kernel
supports more than 10 types of file
 Red Hat systems, such as Btrfs, JFS, ReiserFS,
 Debian ext, ext2, ext3, ext4, ISO 9660, XFS,
 SUSE Minix, MSDOS, UMSDOS, VFAT,
 openEuler NTFS, HPFS, SMB, SysV and PROC.
 The default file system on
openEuler is ext4.
Introduction to File Systems on openEuler

Common File System


Ext
 File system specially designed for
Linux. The latest version is ext4.

XFS
A file system is a method and a data
structure used by an OS to identify files on a  A high-performance log file system
storage device or a partition, that is, a developed for the IRIX OS by Silicon
method of organizing files on a storage Graphics in 1993. Later ported to the
device. Linux kernel, it excels in large-file
processing and provides smooth
In an OS, a software structure that manages data transfer.
and stores file data is referred to as a file
management system, or file system for
VFAT
short.
 On Linux, VFAT is the name of the Sometimes, the only choice
FAT (including FAT 16 and FAT 32) file  Most servers choose not to install a
systems in DOS and Windows. GUI.
 Tools for maintaining and managing
ISO 9600 network devices do not provide a
GUI.
 The standard file system for optical
disc media. Linux supports this file
system. Allowing the system to read Linux CLI Shortcuts
CD-ROMs and ISO image files, and Tab Completion
burn CD-ROMs.
 Use the Tab key to complete a
command or file name, which is
Graphical User Interface (GUI) time-saving and accurate.
 A graphical user interface (GUI)  When no command is entered, press
presents all elements as graphical. Tab twice to list all available
The mouse is used as the main input commands.
tool, and buttons, menus, and dialog  If you have entered a part of the
boxes are used for interaction, command name or file name, press
focusing on ease of use. Tab to complete it automatically.

Command Line Interface (CLI) Cursor Control


 All elements on a command line  Press ↑ several times to display
interface (CLI) are character-based. historical commands for quick
The keyboard is used as the input execution.
tool to enter commands, options,  Press ↓ together with ↑ for
and parameters for executing choosing a historical command.
programs, achieving high efficiency.  Press Home to move the cursor to
 enter bc to start the calculator the beginning of the line.
 Press Ctrl + A to move the cursor to
the beginning of the line.
Why we use CLIs?
 Press Ctrl + E to move the cursor to
On Linux, we generally choose the CLI over the end of the line.
the GUI for management operations.  Press Ctrl + L to clear the screen.
The reasons are as follows:
Higher Efficiency Changing the Password
 On Linux, it is faster to perform  Passwords are used to ensure the
operations on a keyboard than using security of the Linux system and
the mouse. data.
 A GUI-based operation cannot be
To ensure system security, you should:
repeated, while a CLI script can be
used to complete all required tasks,
 Change the password upon the first
for example, deleting outdated log
files. login.
 Change passwords periodically.
 Set a complex password, for
Lower overhead compared with a GUI
example, a password containing
 Running a GUI requires a large more than eight characters and at
amount of system resources. With least three types of the following
the CLI, system resources can be characters: uppercase letters,
released and allocated to other lowercase letters, digits, and special
operations. characters.
For security purposes, openEuler does not command can safely shut down the
display the password when you enter it and system. It is dangerous to shut down
does not use any placeholders to indicate the Linux system by directly
the number of characters. powering off the system. Different
from Windows, Linux runs many
processes in the background.
Types of Linux Users Therefore, forcible shutdown may
On Linux, you need to use a user account to cause loss of process data, making
log in to the system. Linux allows multiple the system unstable and even
users to exist at the same time. On Linux, a damaging hardware in some
UID is used to uniquely identify a user. systems.
 If you run the shutdown command
to shut down the system, the system
Super User
administrator notifies all users who
 It is also called the super have logged in that the system will
administrator. Its UID is 0. The super be shut down and the login
user has all system permissions. It is command will be frozen, prohibiting
similar to the administrator in new user logins.
Windows.

Parameters for Shutdown Command


System Users
 -h: powers off the computer after it
 It is also called program users, have is shut down.
UIDs ranging from 1 to 999. A  -r: powers on the computer after it is
system user is created by a program shut down. (This operation is
and is used to run the program or equivalent to restarting the
service. computer.)
 -p: explicitly indicates that the
system will be shut down and the
Common Users
main power supply will be cut off.
 are generally created by the super
administrator (the root user) to
perform limited management and Reboot
maintenance operations on the  is used to restart the computer,
system. UIDs of common users range which requires root permissions.
from 1000 to 60000.

Parameters of the Reboot Command


Creating and deleting a Linux User
 -w: writes records to the
Common Command for User Management:
/var/log/wtmp file. It does not
 Creating a user (common user by restart the system.
default): useradd username  -d: does not write records to the
 Viewing user information: id /var/log/wtmp file.
username  -i: restarts the system with network
 Switching users: su – username settings disabled.
 Deleting a user: userdel username

File Paths
Basic openEuler Commands
File paths on Linux include absolute paths
Power Supply Commands: shutdown and and relative paths.
reboot
 shutdown is used to shut down the
Absolute Path
computer, which requires root
permissions. The shutdown
 a path starting with the root  The less and more commands are
directory (/), for example, used to view large files page by
/root/Desktop. page. Enter q to exit. Enter a slash (/)
and a keyword to search for the
Relative Path keyword in the file.

 a path starting from the current


path, for example, ./Desktop. ./ or .
 indicates the current path. ../ or .. Creating Files
indicates the upper-level directory of
 mkdir: Creating directories (folders)
the current path.
 -p: cascades to create multiple
directories recursively.
pwd: Viewing the current path  touch: Creating common files
cd: Switching paths
Syntax: cd [directory] Copying Files
 cd /usr: goes to the /usr directory  cp: Copying files or directories
 cd..: goes to the upper-level  -a: copies the files of a directory
directory. Double dot indicates the while retaining the links and file
parent directory. attributes.
 cd.: goes to the current directory.  -r: If the source file is a directory, all
 cd: goes to the home directory by subdirectories and files in the
default if no parameter is added. directories are copied recursively
 cd -: goes to the previous directory. and the attributes are retained.
This command is used to quickly
switch between two directories.
The cp command is used to copy files and
 cd ~: goes to the home directory.
directories. You can copy one or more files
at a time. Exercise caution when running
Viewing Files this command because data loss risks are
involved.
 ls: Viewing the content of a directory
 cat, tail or head: Viewing the
content of a common file Syntax: cp [OPTION]... SOURCE...
 -a: lists all files including hidden files DIRECTORY
 -l: displays file details in long format
 -a: copies the files of a directory
 -R: lists files in the subdirectories
while retaining the links and file
recursively
attributes.
 -t: lists files by modification time.
 -p: copies the file content,
 The cat command is used to view
modification time, and access
contents of a small file. This
permissions to the new file.
command displays all lines in a file.
 -r: if the source file is a directory, all
 The tail command is used to view
subdirectories and files in the
the last 10 lines of a file by default.
directories are copied
 -n: followed by a number, for
example, 5, indicating that the last  -l: creates a hard link of the source
five lines of a file are viewed. You file instead of copying it.
can also enter a number directly  -s: creates a soft link of the source
without the -n option. file instead of copying it.
 -f: dynamically displays file changes.
This option is commonly used for
viewing log files. cp command examples:
 The head command is used to view  cp f1 f2: copies file f1 and renames it
the first 10 lines of a file by default. to f2.
 cp f1 d1/: copies f1 to the d1 Deleting Files
directory without renaming it. rm: Deleting files or directories
 cp f1 f2 f3 d1/: copies multiple files
The rm command is a high-risk command.
to a directory.
No tool can guarantee recovery of files
 cp -i f1 f2: waits for the user's
deleted by the rm command, which doesn't
confirmation before overwriting f2 if
move a file to a recycle bin like in GUIs.
f2 already exists. cp -r d1 d2: copies
Therefore, you cannot undo the deletion.
a directory recursively if the -r
option is added.
 cp -rv d1 d2: displays the copy Syntax: rm [OPTION] file_or_directory
process if the -v option is added.
 -f, --force: ignores the files that do
 cp -s d1 d2: creates a soft link d2 of
not exist and does not display any
the source file d1 instead of copying
message.
it
 -i, --interactive: performs interactive
 cp -a f1 f2: if the -a option is added,
deletion.
the attributes of the source file are
 -r, -R, --recursive: recursively deletes
retained.
all directories listed as arguments
 This option is used to copy block
and their subdirectories.
devices, character devices, and
 -v, --verbose: displays the detailed
named pipes.
progress.
 By default, the cp command does
not ask the user before overwriting
files. Therefore, many shells have Obtaining Help Information About
made cp as an alias for cp -i. The -f Command
option in the cp command does not
 To navigate the massive number of
indicate forcible overwriting.
commands on Linux, you can run the
help command to obtain help
Moving and Renaming Files information.
mv: Moving or renaming a file
 The mv command is used to move a help: Obtaining simple help information
file or directory. Exercise caution about a command
when running this command
because data loss risks are involved.
Syntax: [command] --help or help
 If the source file and target file are in
[command].
the same directory, the mv
command is used to rename the file.  -d: displays a brief description of the
command topic.
 s: displays a brief description of the
Syntax: mv [option] command syntax.
source_file_or_directory
target_file_or_directory

 -b: backs up a file before overwriting


it.
 -f: forcibly overwrites the target file
without asking the user.
 -i: overwrites the target file after
obtaining the user's consent.
 -u: updates the target file only when
the source file is newer than the
target.

You might also like