Cloud Computing - Chapter 5
Cloud Computing - Chapter 5
Foreword
2 Huawei Confidential
Objectives
3 Huawei Confidential
Contents
2. Linux Basics
4 Huawei Confidential
Operating System Definition and Functions
⚫ An operating system (OS) is a computer program (system software) that manages and
controls computer hardware and software resources.
User
Core functions:
⚫ Driver management
Hardware
5 Huawei Confidential
• Mainstream OSs:
▫ From the perspective of application field, OSs are classified into the
following types:
2. Linux Basics
6 Huawei Confidential
Components of an Operating System
⚫ From the perspective of users, an OS consists of a kernel and various applications, that is, the kernel space and
user space.
⚫ The user space is where upper-layer applications run.
⚫ The kernel is essentially a software program used to manage computer hardware resources and provide a system
call interface to run upper-layer application programs.
Applications
and shells
Function
libraries
System Calls
Kernel
7 Huawei Confidential
• Shell: A shell is a special application program, which is also called the command
line interface. It is a command interpreter in essence. It can execute texts (scripts)
that comply with the shell syntax. Some shell script statements encapsulate
system calls for convenient use.
• The kernel controls hardware resources, manages OS resources, and provides a
system call interface for applications.
▫ Process scheduling and management: The kernel creates and destroys
processes and handles their input and output.
▫ Memory management: The kernel creates a virtual address space for all
processes based on limited available resources.
▫ File system management: Linux is based on the concept of file system to a
large extent. Almost anything in Linux can be seen as a file. The kernel
builds a structured file system on top of unstructured hardware.
▫ Device driver management: Drivers of all peripherals in the system, such as
hard drives, keyboards, and tape drives, are embedded in the kernel.
▫ Network resource management: All routing and address resolution
operations are performed in the kernel.
• Summary: User-mode applications can access kernel-mode resources using the
following:
▫ System calls
▫ Shell scripts
▫ Library functions
Contents
2. Linux Basics
9 Huawei Confidential
Common Server OSs
A multi-user and multi-process OS. It supports large-scale file Common Unix OSs:
HP-UX, IBM AIX, Solaris,
UNIX system services and data service applications, provides powerful and A/UX.
functions, and ensures high stability and security.
Linux is a general term for Unix-like OSs. Linux runs with high Common Linux OSs:
GNU/ SUSE Linux, Kylin, Red Flag
Linux security and stability and has a complete permission control Linux, CentOS, RHEL, and
openEuler.
mechanism.
10 Huawei Confidential
▫ The Linux kernel was initially written by Linus Torvalds for a hobby when
he was studying at the University of Helsinki. Frustrated by MINIX, a Unix-
like OS for educational purposes, he decided to develop his own OS. The
first version was released in September 1991 with only 10,000 lines of code.
▫ Unix systems are usually compatible only with specific hardware. This
means that most Unix systems such as AIX and HP-UX cannot be installed
on x86 servers or PCs. On the contrary, Linux can run on various hardware
platforms.
▫ Unix is commercial software, while Linux is open source and free of charge.
▫ GNU is a recursive acronym for "GNU's Not Unix". Linux provides a kernel,
and GNU provides a large amount of free software to enrich the various
applications run on the kernel.
Contents
2. Linux Basics
◼ Introduction to Linux
Introduction to openEuler
Introduction to File Systems on openEuler
Basic openEuler Operations
11 Huawei Confidential
Features of Linux
⚫ Multi-platform design
Linux can run on multiple hardware platforms. The Linux kernel is also used in embedded systems
that run on devices such as handheld computers and set-top boxes.
⚫ Multi-user and multitasking
System resources can be used by different users. Multiple programs can run simultaneously and
independently.
⚫ Free to use
The source code of Linux is available for free. Users can edit and modify the source code as
required.
⚫ Fully compatible with the POSIX.1 standard
⚫ Inherits the design concept of Unix
Everything is a file.
12 Huawei Confidential
13 Huawei Confidential
• The core philosophy of Linux is "everything is a file", which means that all files,
including directories, character devices, block devices, sockets, printers, processes,
threads, and pipes, can be operated, read, and written by using functions such as
fopen(), fclose(), fwrite(), and fread().
• After logging in to the system, enter the ls / command in the current command
window. The command output similar to the figure is displayed. The directories
are described as follows:
▫ /bin: short for binary. This directory stores the frequently used commands.
▫ /boot: stores some core files used for booting the Linux OS, including some
links and images.
▫ /dev: short for device. This directory stores peripheral device files of Linux.
The method of accessing devices on Linux is the same as that of accessing
files.
▫ /etc: stores all configuration files and subdirectories required for system
management.
▫ /lib: stores basic shared libraries of the system. A library functions similarly
to a dynamic link library (DLL) file on Windows. Almost all applications
need to use these shared libraries.
▫ /mnt: temporary mount point for other file systems. You can mount the CD-
ROM drive to /mnt and then go to this directory to view the contents in the
CD-ROM.
▫ /opt: stores additional software installed on the host. For example, if you
install an Oracle database, you can save the installation package to this
directory. By default, this directory is empty.
Contents
2. Linux Basics
Introduction to Linux
◼ Introduction to openEuler
Introduction to File Systems on openEuler
Basic openEuler Operations
14 Huawei Confidential
Background of openEuler
⚫ EulerOS is a server OS that runs on the Linux kernel and supports processors of multiple
architectures, such as x86 and ARM. It is ideal for database, big data, cloud computing,
and artificial intelligence (AI) scenarios.
⚫ Over the past decade, EulerOS has interconnected with various Huawei products and
solutions. It is respected for its security, stability, and efficiency.
⚫ Cloud computing, in addition to Kunpeng processors, has sparked the growth of EulerOS
to become the most powerful software infrastructure in the Kunpeng ecosystem.
⚫ To develop the Kunpeng ecosystem and build prosperity of the computing industry in
China and around the world, the open source version of EulerOS was officially released as
openEuler at the end of 2019.
15 Huawei Confidential
Introduction to openEuler
⚫ openEuler is a free open source Linux distribution that supports multiple processor
architectures including x86, ARM, and RISC-V.
⚫ All developers, enterprises, and business organizations can simply use the openEuler
community version, or use it to build, develop, and release their own OS versions.
https://openeuler.org/
https://gitee.com/openeuler/
16 Huawei Confidential
Relationship Between openEuler and Mainstream OSs
Linux
Kernel
Community edition
Fedora • The upstream community
Red Hat Commercial edition Free edition of openEuler, SUSE,
RHEL CentOS Debian, and Red Hat is
the kernel community
www.kernel.org.
Debian Ubuntu • The openEuler
community releases free
long-term support (LTS)
Commercial edition versions, enabling
SLES
SUSE operating system vendors
Free edition
openSUSE (OSVs) such as Kylinsoft,
iSoft, Sinosoft, and
Kylin V10 GreatDB to develop
Community edition
openEuler openEuler Commercial
iSoft V5.1 commercial releases.
releases
EulixOS 1.0
17 Huawei Confidential
Contents
2. Linux Basics
Introduction to Linux
Introduction to openEuler
◼ Introduction to File Systems on openEuler
Basic openEuler Operations
18 Huawei Confidential
File System Overview
⚫ A file system is a method and a data structure used by an OS to identify files on a storage
device or a partition, that is, a method of organizing files on a storage device.
⚫ In an OS, a software structure that manages and stores file data is referred to as a file
management system, or file system for short.
Underlying storage
hardware, such as drives and Objects and properties
partitions
19 Huawei Confidential
• Function: The file system organizes and allocates the space on file storage
devices, stores files, and protects and retrieves the stored files. Specifically, it is
responsible for creating files for users, saving, reading, modifying, and dumping
files, controlling access to files, and canceling a file that is no longer in use.
Functions of a file system include: manages and schedules storage space of a file,
and provides the logical structure, physical structure, and storage method of the
file; maps file identifiers to actual addresses, controls and accesses files, shares
file information, provides reliable file confidentiality and protection measures,
and provides file security measures.
File Systems on openEuler
⚫ The openEuler kernel is derived from Linux. The Linux kernel supports more than 10 types of
file systems, such as Btrfs, JFS, ReiserFS, ext, ext2, ext3, ext4, ISO 9660, XFS, Minix, MSDOS,
UMSDOS, VFAT, NTFS, HPFS, SMB, SysV and PROC. The following table describes the
common file systems.
⚫ The default file system on openEuler is ext4.
Common File System Description
Ext File system specially designed for Linux. The latest version is ext4.
A high-performance log file system developed for the IRIX OS by Silicon Graphics
XFS in 1993. Later ported to the Linux kernel, it excels in large-file processing and
provides smooth data transfer.
On Linux, VFAT is the name of the FAT (including FAT16 and FAT32) file systems
VFAT
in DOS and Windows.
The standard file system for optical disc media. Linux supports this file system,
ISO 9600
allowing the system to read CD-ROMs and ISO image files, and burn CD-ROMs.
20 Huawei Confidential
Contents
2. Linux Basics
Introduction to Linux
Introduction to openEuler
Introduction to File Systems on openEuler
◼ Basic openEuler Operations
21 Huawei Confidential
Contents
22 Huawei Confidential
Linux GUI and CLI
⚫ A graphical user interface (GUI) presents all elements as graphical. The mouse is used as the
main input tool, and buttons, menus, and dialog boxes are used for interaction, focusing on
ease of use.
⚫ All elements on a command line interface (CLI) are character-based. The keyboard is used as
the input tool to enter commands, options, and parameters for executing programs,
achieving high efficiency.
23 Huawei Confidential
• Example:
▫ Start the calculator on the Windows GUI. Choose Start > Programs >
Windows Accessories > Calculator. In the calculator, click buttons to enter
an expression. Similarly, a small keyboard is displayed when a certain
program requires you to enter a password, asking you to click the numbers.
This method is very user-friendly, and the calculator looks similar to the
input device used at bank ATMs all around the world. The difference here is
that you click it using a mouse, rather than using your own hands.
▫ In the Linux CLI, enter bc to start the calculator. Enter the calculation 1 + 1
and press Enter. Result 2 is obtained.
Why We Use CLIs
⚫ Higher efficiency
On Linux, it is faster to perform operations on a keyboard than using the mouse.
A GUI-based operation cannot be repeated, while a CLI script can be used to complete all required
tasks, for example, deleting outdated log files.
24 Huawei Confidential
Linux CLI Shortcuts
⚫ Tab completion
Use the Tab key to complete a command or file name, which is time-saving and accurate.
When no command is entered, press Tab twice to list all available commands.
If you have entered a part of the command name or file name, press Tab to complete it
automatically.
⚫ Cursor control
↑: Press ↑ several times to display historical commands for quick execution.
↓: Press ↓ together with ↑ for choosing a historical command.
Home: Press Home to move the cursor to the beginning of the line.
Ctrl+A: Press Ctrl+A to move the cursor to the beginning of the line.
Ctrl+E: Press Ctrl+E to move the cursor to the end of the line.
Ctrl+L: Press Ctrl+L to clear the screen.
25 Huawei Confidential
Login to Linux
⚫ You can log in to Linux in either of the following ways:
Local login
Remote Login
◼ Using clients such as PuTTY and Xshell to remotely log in to openEuler.
26 Huawei Confidential
• After you log in to the system as the root user, # is displayed in the command
prompt.
Changing the Password
⚫ Passwords are used to ensure the security of system and data.
⚫ To ensure system security, you should:
Change the password upon the first login.
Change passwords periodically.
Set a complex password, for example, a password containing more than eight characters and at
least three types of the following characters: uppercase letters, lowercase letters, digits, and special
characters.
⚫ You can run the passwd command to change the password.
[root@openEuler ~]# passwd # Change the password of the current user.
Changing password for user root.
New password: # Enter the new password.
Retype new password: # Enter the new password again.
passwd: all authentication tokens updated successfully
[root@openEuler ~]# passwd test1 # Change the password of a common user as the root user.
Changing password for user test1.
New password:
BAD PASSWORD: The password is a palindrome
Retype new password:
passwd: all authentication tokens updated successfully.
27 Huawei Confidential
• For security purposes, openEuler does not display the password when you enter it
and does not use any placeholders to indicate the number of characters.
Types of Linux Users
⚫ On Linux, a UID is used to uniquely identify a user.
⚫ Based on different UIDs, there are three types of users in Linux (openEuler is used as an
example):
Super user
◼ The super user is also called the super administrator. Its UID is 0. The super user has all system permissions.
It is similar to the administrator in Windows.
System user
◼ System users, also called program users, have UIDs ranging from 1 to 999. A system user is created by a
program and is used to run the program or service.
Common user
◼ Common users are generally created by the super administrator (the root user) to perform limited
management and maintenance operations on the system. UIDs of common users range from 1000 to 60000.
28 Huawei Confidential
Creating and Deleting a Linux User
⚫ Creating a user (common user by default): useradd username
⚫ Viewing user information: id username
⚫ Switching users: su - username
⚫ Deleting a user: userdel username
29 Huawei Confidential
Contents
30 Huawei Confidential
Power Supply Commands: shutdown and reboot
⚫ shutdown is used to shut down the computer, which requires root permissions.
Main options:
◼ -h: powers off the computer after it is shut down.
◼ -r: powers on the computer after it is shut down. (This operation is equivalent to restarting the computer.)
◼ -p: explicitly indicates that the system will be shut down and the main power supply will be cut off.
⚫ reboot is used to restart the computer, which requires system administrator permissions.
Main options:
◼ -w: writes records to the /var/log/wtmp file. It does not restart the system.
◼ -d: does not write records to the /var/log/wtmp file.
◼ -i: restarts the system with network settings disabled.
31 Huawei Confidential
• The shutdown command can safely shut down the system. It is dangerous to shut
down the Linux system by directly powering off the system.
• If you run the shutdown command to shut down the system, the system notifies
all users who have logged in that the system will be shut down and the login
command will be frozen, prohibiting new user logins.
File Paths
⚫ Absolute path: a path starting from the root directory (/), for example, /root/Desktop.
⚫ Relative path: a path starting from the current path, for example, ./Desktop.
./ or . indicates the current path. ../ or .. indicates the upper-level directory of the current path.
32 Huawei Confidential
• Syntax: cd [directory]
▫ cd ..: goes to the upper-level directory. Double dot indicates the upper-level
directory.
33 Huawei Confidential
• The cat command is used to view contents of a small file. This command displays
all lines in a file.
• The tail command is used to view the last 10 lines of a file by default.
▫ -n: followed by a number, for example, 5, indicating that the last five lines
of a file are viewed. You can also enter a number directly without the -n
option.
▫ -f: dynamically displays file changes. This option is commonly used for
viewing log files.
• The head command is used to view the first 10 lines of a file by default.
• The less and more commands are used to view large files page by page. Enter q
to exit. Enter a slash (/) and a keyword to search for the keyword in the file.
Creating Files
⚫ mkdir: Creating directories (folders)
-p: cascades to create multiple directories recursively.
[root@localhost ~]# mkdir my_dir_01 # Create a my_dir_01 directory.
[root@localhost ~]# ls
anaconda-ks.cfg my_dir_01
[root@localhost ~]# mkdir -p my_dir_02/sub_dir # Create a my_dir_02 directory and its subdirectory sub_dir.
[root@localhost ~]# touch test01.log test02.log # Create files test01.log and test02.log.
[root@localhost ~]# ls -lt
total 0
-rw-------. 1 root root 0 Jul 29 15:06 test01.log
-rw-------. 1 root root 0 Jul 29 15:06 test02.log
34 Huawei Confidential
Copying Files
⚫ cp: Copying files or directories
-a: copies the files of a directory while retaining the links and file attributes.
-r: If the source file is a directory, all subdirectories and files in the directories are copied recursively
and the attributes are retained.
[root@localhost ~]# ls
test01.log test02.log
[root@localhost ~]# cp /etc/passwd passwd.back # Copy the /etc/passwd file to the current directory and rename the
file to passwd.back.
[root@localhost ~]# cp -r /var/log/audit ./ # Copy the audit directory and all files in it to the current directory.
[root@localhost ~]# ls
audit passwd.back test01.log test02.log
[root@localhost ~]# cp -s /etc/passwd passwd_link # Create a symbolic link passwd_link of the passwd file.
[root@localhost ~]# ls
audit passwd.back passwd_link test01.log test02.log
[root@localhost ~]# ls -l
total 8
drwx------. 2 root root 4096 Jul 29 15:24 audit
-rw-------. 1 root root 2546 Jul 29 15:24 passwd.back
lrwxrwxrwx. 1 root root 11 Jul 29 15:25 passwd_link -> /etc/passwd
-rw-------. 1 root root 0 Jan 2 19:20 test01.log
-rw-------. 1 root root 0 Jul 29 19:20 test02.log
[root@localhost ~]#
35 Huawei Confidential
• The cp command is used to copy files and directories. You can copy one or more
files at a time. Exercise caution when running this command because data loss
risks are involved.
• Syntax: cp [OPTION]... SOURCE... DIRECTORY
▫ -a: copies the files of a directory while retaining the links and file attributes.
▫ -p: copies the file content, modification time, and access permissions to the
new file.
▫ -r: if the source file is a directory, all subdirectories and files in the
directories are copied recursively.
▫ -l: creates a hard link of the source file instead of copying it.
▫ -s: creates a soft link of the source file instead of copying it.
• cp f1 f2: copies file f1 and renames it to f2.
• cp f1 d1/: copies f1 to the d1 directory without renaming it.
• cp f1 f2 f3 d1/: copies multiple files to a directory.
• cp -i f1 f2: waits for the user's confirmation before overwriting f2 if f2 already
exists.
• cp -r d1 d2: copies a directory recursively if the -r option is added.
• cp -a f1 f2: if the -a option is added, the attributes of the source file are retained.
This option is used to copy block devices, character devices, and named pipes.
• By default, the cp command does not ask the user before overwriting files.
Therefore, many shells have made cp as an alias for cp -i. The -f option in the cp
command does not indicate forcible overwriting.
Moving and Renaming Files
⚫ mv: Moving or renaming a file
The mv command is used to move a file or directory. Exercise caution when running this command
because data loss risks are involved.
If the source file and target file are in the same directory, the mv command is used to rename the
file.
[root@localhost ~]# ls
passwd_link test01.log test02.log
[root@localhost ~]# mv test02.log test03.log #Change the name of the test02.log file to test03.log
[root@localhost ~]# ls
passwd_link test01.log test03.log
[root@localhost ~]# mv test01.log /root/test # Move the test01.log file to the /root/test directory.
[root@localhost ~]# mv –f test01.log test03.log # Forcibly overwrite the test03.log file with the content of
the test01.log file.
36 Huawei Confidential
• If the source file and target file are in the same directory, the mv command
renames the file.
▫ -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.
Deleting Files
⚫ rm: Deleting files or directories
The rm command is a high-risk command. No tool can guarantee recovery of files deleted by the
rm command, which does not move a file to a recycle bin like in GUIs. Therefore, you cannot undo
the deletion.
[root@localhost ~]# ls
audit_back passwd.back test01.log test03.log
[root@localhost ~]# rm test01.log # Delete the test01.log file with a prompt
before deletion.
rm: remove regular empty file 'test01.log'? yes
[root@localhost ~]# rm -rf test03.log # Forcibly delete the test03.log file.
[root@localhost ~]# rm -rf audit_back/ # Delete the mail.bak directory, including all
files and subdirectories in it.
[root@localhost ~]# ls
passwd.back
[root@localhost ~]#
37 Huawei Confidential
▫ -f, --force: ignores the files that do not exist and does not display any
message.
▫ -r, -R, --recursive: recursively deletes all directories listed as arguments and
their subdirectories.
Exit Status:
Returns 0 unless an invalid option is given or the current directory cannot be read.
[root@localhost ~]# systemctl --help
systemctl [OPTIONS...] {COMMAND} ...
38 Huawei Confidential
• Syntax:
39 Huawei Confidential
Linux Text Editor - Vim
⚫ Vim is a customizable text editor derived from Visual Editor (vi) that inherits, improves and
adds many features to vi's original base.
⚫ Common Vim modes:
Normal mode: used to copy, paste, and delete text, undo previous operations, and navigate the cursor.
Insert mode: used to edit and modify text.
Command line mode: used to save, exit, search for, or replace text. Enter a colon (:) to switch to this mode.
Normal mode
Esc Esc
: or / a, i, o, or s
40 Huawei Confidential
• Vim is not installed on openEuler 20.03 LTS by default. You need to manually
install it.
Normal Mode of Vim
⚫ By default, Vim begins to run in normal mode after you open a file with the vim command.
vim [options] [file]... Edit specified files.
vim [options] - Read text from standard input (stdin).
vim [options] -t tag Edit the file where the tag is defined.
vim [options] -q [errorfile] Edit the file where the first error occurs.
⚫ Common options:
-c: runs a specified command before opening a file.
-R: opens a file in read-only mode but allows you to forcibly save the file.
-M: opens a file in read-only mode and does not allow you to forcibly save the file.
-r: recovers a crashed session.
+num: starts at line num.
41 Huawei Confidential
Common Operations in Vim Normal Mode
⚫ Cursor control
Arrow keys or k, j, h, and l keys move the cursor up, down, left, and right, respectively.
0: moves the cursor to the beginning of the current line.
g0: moves the cursor to the leftmost character of the current line that is on the screen.
:n: moves the cursor to line n.
gg: moves the cursor to the first line of the file.
G: moves the cursor to the last line of the file.
⚫ Data operations
yy or Y: copies an entire line of text.
y[n]w: copies 1 or n words.
d[n]w: deletes (cuts) 1 or n words.
[n] dd: deletes (cuts) 1 or n lines.
42 Huawei Confidential
Insert Mode of Vim
⚫ Use the vim filename command to open a file and enter the normal mode by default. Type i,
I, a, A, o, or O to enter the insert mode.
⚫ If the filename file exists, the file is opened and the file content is displayed; otherwise, Vim
displays [New File] at the bottom of the screen and creates the file when saving the file for
the first time.
⚫ Press Esc to exit the insert mode and return to the normal mode.
[root@openEuler ~]# vim test.txt # Enter the normal mode by default.
~
~
"test.txt" [New File]
[root@openEuler ~]# vim test.txt # Press i, I, a, A, o, or O to enter the insert mode.
~
~
-- INSERT --
43 Huawei Confidential
Command Line Mode of Vim
⚫ Search
:/word or /word: searches for a word string after the cursor. Press n to continue to search forwards or press Shift+n to search
backwards.
⚫ Replace
:1,5s/word1/word2/g: replaces all occurrences of word1 in lines 1 to 5 with word2. If g is not specified, only the first occurrence
of word1 in each line is replaced.
%s/word1/word2/gi: replaces all occurrences of word1 with word2. i ignores the case of matches.
44 Huawei Confidential
Contents
45 Huawei Confidential
Important Network Concepts in openEuler
⚫ Host network device: a network adapter on the
host.
⚫ Interface
Interfaces on devices are created by drivers for the
system access.
⚫ Broadcast address
An IP address used to send packets to all hosts on the
network segment
⚫ Subnet mask
A number that distinguishes the network address and
the host address within an IP address
⚫ Route
Next-hop IP address when IP packets are transmitted
across network segments
⚫ Link: connection between the device and the
network.
46 Huawei Confidential
Commands for Querying IP Addresses
⚫ ip and ifconfig commands are used to view IP addresses of the current host.
⚫ Viewing information about all network adapters on a host.
[root@openEuler ~]# ifconfig –a
[root@openEuler ~]# ip addr show
47 Huawei Confidential
• Viewing the current IP addresses and subnet masks of all interfaces: ip addr
Configuring Static IP Addresses Using Network Adapter Configuration Files
⚫ Query the path of the network adapter configuration file:
[root@openEuler ~]# ls /etc/sysconfig/network-scripts/ifcfg-*
/etc/sysconfig/network-scripts/ifcfg-enp0s3 /etc/sysconfig/network-scripts/ifcfg-enp0s8
⚫ Parameter description: Parameter Description
TYPE Interface type
BOOTPROTO Boot-time protocol
ONBOOT Whether to activate the device at boot-time
IPADDR IP address
NETMASK Subnet mask
GATEWAY Gateway address
BROADCAST Broadcast address
MAC address. Only one MAC address needs to be set. New MAC addresses
HWADDR/MACADDR
cannot share the same name as another when they are set at the same time.
Whether to specify the DNS server address. If the DHCP protocol is used, the
PEERDNS
default value is yes.
DNS{1, 2} DNS server addresses
USERCTL User permission control
NAME Network connection name
DEVICE Physical interface name
48 Huawei Confidential
Configuring the IP Address - Configuration File Example
⚫ Set the static IP address of the enp0s3 interface to 192.168.56.100/24.
TYPE=Ethernet
BOOTPROTO=static
NAME=enp0s3
DEVICE=enp0s3
ONBOOT=yes
IPADDR=192.168.56.100
NETMASK=255.255.255.0
49 Huawei Confidential
50 Huawei Confidential
51 Huawei Confidential
52 Huawei Confidential
• The route, ip, and nmcli commands can be used to manage routes. The following
uses the route command as an example.
Viewing the Routing Table Using the route Command
⚫ Run the route command to view the routing table.
53 Huawei Confidential
• When the -n option is used to display routes, the values in the Destination
column are IP addresses.
• Eight fields are displayed when you run the route command to view routes. The
possible values of the Flags field include:
route [-f] [-p] [Command [Destination] [mask Netmask] [Gateway] [metric Metric]] [if Interface]]
⚫ Example:
[root@openEuler ~]# route add -net 192.168.101.0 netmask 255.255.255.0 dev enp4s0
[root@openEuler ~]# route add -host 192.168.100.10 dev enp4s0
[root@openEuler ~]# route
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
default _gateway 0.0.0.0 UG 100 0 0 enp4s0
192.168.100.10 0.0.0.0 255.255.255.255 UH 0 0 0 enp4s0
192.168.101.0 0.0.0.0 255.255.255.0 U 0 0 0 enp4s0
192.168.110.0 0.0.0.0 255.255.255.0 U 100 0 0 enp4s0
192.168.122.0 0.0.0.0 255.255.255.0 U 0 0 0 virbr0
54 Huawei Confidential
• You can use the route command to add routes. The added routes are stored in
the memory and become invalid after the system is restarted.
• The route add -net 192.168.101.0 netmask 255.255.255.0 dev enp3s0 command
adds a route to the 192.168.101.0/24 segment through the enp3s0 device.
• The route add -host 192.168.101.100 dev enp3s0 command adds a route to the
192.168.101.100 host through the enp3s0 device.
• The output of the route command shows that routes to hosts have a higher
priority than routes to network segments.
Deleting a Route Using the route Command
⚫ Deleting a route to a network segment or host using the route del command.
⚫ Syntax:
route del [-net|-host] [netmask Nm] [gw Gw] [[dev] If]
⚫ Example:
55 Huawei Confidential
• The route del -net 192.168.101.0 netmask 255.255.255.0 dev enp3s0 command
deletes the route to the 192.168.101.0/24 segment. To delete a route to a
network segment, the network segment and subnet mask parameters are
mandatory, while the device parameter is optional.
• The route del -host 192.168.101.100 dev enp3s0 command deletes the route to
the 192.168.101.100 host. The device parameter is optional.
• To delete routes in the route file, use the vi editor to edit the file and restart the
network.
Host Name
⚫ A host name identifies a device in a local area network (LAN).
⚫ The device can be a physical or virtual machine.
⚫ The host name is stored in the /etc/hostname file.
56 Huawei Confidential
Setting the Host Name
⚫ Setting a temporary host name: hostname new-name
⚫ Setting a permanent host name: hostnamectl set-hostname new-name
⚫ Setting a host name by modifying the file: write new-name to the /etc/hostname file.
57 Huawei Confidential
• To make the setting take effect, log in again or run the source .bashrc command.
• Run the hostname command to view the host name of the current system.
Introduction to the hosts File
⚫ Hosts in a LAN can be accessed through IP addresses.
⚫ IP addresses are difficult to remember when a large number of hosts exist in the LAN.
Therefore, we want to access the hosts directly through their host names.
⚫ In this case, the hosts can be located using a table that records the mapping between host
names and IP addresses. This table is the hosts file.
[root@openEuler ~]# cat /etc/hosts
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
::1 localhost localhost.localdomain localhost6 localhost4.localdomain6
58 Huawei Confidential
• The hosts file is a system file without a file name extension. Its basic function is
to establish a "database" of frequently used domain names and their
corresponding IP addresses.
• When a user enters a website URL in the web browser, the system searches for
the corresponding IP address in the hosts file. Once the IP address is found, the
system opens the corresponding web page.
• If the URL is not found, the system sends the URL to the DNS server for IP
address resolution.
# Ip domain.com
192.168.10.20 www.example.com
#ip domain.com
#192.168.10.20 www.example.com
59 Huawei Confidential
Quiz
1. Which of the following statements is incorrect about file systems?
A. A file system is a method and a data structure used by an OS to identify files on a
storage device or a partition.
B. The software structure that manages and stores file data is referred to as a file
management system.
C. The file system manages and controls computer hardware and software resources.
D. The file system organizes and allocates the space on file storage devices, stores files,
and protects and retrieves the stored files.
2. Linux is a multi-user OS that allows multiple users to log in at the same time and
allows one user to log in multiple times.
A. True
B. False
60 Huawei Confidential
• Answer:
▫ C
▫ A
Summary
⚫ This course discusses the basic components and types of OSs and basic
operations of Linux. Now, we have finished learning the basics about
computing, storage, network, and OS technologies. In cloud computing,
how can we use and manage the resources to provide services for
applications? We will address these issues in the next course about
virtualization technology.
61 Huawei Confidential
Recommendations
⚫ Huawei iLearning
https://e.huawei.com/en/talent/portal/#/
⚫ Huawei Support Knowledge Base
https://support.huawei.com/enterprise/en/knowledge?lang=en
62 Huawei Confidential
Acronyms and Abbreviations
CLI: Command Line Interface
63 Huawei Confidential
Thank you. 把数字世界带入每个人、每个家庭、
每个组织,构建万物互联的智能世界。
Bring digital to every person, home, and
organization for a fully connected,
intelligent world.