Download as pdf or txt
Download as pdf or txt
You are on page 1of 167

y

nl
O
e
te Us
SUSE Linux Enterprise Server
Administration

bu r
tri ne
-Workbook-
is rt
D Pa
Course ID: SLE201v15
Version: 15.2.1
ot d
N an

Date: 2020-11-12
D aln
er
o
t
In
SE
SU
Proprietary Statement Disclaimer
Copyright © 2020 SUSE LLC. All rights reserved. SUSE LLC, makes no representations or warranties
with respect to the contents or use of this
documentation, and specifically disclaims any express
SUSE LLC, has intellectual property rights relating to
or implied warranties of merchantability or fitness for
technology embodied in the product that is described in
any particular purpose.
this document.

Further, SUSE LLC, reserves the right to revise this


No part of this publication may be reproduced,
publication and to make changes to its content, at any
photocopied, stored on a retrieval system, or
time, without obligation to notify any person or entity of
transmitted without the express written consent of the

y
such revisions or changes. Further, SUSE LLC, makes
publisher.

nl
no representations or warranties with respect to any
software, and specifically disclaims any express or

O
SUSE implied warranties of merchantability or fitness for any
Maxfeldstrasse 5 particular purpose. Further, SUSE LLC, reserves the
right to make changes to any and all parts of SUSE

e
90409 Nuremberg
software, at any time, without any obligation to notify

te Us
Germany any person or entity of such changes.
www.suse.com
Any products or technical information provided under

bu r
(C) 2020 SUSE LLC. All Rights Reserved. SUSE and this Agreement may be subject to U.S. export controls

tri ne
the SUSE logo are registered trademarks of SUSE LLC and the trade laws of other countries. You agree to
in the United States and other countries. All third-party comply with all export control regulations and to obtain
trademarks are the property of their respective owners. any required licenses or classification to export, re-
is rt export or import deliverables. You agree not to export
D Pa
or re-export to entities on the current U.S. export
If you know of illegal copying of software, contact your
exclusion lists or to any embargoed or terrorist
local Software Antipiracy Hotline.
countries as specified in the U.S. export laws. You
agree to not use deliverables for prohibited nuclear,
ot d

missile, or chemical biological weaponry end uses.


N an

SUSE assumes no responsibility for your failure to


obtain any necessary export approvals.
D al

This SUSE Training Manual is published solely to


instruct students in the use of SUSE networking
n

software. Although third-party application software


packages may be used in SUSE training courses, this
er

is for demonstration purposes only and shall not


o

constitute an endorsement of any of these software


t
In

applications.

Further, SUSE LLC does not represent itself as having


SE

any particular expertise in these application software


packages and any use by students of the same shall be
done at the student’s own risk.
SU
Table of Contents
Section 1 : Overview of SUSE Linux Enterprise...............................9
Exercise 1 : Understand YaST...............................................................................................10
Task 1: Start YaST..................................................................................................................................10
Task 2: View the contents of a System Log File....................................................................................10
Task 3: Change the Time and Date........................................................................................................10

y
Task 4: Display Available YaST Modules................................................................................................11

nl
Task 5: Start the ncurses Version of YaST.............................................................................................11
Task 6: View the Content of a System Log File......................................................................................11

O
Exercise 2 : Manage Favorite Applications............................................................................13
Task 1: Log into the Desktop (if required)..............................................................................................13

e
Task 2: Add an Application to your Favorite Applications.......................................................................13

te Us
Task 3: Remove an Application from your Favorite Applications...........................................................13
Exercise 3 : Use the File Manager.........................................................................................15

bu r
Task 1: Copy a File with Files.................................................................................................................15

tri ne
Task 2: Rename a copied File................................................................................................................15
Task 3: Delete a File...............................................................................................................................15
is rt
Exercise 4 : Change Screen Settings....................................................................................17
D Pa
Task 1: Change Screen Settings............................................................................................................17
Section 2 : The Linux Filesystem......................................................18
Exercise 1 : Explore Filesystem Hierarchy.............................................................................19
ot d
N an

Task 1: Open a terminal Session as the root User.................................................................................19


Task 2: Install the tree command...........................................................................................................19
Task 3: Use tree to View the Structure of System Directory Hierarchies...............................................19
D al

Section 3 : Work with the Command Line........................................21


n

Exercise 1 : Access and use man and info Pages.................................................................22


er

Task 1: Open a terminal session............................................................................................................22


o

Task 2: Use the man Command to Find Information..............................................................................22


t
In

Task 3: Finding the Command or File You Really Want.........................................................................23


Task 4: Go Directly to a Particular Man Page and Find Text..................................................................23
SE

Task 5: Use the info Command..............................................................................................................24


Exercise 2 : Use the Shell History..........................................................................................25
Task 1: Open a terminal session............................................................................................................25
SU

Task 2: View the Shell History................................................................................................................25


Exercise 3 : Use Piping and Redirection................................................................................27
Task 1: Open a terminal session............................................................................................................27
Task 2: Use Redirection to Create a File................................................................................................27
Task 3: Use Redirection to Overwrite a File...........................................................................................27
Task 4: Use Redirection to Append to a File..........................................................................................27
Task 5: Copy and Count the Lines in a File...........................................................................................28
Task 6: Number the Lines in a File.........................................................................................................28
Task 7: Prepare a File for Printing..........................................................................................................28
Task 8: Using Pipes and Redirection Together......................................................................................28
Exercise 4 : Change Directories and List Directory Contents................................................30
Task 1: Open a terminal session............................................................................................................30
Task 2: Navigate Around the File System..............................................................................................30
Task 3: List Directory Contents..............................................................................................................31
Exercise 5 : Perform Multiple File Operations........................................................................32
Task 1: Open a terminal session............................................................................................................32
Task 2: Create a Test Directory and Test Files.......................................................................................32
Task 3: Move and Copy Files.................................................................................................................32
Task 4: Create Directory Structures.......................................................................................................33

y
nl
Task 5: Delete Files and Directories.......................................................................................................33
Task 6: Link Files....................................................................................................................................34

O
Exercise 6 : Use Shell Commands to Work with Files...........................................................36
Task 1: Open a terminal session............................................................................................................36

e
Task 2: Displaying and Finding Content in Text Files.............................................................................36

te Us
Task 3: Using head and tail to Display File Contents.............................................................................36
Exercise 7 : Create File Backup.............................................................................................38
Task 1: Open a terminal session............................................................................................................38

bu r
tri ne
Task 2: Create a Tar Archive..................................................................................................................38
Task 3: Create Compressed Tar Archives..............................................................................................38
is rt
Task 4: Sync Tar Archive........................................................................................................................39
D Pa
Task 5: Change Content in the Source Directory...................................................................................39
Exercise 8 : Search File Content............................................................................................41
Task 1: Open a terminal session............................................................................................................41
ot d

Task 2: Search File Content...................................................................................................................41


N an

Section 4 : The VIM Editor.................................................................43


Exercise 1 : Use vim to Edit and Manipulate Text Files.........................................................44
D al

Task 1: Open a terminal session............................................................................................................44


Task 2: Open an Existing File for Editing with Various Options.............................................................44
n

Task 3: Navigate in and Save an Existing File as a New File with Changes.........................................45
er

Task 4: Search and Replace Text in a File.............................................................................................45


o
t

Task 5: Compare Two Similar Files for Differences...............................................................................46


In

Section 5 : Remote Administration...................................................48


Exercise 1 : Practice using OpenSSH Utilities.......................................................................49
SE

Task 1: Open a terminal session............................................................................................................49


Task 2: Access a remote server using SSH...........................................................................................49
SU

Task 3: Use scp to Copy Files to and from a Remote Server................................................................50


Task 4: Use sftp......................................................................................................................................50
Exercise 2 : Configure Key Based Authentication in OpenSSH............................................51
Task 1: Generate an SSH Key Pair........................................................................................................51
Task 2: Upload the Public Key to a Remote Server...............................................................................51
Task 3: Verify Key Based Login and Store the Private Key in the SSH Agent.......................................51
Task 4: Disable Password Based Logins...............................................................................................52
Exercise 3 : Remote Administration using VNC.....................................................................54
Task 1: Check remote administration is not enabled on server2...........................................................54
Task 2: Try to remotely administer server2 from server1.......................................................................54
Task 3: Enable remote management on server2...................................................................................54
SUSE Linux Enterprise Server Administration
Task 4: Remotely administer server2 from server1................................................................................55
Section 6 : System Initialization........................................................56
Exercise 1 : Secure GRUB with a Password.........................................................................57
Task 1: Open a terminal session............................................................................................................57
Task 2: Secure Access to GRUB with a Password................................................................................57
Task 3: Test the GRUB Password.........................................................................................................58
Exercise 2 : Manage Services................................................................................................59

y
Task 1: Open a terminal session............................................................................................................59

nl
Task 2: Manage Services.......................................................................................................................59

O
Exercise 3 : Work with systemd Targets.................................................................................63
Task 1: Open a terminal session............................................................................................................63

e
Task 2: Change to Different Targets.......................................................................................................63

te Us
Task 3: Boot into a Different Target........................................................................................................63
Task 4: Add Services to and Remove Services from a Target Unit........................................................64
Section 7 : Process Management.....................................................66

bu r
tri ne
Exercise 1 : Modify Process Priorities....................................................................................67
Task 1: Modify Process Priority..............................................................................................................67
is rt
Task 2: Specify Process Priority at Program Start.................................................................................68
D Pa
Task 3: Terminate Processes.................................................................................................................68
Exercise 2 : Manage Linux Processes and Jobs...................................................................69
Task 1: Open a terminal session............................................................................................................69
ot d

Task 2: Display Linux Processes............................................................................................................69


N an

Task 3: Manage Linux Jobs....................................................................................................................69


Task 4: Start Processes that Ignore HANGUP.......................................................................................70
Task 5: Terminate Linux Processes........................................................................................................71
D al

Exercise 3 : Use the screen Command..................................................................................72


n

Task 1: Open a terminal session............................................................................................................72


er

Task 2: Use the screen Command.........................................................................................................72


o

Exercise 4 : Schedule Jobs with cron....................................................................................75


t
In

Task 1: Open a terminal session............................................................................................................75


Task 2: Schedule Jobs with cron............................................................................................................75
SE

Task 3: Schedule a cron Job as root......................................................................................................76


Section 8 : Identity and Security.......................................................78
Exercise 1 : Manage Users with YaST...................................................................................79
SU

Task 1: Start YaST..................................................................................................................................79


Task 2: Create a New User Account with YaST.....................................................................................79
Task 3: Log in as the New User.............................................................................................................79
Task 4: View the /etc/passwd File..........................................................................................................80
Task 5: Remove the New User Account.................................................................................................80
Task 6: Remove and Confirm the Removal of the New User Account...................................................80
Exercise 2 : Manage Users and Groups from the Command Line........................................82
Task 1: Open a terminal session............................................................................................................82

5
SUSE Linux Enterprise Server Administration
Task 2: Create a Local User Account from the Command Line.............................................................82
Task 3: Create and Add Users to a New Local Group...........................................................................83
Task 4: Create a New User Account with a Valid Password Automatically............................................83
Exercise 3 : Manage File Permissions...................................................................................85
Task 1: Open a terminal session............................................................................................................85
Task 2: Create a Private and a Public Directory....................................................................................85
Task 3: Create a File as a Normal User in both Directories...................................................................86

y
Exercise 4 : Configure Posix ACLs.........................................................................................87

nl
Task 1: Open a terminal session............................................................................................................87
Task 2: Configure the ACLs of a Directory.............................................................................................87

O
Task 3: Configure Default ACLs for a Directory.....................................................................................88
Task 4: Delete ACLs...............................................................................................................................88

e
Exercise 5 : Use the su Command to Elevate Privileges.......................................................90

te Us
Task 1: Open a terminal session............................................................................................................90
Task 2: Use the su Command................................................................................................................90
Exercise 6 : Configure sudo for Delegation of Administration................................................92

bu r
tri ne
Task 1: Open a terminal session............................................................................................................92
Task 2: Open a terminal session............................................................................................................92
is rt
Task 3: Define sudo Aliases...................................................................................................................92
D Pa
Task 4: Test the sudo Aliases.................................................................................................................93
Task 5: Grant the Tux User the Ability to Change Users Passwords.....................................................93
Exercise 7 : Grant Administrative Privilege with PolicyKit......................................................95
ot d

Task 1: Open a terminal session............................................................................................................95


N an

Task 2: Try to Use the GNOME Date & Time Tool.................................................................................95


Task 3: Grant the Privilege to Use GNOME Date & Time Tool..............................................................95
Task 4: Execute a Command as Another User......................................................................................96
D al

Section 9 : Software Management....................................................98


n

Exercise 1 : Manage Software with RPM...............................................................................99


er

Task 1: Open a terminal session as root................................................................................................99


o
t

Task 2: Get Information on Software Packages.....................................................................................99


In

Task 3: Verify Changes to Software Packages......................................................................................99


Task 4: Install Software with RPM BETA FIX.......................................................................................100
SE

Task 5: Remove Software with RPM....................................................................................................101


Exercise 2 : Install Software with zypper..............................................................................102
SU

Task 1: Open a terminal session..........................................................................................................102


Task 2: Install a Software Package with zypper...................................................................................102
Task 3: Removing a Package with Zypper...........................................................................................103
Task 4: Use zypper to Install a Pattern.................................................................................................103
Exercise 3 : Manage Software Sources with zypper............................................................104
Task 1: Open a terminal session..........................................................................................................104
Task 2: Add an Installation source with zypper....................................................................................104
Task 3: Install a Software Package from the New Repository.............................................................105
Task 4: Rename an Installation Source with zypper............................................................................105

6
SUSE Linux Enterprise Server Administration
Task 5: Remove an Installation Source with zypper............................................................................105
Exercise 4 : Manage Software with YaST............................................................................107
Task 1: Start YaST................................................................................................................................107
Task 2: Install Software Packages with YaST......................................................................................107
Task 3: Remove Software Packages with YaST..................................................................................108
Section 10 : Network Management.................................................109
Exercise 1 : Configure the Network Connection Manually...................................................110

y
Task 1: Open a terminal session..........................................................................................................110

nl
Task 2: Note the Current Network Configuration..................................................................................110

O
Task 3: Delete the Current Network Setup with YaST..........................................................................111
Task 4: Configure the Network Manually..............................................................................................111

e
Exercise 2 : Configure Local Name Resolution....................................................................112

te Us
Task 1: Open a terminal session..........................................................................................................112
Task 2: Configure Local Name Resolution...........................................................................................112
Task 3: Test Name Resolution..............................................................................................................112

bu r
Exercise 3 : Save the Network Configuration to a File.........................................................114

tri ne
Task 1: Open a terminal session..........................................................................................................114
Task 2: Save the Network Configuration to a File................................................................................114
is rt
Task 3: Test the Network Configuration................................................................................................115
D Pa
Exercise 4 : Manage Network Configuration with Wicked....................................................116
Task 1: Open a terminal session..........................................................................................................116
Task 2: Manage Network Configuration with Wicked...........................................................................116
ot d

Exercise 5 : Configure a Host Based Firewall with firewalld................................................119


N an

Task 1: Open a terminal session..........................................................................................................119


Task 2: Viewing your system’s iptables configuration..........................................................................119
D al

Task 3: Changing the Zone of an Interface..........................................................................................119


Task 4: Set the Allowed Services for an Interface................................................................................120
n

Task 5: Confirm your iptables Configuration is active..........................................................................120


er

Task 6: Confirm your iptables Configuration is permanent..................................................................120


o
t

Section 11 : Storage Administration...............................................121


In

Exercise 1 : Manage Partitions with YaST...........................................................................122


SE

Task 1: Start YaST................................................................................................................................122


Task 2: Manage partitions with YaST...................................................................................................122
Task 3: View the new partitions and filesystems..................................................................................123
SU

Exercise 2 : Manage Partitions with parted..........................................................................126


Task 1: Open a terminal session..........................................................................................................126
Task 2: View the Existing Partitions.....................................................................................................126
Task 3: Create a New Partition.............................................................................................................126
Exercise 3 : Create a File System in an Empty Partition.....................................................131
Task 1: Open a terminal session..........................................................................................................131
Task 2: Create an ext3 File System.....................................................................................................131
Exercise 4 : Configure a LVM Volume Group and a Logical Volume...................................133

7
SUSE Linux Enterprise Server Administration
Task 1: Open a terminal session..........................................................................................................133
Task 2: List Partitions on a disk............................................................................................................133
Task 3: Configure an LVM Group.........................................................................................................134
Task 4: Configure a Basic LVM Logical Volume...................................................................................134
Task 5: Format the Basic LVM Volume with a File System..................................................................135
Task 6: Resize the volumegroup and ext4 file system.........................................................................135
Task 7: Rename an Existing Logical Volume.......................................................................................136
Exercise 5 : Create a Linear RAID1 Array............................................................................137

y
nl
Task 1: Add the Dev-Tools module to Server2.....................................................................................137
Task 2: Prepare the disks.....................................................................................................................137

O
Task 3: Create a RAID1 Array..............................................................................................................138
Task 4: Create an mdadm.conf file.......................................................................................................138

e
Task 5: Mount the RAID Array into the Filesystem...............................................................................139

te Us
Exercise 6 : Simulate a Failed RAID Disk............................................................................140
Task 1: Open a terminal session..........................................................................................................140
Task 2: Simulate a Failing Disk in RAID...............................................................................................140

bu r
tri ne
Task 3: Add a New Spare Disk to the Array.........................................................................................141
Exercise 7 : Create a Btrfs File System...............................................................................142
is rt
Task 1: Create some free space for a BtrFS filesystem.......................................................................142
D Pa
Task 2: Create a BtrFS filesystem........................................................................................................142
Exercise 8 : Convert an Existing Directory into a Subvolume..............................................144
Task 1: Open a terminal session..........................................................................................................144
ot d

Task 2: Convert an Existing Directory into a Subvolume.....................................................................144


N an

Exercise 9 : Work with Btrfs.................................................................................................147


Task 1: Display Volume and Subvolume Information...........................................................................147
Task 2: Work with BtrFS.......................................................................................................................148
D al

Task 3: Work with BtrFS Snapshots.....................................................................................................149


n

Task 4: Work with BtrFS Subvolumes..................................................................................................150


er

Exercise 10 : BtrFS: In-Place Migration and Maintenance..................................................152


o

Task 1: Convert an ext4 Filesystem to BtrFS.......................................................................................152


t
In

Task 2: Perform BtrFS Maintenance Tasks..........................................................................................154


Exercise 11 : Configure NFS................................................................................................156
SE

Task 1: Setup an NFS Server...............................................................................................................156


Task 2: Setup an NFS Client................................................................................................................157
Section 12 : Administration and Monitoring..................................159
SU

Exercise 1 : Configure the NTP Service...............................................................................160


Task 1: Configure the NTP Server.......................................................................................................160
Task 2: Ensure NTP is Loaded and Running.......................................................................................161
Task 3: Query your system for NTP information..................................................................................161
Exercise 2 : Manage System Logging..................................................................................163
Task 1: Modify the rsyslog Configuration.............................................................................................163
Task 2: Configure logrotate..................................................................................................................164

8
SUSE Linux Enterprise Server Administration

1 Overview of SUSE Linux Enterprise

Description: In this section you will be introduced to YaST, manage the Linux Desktop and
use the Files file manager to manage the filesystem.

y
nl
O
e
te Us
bu r
tri ne
is rt
D Pa
ot d
N an
D aln
er
o
t
In
SE
SU

9
SUSE Linux Enterprise Server Administration

1- 1 Understand YaST
Description:
In this exercise, you learn how to use the different interfaces of YaST and how to start
some YaST modules. This lab exercise will be performed in the course virtual machine

y
labeled SLE201-server1 (also referred to as server1).

nl
O
Task 1: Start YaST

e
te Us
1. If not already running, launch the Virtual Machine Manager (virt-manager)
2. In virt-manager, double-click on the SLE201-server1 (also referred to as server1)
virtual machine, and when the VM window opens, select:

bu r
tri ne
Virtual Machine > Run
3. Log in to server1 as tux; the password is linux
is rt
4. Launch YaST by clicking on the Activities menu and click on:
D Pa
YaST
5. Enter the root user’s password (linux) when prompted.
ot d
N an

Task 2: View the contents of a System Log File


1. Start the YaST System Log module by selecting:
D al

Miscellaneous > Display the system’s log


n

The messages log is displayed by default.


er

2. If you like you can view other log files by selecting other entries from the drop-down list
o

3. Close the log window by selecting:


t
In

OK
SE

Task 3: Change the Time and Date


1. With the YaST Control Center open select:
SU

System > Date and Time


2. Change the Region and Timezone to the following:
Region: Global
Time Zone: GMT
Click OK
3. Close the YaST Control Center

10
SUSE Linux Enterprise Server Administration

Task 4: Display Available YaST Modules


1. Open a terminal by clicking on the Activities menu and type:
terminal
When the Terminal icon appears, click on it to start a terminal session
2. Switch to the root user by typing:

y
nl
su -

O
Enter the root user password (linux)
3. To view a list of the available YaST modules enter the following command:

e
yast -l

te Us
The yast command modules will be displayed on the screen.

bu r
Task 5: Start the ncurses Version of YaST

tri ne
1. Start the ncurses interface of YaST from a terminal or shell:
yast is rt
D Pa
Task 6: View the Content of a System Log File
2. Press the down-arrow key until the following is highlighted in the left frame:
ot d

Miscellaneous
N an

and press Tab


3. Highlight the following in the right frame:
D al

Display the system’s log (/var/log/messages)


n

and press Enter


er

4. Press the down-arrow key to change to the following log:


o
t
In

/var/log/boot.log
And press Enter
SE

5. Press the Tab key until OK is highlighted and press Enter


6. Press Alt+Q to Quit (or press Tab until Quit is selected and then Enter)
SU

7. Log out from the root account by entering:


exit
8. Close the terminal window by entering:
exit

Summary:

11
SUSE Linux Enterprise Server Administration

You should now be familiar with using the graphical and text versions of YaST to view
system log files.

(End of Exercise)

y
nl
O
e
te Us
bu r
tri ne
is rt
D Pa
ot d
N an
D aln
er
o
t
In
SE
SU

12
SUSE Linux Enterprise Server Administration

1- 2 Manage Favorite Applications

Description:

y
In this exercise you add and remove an application to your favorite applications.

nl
O
Task 1: Log into the Desktop (if required)

e
1. If not already logged in on server1, in the log in screen, click Tux Penguin

te Us
and enter the password linux
2. Click Sign In and the GNOME desktop will shortly appear

bu r
tri ne
Task 2: Add an Application to your Favorite Applications
1. To open the main menu click Activities in the top left corner
is rt
2. Move the mouse pointer over to the Search dialogue in the top middle of the screen
D Pa
3. In the Search dialogue, type:
terminal
ot d

The Terminal application icon will be displayed.


N an

4. Move the mouse pointer over the Terminal application icon and:
Right-Click
D al

Add to Favorites
n

Text stating Terminal has been added to your Favorites will appear.
er

Press Esc
o

5. The Terminal icon should now be accessible under Favorites in the side menu when you
t
In

click on the Activities menu text


SE

Task 3: Remove an Application from your Favorite Applications


SU

1. To open the main menu, click Activities in the top left corner
2. Move the mouse pointer down to the Favorites section of the screen, hover over the
Help icon (Life Preserver) and:
Right-Click
Remove from Favorites
The Help icon should disappear from the Favorites section of the screen

13
SUSE Linux Enterprise Server Administration
Summary:
In this exercise, you added an application to your favorite applications. You also
removed an application from your favorite applications.

(End of Exercise)

y
nl
O
e
te Us
bu r
tri ne
is rt
D Pa
ot d
N an
D aln
er
o
t
In
SE
SU

14
SUSE Linux Enterprise Server Administration

1- 3 Use the File Manager

Description:

y
In this exercise you practice using the Files file manager.

nl
O
Task 1: Copy a File with Files

e
1. Make sure you are logged in to server1 as tux

te Us
2. To start the Files file manager click the Activities menu and then move your mouse to
the Favorite Applications area on the left side of the screen click the Files (file
cabinet) icon to start Files

bu r
tri ne
3. To view the contents of the /etc directory, select Other Locations then from the right
frame select Computer
is rt
4. Double-click the /etc icon
D Pa
5. To copy the /etc/aliases file onto the desktop, locate the aliases file icon and right-
click the icon. From the pop-up menu, select Copy To
In the Select Copy Destination window click the Home icon in the left frame and then
ot d

double-click the Desktop icon in the right frame. Then press the Select button
N an

6. Switch back to your home directory by selecting Home folder in the left side panel
7. To move the aliases file from the Desktop directory into your home directory do the
following:
D al

Double-click the Desktop icon in the right frame to see the content of the directory
n

Click the aliases file icon and keep the mouse button pressed
er

Drag the mouse pointer with the file icon over the Home icon in the left side panel
o

and release the mouse button


t
In

Task 2: Rename a copied File


SE

1. View the contents of the Home folder


2. Rename the copied file by right-clicking the aliases file icon and select Rename from
SU

the context menu


3. For the new file name type example.txt and then press Enter

Task 3: Delete a File


1. Delete the example.txt file by dragging the file icon over the Trash icon in the left side
panel and releasing the mouse button
2. Close the Files file browser window

15
SUSE Linux Enterprise Server Administration

Summary:
In this exercise, you copied a file, renamed it and moved it into the trash.

(End of Exercise)

y
nl
O
e
te Us
bu r
tri ne
is rt
D Pa
ot d
N an
D aln
er
o
t
In
SE
SU

16
SUSE Linux Enterprise Server Administration

1- 4 Change Screen Settings

Description:

y
In this exercise, you change the screen settings.

nl
O
Task 1: Change Screen Settings

e
1. Make sure you are logged in to server1 as tux

te Us
2. Launch settings by clicking on the Activities menu and in the Search dialogue type:
Settings

bu r
tri ne
3. When the Settings (gear) icon appears, click on it to start Settings
4. To start the Display Configuration tool, select:
Devices > Displays is rt
D Pa
5. In the display configuration tool there should be one display labeled “Unknown
Display” listed. Select this item by clicking on it.
6. From the Resolution menu, select
ot d
N an

1440x900 (16:10)

Click Apply
D al

7. In the confirmation dialog select Keep Changes. You may wish to resize the virtual
n

machine window to view all of the display area without scrolling.


er

8. Close the Displays window


o
t
In

Summary:
SE

In this exercise you changed the screen settings.


SU

(End of Exercise)

17
SUSE Linux Enterprise Server Administration

2 The Linux Filesystem

Description: In this section you’ll briefly explore the Linux filesystem and it’s hierarchy.

y
nl
O
e
te Us
bu r
tri ne
is rt
D Pa
ot d
N an
D aln
er
o
t
In
SE
SU

18
SUSE Linux Enterprise Server Administration

2- 1 Explore Filesystem Hierarchy

Description:
In this exercise, you will briefly explore the structure of the filesystem.

y
nl
O
Task 1: Open a terminal Session as the root User

e
1. On server1, open a terminal by clicking on the Activities menu and type:

te Us
terminal
When the Terminal icon appears, click on it to start a terminal session

bu r
2. Switch to the root user by typing:

tri ne
su -
is rt
Enter the root user password
D Pa
Task 2: Install the tree command
ot d

1. As the root user on server1, install the tree command:


N an

zypper in tree

Answer Yes to the prompt


D al

The output should show the tree command being installed.


n
er

Task 3: Use tree to View the Structure of System Directory Hierarchies


o
t
In

1. As the root user on server1, run the tree command:


tree
SE

The output should show the tree structure of the root user’s home directory.
2. Now show the directory structure of the /home folder hierarchy with:
SU

tree /home
The output should show the more extensive structure of the /home including the tux
user’s directory and file structure.
3. Now show the directory structure of the /etc directory with:
tree /etc
This will show you a lot of files and directories and will scroll long past the limits of the
screen.

19
SUSE Linux Enterprise Server Administration
4. Now show the directory structure of the /etc directory leaving out the files and just
showing the directories with:
tree -d /etc
The output will show only directories in the /etc hierarchhy, not the files in them.
5. Finally, show the structure of the files and directories in the /etc/zypp directory hierarchy
and the full path of each one with:
tree -f /etc/zypp

y
nl
The output will show the files and directories in the /etc/zypp hierarchy, including the full
path and filename of each object.

O
6. Close your root session by typing:

e
exit

te Us
7. Close your terminal session by typing:
exit

bu r
tri ne
Summary:
is rt
In this exercise you explored the file system hierarchy using the tree command.
D Pa
(End of Exercise)
ot d
N an
D aln
er
o
t
In
SE
SU

20
SUSE Linux Enterprise Server Administration

3 Work with the Command Line

Description:

y
nl
In this section you will learn how to use the available help systems. You will then

O
become familiar with using the shell. You will then use the command line to manage files
and folders.

e
te Us
bu r
tri ne
is rt
D Pa
ot d
N an
D aln
er
o
t
In
SE
SU

21
SUSE Linux Enterprise Server Administration

3- 1 Access and use man and info Pages

Description:
In this exercise, you use the whatis, man and info commands and navigate through

y
nl
the help text.

O
Task 1: Open a terminal session

e
te Us
1. On server1, open a terminal by clicking on the Activities menu and type:
terminal

bu r
When the Terminal icon appears, click on it to start a terminal session

tri ne
is rt
Task 2: Use the man Command to Find Information
D Pa
2. Find the manual section categories with:
man man
ot d

3. Then when the manual page for the man command appears, find the area which
N an

mentions the section numbers that man pages are categorized into with:

/section numbers
D al

The section numbers listing will be shown in the approximate middle of the screen. Note
n

that Section 1 is described as Executable programs or shell commands and that


er

Section 8 is described as System Administration commands (usually only for root).


o
t

4. Quit the man command with:


In

q
SE

5. Attempt to view the man page for the crontab command with:
man crontab
SU

Notice that the interface shows a couple of selections, one of which has an * character
to the left of the crontab text, this is the default and if you wait a few (approximately 8)
seconds, the man command will automatically load this man page, and not the other
listed man page(s) that matched your search.
Notice also that the section for each of the found items is shown to the right of the item
in parentheses (1).
6. Quit the man command with:
q

22
SUSE Linux Enterprise Server Administration
7. Switch to the root user with su - and force mandb to update. Normally this is done daily
via a cron job.
mandb
8. Switch back to the tux user:
exit
Task 3: Finding the Command or File You Really Want

y
1. Search for all instances of a command or a file named crontab with:

nl
man -f crontab

O
You will see that apparently the man command searched the left-side command or
filename portion of the man pages and returns several man pages for the text crontab.

e
2. Run the following command and compare it’s output with the above command’s output:

te Us
whatis crontab
You will notice the output is identical with the -f option’s output.

bu r
tri ne
3. See if you can find any more man pages that mention the text crontab in the right-side
description of the man page headers with:
man -k crontab is rt
D Pa
Notice that using the -k option finds even more man pages than the -f option. This is
because the -f option searches only the command or file name, whereas the -k option
searches the entire name and description line.
ot d

4. Run the following command and compare it’s output with the above command’s output:
N an

apropos crontab
You will notice the output is identical with the -k option’s output.
D aln

Task 4: Go Directly to a Particular Man Page and Find Text


er
o

1. To go directly to a given man page, use the following:


t
In

man 5 crontab
Notice the man page shown is the crontab man page from section 5, which is
SE

described as containing File formats and conventions.


2. Navigate to the 10th line of the file using:
SU

10G
3. Now navigate back to the top of the man page using:
1G
4. Search within the crontab man page for an example of the CRON file with:
/^EXAMPLE
The search above begins with the forward slash denoting a search, then the caret
character which means that the text we are looking for starts on column one of any line,
and then the text we are looking for, aka a man page section inside of a man page.

23
SUSE Linux Enterprise Server Administration
The page should be focused on the EXAMPLE CRON FILE portion of the man page.
5. Navigate to the end of the man page using:
G
6. Quit the man command with:
q

y
Task 5: Use the info Command

nl
1. From the terminal window display the info pages for the info command by entering:

O
info info

e
2. Move the cursor to the line referring to (Invoking Info) by pressing

te Us
Tab
Tab

bu r
3. Follow the link by pressing

tri ne
Enter
is rt
4. Move the cursor to the link Note Custom Key Bindings: by pressing
D Pa
Tab (6 times)
5. Follow the link by pressing
ot d

Enter
N an

6. Return to the page Note Custom Key Bindings: by typing (lowercase L):
l
D al

7. Exit the info file by typing:


n

q
er
o

8. Close the terminal window


t
In
SE

Summary:
In this exercise, you used the whatis, man, apropos and info commands and
SU

navigated through the help text.

(End of Exercise)

24
SUSE Linux Enterprise Server Administration

3- 2 Use the Shell History

Description:

y
In this exercise, you use the shell history to retrieve and execute previously entered

nl
commands.

O
e
Task 1: Open a terminal session

te Us
1. On server1, open a terminal by clicking on the Activities menu and type:
terminal

bu r
When the Terminal icon appears, click on it to start a terminal session

tri ne
Task 2: View the Shell History
is rt
1. To view the history cache in a terminal window enter:
D Pa
history
2. Press the Up-arrow until you see a command you would like to execute then press
ot d

Enter
N an

3. Execute and quit (if needed, using q) the following commands to load up some history
items:
D al

info top
man top
n

top
free
er

clear
o
t

4. Execute the info top history line by typing:


In

!in
The info top command history item will be executed
SE

5. Quit the info command with:


q
SU

6. Execute the free command’s history line with:


!fr
7. Run the history command again:
history
8. Noting the line number associated with the man top command, invoke it by typing:
!## (replace the hashmarks with the actual numerals of the man top history entry)

25
SUSE Linux Enterprise Server Administration
9. Type h and press Page Up once, you should see the history command at the
command line again
10. Press Enter to execute the history command again
11. Re-run the history command at the command line again using:
!!
12. Clear your screen using:

y
!cl

nl
13. exit the terminal session using:

O
exit

e
Summary:

te Us
In this exercise, you used the history command to retrieve and execute previously
entered commands.

bu r
tri ne
is rt (End of Exercise)
D Pa
ot d
N an
D aln
er
o
t
In
SE
SU

26
SUSE Linux Enterprise Server Administration

3- 3 Use Piping and Redirection

Description:

y
In this exercise, you redirect the output of commands into files and pipe the output of

nl
commands to other commands.

O
e
Task 1: Open a terminal session

te Us
1. On server1, as the tux user, open a terminal by clicking on the Activities menu and
type:

bu r
terminal

tri ne
When the Terminal icon appears, click on it to start a terminal session

is rt
Task 2: Use Redirection to Create a File
D Pa
1. Redirect the output of a command to a file on disk with:
ls /etc > dir-listing.txt
ot d

2. Count the number of lines in the resulting file with:


N an

wc -l dir-listing.txt
Note the number of lines indicated for later reference.
D al

Task 3: Use Redirection to Overwrite a File


n

1. Redirect the output of a command to a file on disk with:


er

ls ~ > dir-listing.txt
o
t
In

2. Count the number of lines in the resulting file with:


wc -l dir-listing.txt
SE

Compare this number of lines with the previous steps number, indicating the file was
overwritten by the contents of your home directory.
SU

Task 4: Use Redirection to Append to a File


1. Redirect the output of a command to a file on disk with:
ls ~ >> dir-listing.txt
2. Count the number of lines in the resulting file with:
wc -l dir-listing.txt
Compare this number of lines with the previous steps number, the file has doubled in
size, showing that the output was appended to the file.

27
SUSE Linux Enterprise Server Administration
Task 5: Copy and Count the Lines in a File
1. Copy a sample text file from the documentation directories with:
cp /usr/share/doc/packages/vim/README.txt vim-readme.txt
2. Count the number of lines in the resulting file with:
wc -l vim-readme.txt
The file should contain 133 lines of content.

y
nl
Task 6: Number the Lines in a File

O
1. Number just the lines of a file that have content with:
nl vim-readme.txt

e
You will see the output indicates that 88 lines were numbered, leaving blank lines

te Us
unnumbered.
2. Number all lines of a file with:

bu r
nl -ba vim-readme.txt

tri ne
You will see the output indicates that all 133 lines were numbered, including lines with
no content.
is rt
D Pa
Task 7: Prepare a File for Printing
1. Keeping in mind the original number of lines in the file, add page numbers, line widths
and double-spacing to the file with:
ot d
N an

pr -d vim-readme.txt | wc -l
You will observe that the file is considerably lengthened by the formatting added to it by
the command.
D al

Task 8: Using Pipes and Redirection Together


n

1. Prepare a raw text file on disk for printing and display the identical output on the console
er

with:
o
t
In

cat vim-readme.txt | nl -ba | pr | tee vim-readme.2print | less


2. Navigate to the bottom of the output in less with:
SE

G
Note the number of lines in the output, for comparison in the next step.
SU

3. Quit the less command with:


q
4. Verify the number of lines of content in the vim-readme.2print file with:
wc -l vim-readme.2print
The number of lines indicated should match the number of lines in the less command’s
output, showing the exact output was shown on screen and committed to disk.
5. Close the terminal window

28
SUSE Linux Enterprise Server Administration

Summary:
In this exercise, you redirected the output of a command.

y
(End of Exercise)

nl
O
e
te Us
bu r
tri ne
is rt
D Pa
ot d
N an
D aln
er
o
t
In
SE
SU

29
SUSE Linux Enterprise Server Administration

3- 4 Change Directories and List Directory Contents

Description:

y
In this exercise, you learn how to use the cd, pwd, and ls commands, change the

nl
current directory and list the directory contents.

O
e
Task 1: Open a terminal session

te Us
1. On server1, as the user tux, open a terminal by clicking on the Activities menu and
type:

bu r
terminal

tri ne
When the Terminal icon appears, click on it to start a terminal session

is rt
D Pa
Task 2: Navigate Around the File System
1. Change to the /tmp directory by entering:
ot d

cd /tmp
N an

2. Display the name of the current directory by entering:


pwd
D al

3. Change to the home directory by entering:


n

cd ~
er

4. Display the name of the current directory by entering:


o
t

pwd
In

5. Change to the /usr/share/doc directory by entering:


SE

cd /usr/share/doc
6. Display the name of the current directory by entering:
SU

pwd
7. Change back to tux’s home directory by entering:
cd -
8. Display the name of the current directory by entering:
pwd

30
SUSE Linux Enterprise Server Administration
Task 3: List Directory Contents
1. Display the content of the current directory by entering:
ls
2. Display the content of the current directory, including the hidden files, by entering:
ls -a
3. View the permissions and the file sizes of all the files in the current directory by

y
entering:

nl
ls -la

O
4. List the contents of the current directory and display the classification indicators for the
various file types with:

e
te Us
ls -lF

Note what file types the various indicators match up with, */=>@|. For example,
directories will have a / character appended to the end indicating a directory. What

bu r
tri ne
does the * character indicate?

Hint: You can find the answers to the above by using the info ls command, and
is rt
searching for the phrase classify.
D Pa
Summary:
ot d

In this exercise, you the file system and displayed the content of the current directory.
N an
D al

(End of Exercise)
n
er
o
t
In
SE
SU

31
SUSE Linux Enterprise Server Administration

3- 5 Perform Multiple File Operations

Description:

y
In this exercise, you copy and move files with the cp and mv commands, create

nl
directories with the mkdir command, delete files and directories with the rm and rmdir

O
commands and link files with the ln command.

e
te Us
Task 1: Open a terminal session
1. On server1, as the tux user, open a terminal by clicking on the Activities menu and
type:

bu r
tri ne
terminal
When the Terminal icon appears, click on it to start a terminal session
is rt
D Pa
Task 2: Create a Test Directory and Test Files
1. Create a /home/tux/test directory using the following command:
ot d
N an

cd ; mkdir test
2. Change to the newly-created test directory and create a file named myfile using the
following commands:
D al

cd ~/test ; touch myfile


n
er

Task 3: Move and Copy Files


o
t

3. Rename myfile to firstfile by entering the following:


In

mv myfile firstfile
SE

4. Verify that the file was renamed by entering:


ls -l
SU

5. Make a copy of firstfile and name it secondfile by entering the following:


cp firstfile secondfile
6. Verify that secondfile was created by entering:
ls -l sec*
7. Copy the /usr/bin/rename and /usr/bin/tac files to the /tmp/ directory by entering
the following:
cp /usr/bin/rename /usr/bin/tac /tmp

32
SUSE Linux Enterprise Server Administration
8. Verify that the files were copied by entering:
ls -l /tmp
9. Move the /tmp/tac file to the home directory (~) by entering the following:
mv /tmp/tac ~
10. Verify the move by entering:
ls -l ~

y
nl
11. Move and rename the /tmp/rename file to ~/oldrename by entering the following:
mv /tmp/rename ~/oldrename

O
12. Verify that the oldrename file exists by entering:

e
ls -l ~/oldrename

te Us
13. Copy the complete /bin/ directory to the home directory with the new directory being
named mybin by entering the following:

bu r
cp -r /bin ~/mybin

tri ne
14. Verify that the files were copied by entering:
ls -l ~/mybin is rt
D Pa
Task 4: Create Directory Structures
ot d

1. Create a directory named newdir inside the test directory by entering the following:
N an

mkdir ~/test/newdir
2. Verify that the directory was created by entering the following:
D al

ls ~/test
n

3. Create a directory tuxdir including a new directory emptydir as a subdirectory of the


er

~/test directory by entering the following:


o
t

mkdir -p ~/test/tuxdir/emptydir
In

4. Verify that tux_dir was created by entering:


SE

ls ~/test
5. Verify that emptydir was created by entering:
SU

ls ~/test/tuxdir

Task 5: Delete Files and Directories


1. Try to remove the ~/test/tuxdir directory by entering:
rmdir ~/test/tuxdir
A message is displayed indicating that the directory cannot be removed. This is
because the directory is not empty.

33
SUSE Linux Enterprise Server Administration
2. Remove the ~/test/tuxdir/emptydir directory by entering the following:
rmdir ~/test/tuxdir/emptydir
3. Verify that the emptydir directory has been removed by entering:
ls ~/test/tuxdir
4. Remove the ~/tux_dir directory by entering:
rmdir ~/test/tuxdir

y
nl
5. Verify that the directory was removed by entering:
ls

O
6. Remove the ~/my_dir/login file by entering:

e
rm ~/mybin/login

te Us
7. Verify that the file has been removed by entering:
ls ~/mybin/login

bu r
tri ne
A message indicating there is no such file or directory should displayrm
8. Remove all files with names that begin with “a” in the /home/tux/my_dir/ directory by
is rt
entering the following:
D Pa
rm -i ~/mybin/a*
Confirm every warning by entering:
ot d

y
N an

9. Remove the /home/tux/my_dir/ directory including its content by entering the


following:
D al

rm -r ~/mybin
and if prompted confirm every warning by entering:
n
er

y
o

10. Verify that the directory has been removed by entering:


t
In

ls ~/mybin
SE

Task 6: Link Files


SU

1. Enter the following to create a symbolic link to the my_file file in your home directory:
ln -s ~/test/firstfile symlink
2. Enter the following to create a hard link to the my_file1 file in your home directory:
ln ~/test/firstfile hardlink
3. Display the links by entering:
ls -l

34
SUSE Linux Enterprise Server Administration
Notice that the symbolic link identifies the file it is linked to, and that the files that are
hardlinked show a link count of 2 in the second column.
4. Show the inode information about these files with:
ls -li
Notice that the files symlink and firstfile have different inode information, whereas
the file firstfile and hardlink have the same inode information.
5. Using the first column of the output from the previous command, find the two files in the

y
/home directory tree that have the same inode number with the command:

nl
find /home -inum XXXXXXX
You must have used the inode number from either the hardlink or firstfile files in

O
place of the X’s in the above command for it to work properly.

e
Summary:

te Us
In this exercise, you copied and moved files. You also created and deleted directories
and links.

bu r
tri ne
is rt (End of Exercise)
D Pa
ot d
N an
D aln
er
o
t
In
SE
SU

35
SUSE Linux Enterprise Server Administration

3- 6 Use Shell Commands to Work with Files

Description:

y
In this exercise, you create an empty file and view the content of a file by using the

nl
cat, less, head, and tail commands.

O
e
Task 1: Open a terminal session

te Us
1. On server1, as the tux user, open a terminal by clicking on the Activities menu and
type:

bu r
terminal

tri ne
When the Terminal icon appears, click on it to start a terminal session

is rt
D Pa
Task 2: Displaying and Finding Content in Text Files
1. Open a second terminal window on server1 and log in as root (su -).
2. In the second terminal session display the content of the /var/log/messages file by
ot d

entering:
N an

cat /var/log/messages
3. Display the content of /var/log/messages page-by-page by entering:
D al

less /var/log/messages
n

4. Find the first occurrence of the word “root” by entering:


er
o

/root
t
In

and find the next occurrence of the word “root” by typing:


n
SE

5. Navigate through the output by using the cursor keys and the Page Up and the Page
Down keys
SU

6. Quit the display and return to the command line by typing:


q

Task 3: Using head and tail to Display File Contents


1. Display the first 5 lines of the /var/log/messages file by entering:
head -n 5 /var/log/messages
2. View a continuously updated display of the last lines of the /var/log/messages file by

36
SUSE Linux Enterprise Server Administration
entering:
tail -f /var/log/messages
This option allows you to see updates to the log file in real-time.
3. Arrange the terminal windows on the desktop so that you can see the content of both
4. In the first terminal window you opened in Step 1, log in as root (su -) entering an
invalid password such as blah
5. Notice that the login attempt is logged in the second terminal window

y
nl
6. In the first terminal window, log in as root (su -) using the correct password
7. The login is logged in the second terminal window

O
8. Log out as root in the first terminal window by entering:

e
exit

te Us
9. Close the first terminal window by entering:
exit

bu r
10. Stop the tail process in the second terminal window by pressing:

tri ne
Ctrl+C
is rt
11. Log out as root by entering:
D Pa
exit
12. Close the terminal window
ot d
N an

Summary:
D al

In this exercise, you viewed files. You also created and deleted directories and links.
n
er
o
t

(End of Exercise)
In
SE
SU

37
SUSE Linux Enterprise Server Administration

3- 7 Create File Backup

Description:

y
In this exercise, you will create archives using the tar command and sync these archives to

nl
another directory using rsync.

O
e
Task 1: Open a terminal session

te Us
1. On server1, as the tux user, open a terminal by clicking on the Activities menu and
type:

bu r
terminal

tri ne
When the Terminal icon appears, click on it to start a terminal session

is rt
D Pa
Task 2: Create a Tar Archive
1. Make sure you are logged as tux and open a terminal window
2. To create an empty directory, enter:
ot d
N an

mkdir ~/mybackups
3. To change into the new directory enter:
D al

cd ~/mybackups
n

4. To create a tar archive out of the files in the /bin directory, enter the following:
er

tar cvf bin-archive.tar /bin


o
t

5. View the space utilization of the new .tar file with:


In

ls -l bin-archive.tar
SE

Note the size of the .tar file for comparison with future compressed versions.
SU

Task 3: Create Compressed Tar Archives


6. To create a gzipped tar archive out of the files in the /bin directory, enter the following:
tar czvf bin-archive.tar.gz /bin
7. To create a bz2-zipped tar archive out of the files in the /bin directory, enter the
following:
tar cjvf bin-archive.tar.bz2 /bin
8. To compare the size of the three archives enter:

38
SUSE Linux Enterprise Server Administration
ls -l bin-archive*.*

Notice the .tar version is over twice as large as the compressed versions, and that
the .bz2 archive is slightly smaller than the .gz version.

Task 4: Sync Tar Archive


1. To create a new directory to sync the archives into enter:

y
nl
mkdir /tmp/destinationdir

O
2. To sync the content of the mybackups directory into the destination_dir directory
enter:

e
rsync -av ~/mybackups/* /tmp/destinationdir/

te Us
3. To verify that the files were copied enter:
ls -la /tmp/destinationdir

bu r
tri ne
Task 5: Change Content in the Source Directory
is rt
1. To create new files in the mybackups directory, you can extract the file bin/login from
D Pa
the bin-archive.tar.gz archive. Enter the following:

tar xzvf bin-archive.tar.gz bin/login


ot d

2. To test if the extraction was successful enter:


N an

ls -a ~/mybackups
D al

3. You should see a new directory bin


4. To display the content of the bin directory enter:
n
er

ls -a ~/mybackups/bin
o

You should see the extracted file login.


t
In

5. To sync the content of the mybackups directory into the destinationdir directory
enter:
SE

rsync -av ~/mybackups/* /tmp/destinationdir/


In the output on the screen you should see that only the bin directory and the login
SU

files were transferred

Summary:
In this exercise, you created archives using the tar command and synchronized these
archives to another directory using rsync.

39
SUSE Linux Enterprise Server Administration
(End of Exercise)

y
nl
O
e
te Us
bu r
tri ne
is rt
D Pa
ot d
N an
D aln
er
o
t
In
SE
SU

40
SUSE Linux Enterprise Server Administration

3- 8 Search File Content

Description:

y
In this exercise, you find a special character combination in a file with the grep and

nl
egrep commands.

O
e
Task 1: Open a terminal session

te Us
1. On server1, as the tux user, open a terminal by clicking on the Activities menu and
type:

bu r
terminal

tri ne
When the Terminal icon appears, click on it to start a terminal session

is rt
D Pa
Task 2: Search File Content
1. From a terminal window find all HTML headings of hierarchy 2 in the /usr/share/doc/
packages/yast2-users/users.html file by entering the following (on one line):
ot d

grep "<h2>" /usr/share/doc/packages/yast2-users/users.html


N an

The output may appear similar to this:


D al

<h2>Features (SL9.3)</h2>
<h2>Implementation</h2>
n

<h2>The files</h2>
er

2. Find all locations in the HTML files of the /usr/share/doc/packages/yast2-users/


o

directory that include the word “configuration” by entering the following (on one line):
t
In

grep configuration /usr/share/doc/packages/yast2-users/*.html


The output may appear similar to this:
SE

<h1>YaST2: Users configuration module</h1>


3. Find all locations in the TXT files of all “yast2” directories /usr/share/doc/packages/
SU

yast2-*/ that include lines beginning with a upper case letter A, B or C by entering the
following (on one line):
egrep "^[ABC]" /usr/share/doc/packages/yast2-*/*.txt
4. Find all locations in the TXT files of all /usr/share/doc/packages/yast2-*/
directories that include lines beginning with the letter “m” or “n” by entering the following
(on one line):
egrep "^[mn]" /usr/share/doc/packages/yast2-*/*.txt

41
SUSE Linux Enterprise Server Administration
5. Close the terminal window

Summary:
In this task you used grep and egrep to search for the string “<h2>” in a HTML file.
You then searched for all TXT files that include lines beginning with a number and

y
finally you searched for TXT files that include lines beginning with the letter “m” or “n”.

nl
O
(End of Exercise)

e
te Us
bu r
tri ne
is rt
D Pa
ot d
N an
D aln
er
o
t
In
SE
SU

42
SUSE Linux Enterprise Server Administration

4 The VIM Editor

Description:

y
nl
You will learn the basic functions of the Vim editor.

O
e
te Us
bu r
tri ne
is rt
D Pa
ot d
N an
D aln
er
o
t
In
SE
SU

43
SUSE Linux Enterprise Server Administration

4- 1 Use vim to Edit and Manipulate Text Files

Description:
In this exercise, you will use the vim editor to open vim with various options, create

y
nl
new files, save and exit vim.

O
Task 1: Open a terminal session

e
te Us
1. On server1, as the tux user, open a terminal by clicking on the Activities menu and
type:
terminal

bu r
tri ne
When the Terminal icon appears, click on it to start a terminal session.

is rt
Task 2: Open an Existing File for Editing with Various Options
D Pa
1. Copy an existing file to your home directory with:
cp /usr/share/doc/packages/zip/WHATSNEW ~/zipwhatsnew.txt
ot d
N an

2. Open the new file for editing/display with:


vim zipwhatsnew.txt
D al

This will open the file and place your cursor to the left of the first occurrence of text by
default.
n

3. Quit the VIM editor with:


er
o

:q
t
In

4. Open the file again and automatically position your cursor on the first line that has the
word zip30.ann in it:
SE

vim +/zip30.ann zipwhatsnew.txt


Verify that your cursor is on the first line in the file with the filename zip30.ann in it,
SU

which should be line 6.


5. Open the file again and automatically move your cursor to line 25 with:
vim +25 zipwhatsnew.txt
Verify that you are indeed on line 25 of the file by inspecting the positional indicators on
the right bottom of the editor screen, which should read 25,1.
6. Quit the vim editor with:
:q

44
SUSE Linux Enterprise Server Administration
Task 3: Navigate in and Save an Existing File as a New File with Changes
1. Open the zipwhatsnew.txt file with the vim editor:
vim zipwhatsnew.txt
2. Navigate to the top of the file and then to the blank line just above the 4 th full paragraph
that starts with the text - AES encryption with the keystrokes:
1G

y
4}

nl
This should move you to the blank line between the two paragraphs.

O
3. Navigate down a line to the start of the line that begins with - AES encryption with the
down arrow key or use the keystroke:

e
j

te Us
4. With the cursor on the text line, delete the line from the buffer with the keystrokes:
dd

bu r
5. Using your cursor/arrow keys, navigate so that the cursor is on the first letter of the word

tri ne
Unicode three lines below your current line, and delete the word with the keystrokes:
dw is rt
D Pa
6. Re-add the word Unicode back in to the buffer, entering Insert mode with:
i
Uni-code
ot d
N an

7. Add a space to separate Uni-code from the word paths, then:


[ESC]
D al

8. Write a new file from the changed buffer with the command:
n
er

:w zipwhatsnew-edited.txt
o

Notice that the filename at the bottom left of the interface indicates have just created a
t
In

[New] file.
9. Exit the zipwhatsnew.txt file WITHOUT saving the edits to the file with:
SE

:q!
SU

Task 4: Search and Replace Text in a File


1. Edit the zipwhatsnew-edited.txt file with:
vim zipwhatsnew-edited.txt
2. Go to the top of the file and begin searching down the file for a string with:
1G
/Unicode
[ENTER]
3. Notice that your cursor automatically goes to the string as you type it.

45
SUSE Linux Enterprise Server Administration
4. Now search for more instances of the string with:
n
n
n
5. Notice that your cursor goes to the next string you searched for, and the next etc.
6. Now reverse search back up the file with:
N

y
N

nl
7. Search for instances of a text string in the buffer with:

O
1G
:%s/zip/Zippy/g

e
te Us
Notice we had you start at the top of the buffer, so all instances of the found text are
replaced throughout the entire file.

bu r
Notice also that the search and replace uses the g character to indicate that you are

tri ne
wanting to globally replace zip with Zippy, otherwise it would only replace the first
instance of each found string.
is rt
8. Undo your search and replace, restoring the file to it’s initial state with:
D Pa
u
ot d

This will work if you have not saved the buffer to disk, if you save to disk, the undo
N an

feature will not work.

9. Quit the file without saving:


D al

[ESC]
n

:q!
er
o
t
In

Note:
The search and replace syntax in vim is similar to that of sed, with the /g
SE

characters at the end of the command invoking global replacement of the text
string, as opposed to just replacing the first found instance of the string on a given
line.
SU

Task 5: Compare Two Similar Files for Differences


1. From the command line, compare the two versions of the GPL License file with:
vimdiff zipwhatsnew.txt zipwhatsnew-edited.txt
You should see a dual-pane interface with the two files loaded and synchronized,
showing the differences between them marked in various colors.

46
SUSE Linux Enterprise Server Administration
2. Exit the vimdiff instance, including both files with:
:qa
3. Exit the terminal with:
exit

Summary:

y
nl
In this exercise, you used the vim editor to open, navigate within, delete text from, add

O
text to and save another copy of a changed file buffer, as well as showing you how to
search and replace text and compare two similar files for their differences.

e
te Us
(End of Exercise)

bu r
tri ne
is rt
D Pa
ot d
N an
D aln
er
o
t
In
SE
SU

47
SUSE Linux Enterprise Server Administration

5 Remote Administration

Description:

y
nl
You will use SSH and VNC to remotely manage systems.

O
e
te Us
bu r
tri ne
is rt
D Pa
ot d
N an
D aln
er
o
t
In
SE
SU

48
SUSE Linux Enterprise Server Administration

5- 1 Practice using OpenSSH Utilities

Description:
In this exercise, you practice using the SSH suite of utilities. You will use the SLE201-

y
nl
server1 and SLE201-server2 virtual machines for this lab exercise.

O
Task 1: Open a terminal session

e
te Us
1. Ensure both SLE201-server1 and SLE201-server2 are running.
2. On server2, as the tux user, open a terminal by clicking on the Activities menu and
type:

bu r
tri ne
terminal
When the Terminal icon appears, click on it to start a terminal session
is rt
3. Repeat step 2 on server1 to open a terminal
D Pa
Task 2: Access a remote server using SSH
ot d

1. From the terminal on server2, enter the following command to connect to the server1
N an

machine:
ssh tux@server1
D al

If prompted accept server1's host key by entering:


n

yes
er

2. When prompted enter tux's password for server1 (linux)


o
t

You are now logged in to server1 as tux


In

3. Log out by entering:


SE

exit
4. From the terminal on server1, enter the following on server1 to view the processes
running on server2:
SU

ssh tux@172.16.2.22 ps aux


If prompted accept host key by entering:
yes
5. When prompted enter tux's password for server2 (linux)
After entering tux's password, a list of all processes currently running on server2 should
be displayed

49
SUSE Linux Enterprise Server Administration
Task 3: Use scp to Copy Files to and from a Remote Server
Do the following on server1:
1. Enter the following command to copy the /etc/hosts file from server2 to the /tmp
directory on server1:
scp tux@172.16.2.22:/etc/hosts /tmp/
When prompted enter tux's password for server2

y
2. On server1, enter the following command to verify that the file was transferred:

nl
ls /tmp/hosts

O
You should see the hosts file from the server2 server in your /tmp directory
3. Enter the following command on server1 to copy the /etc/hosts file from server1 to

e
tux’s home directory on server2:

te Us
scp /etc/hosts tux@172.16.2.22:~
When prompted enter tux's password for server2

bu r
4. On server2 browse to the tux user's home directory (/home/tux) to verify that the file

tri ne
was copied
You should see the hosts file from the server1 in the tux user’s home directory on
server2 is rt
D Pa
Task 4: Use sftp
ot d

Do the following on server1


N an

1. Enter the following command to connect via sftp to server2:


sftp tux@172.16.2.22
D al

When prompted enter tux's password for server2


n

2. You should be at an sftp> prompt on server2


er

3. Enter the following command to copy the /bin/date program from server2 to tux’s
o

home directory:
t
In

get /bin/date /home/tux/


4. Exit sftp by entering:
SE

exit
5. Browse to the tux user's home directory to verify that the file was transferred
SU

Summary:
In this exercise you practiced using the SSH suite of utilities.

(End of Exercise)

50
SUSE Linux Enterprise Server Administration

5- 2 Configure Key Based Authentication in OpenSSH

Description:
In this exercise, you will practice using SSH utilities with public key authentication.

y
nl
Task 1: Generate an SSH Key Pair

O
1. Using server1 logged in as tux

e
2. Open a terminal window and enter the following command to generate an SSH key pair:

te Us
ssh-keygen -t rsa -b 4096
3. Accept the default location for the key (/home/tux/.ssh/id_rsa)

bu r
4. Enter a passphrase (twice) of:

tri ne
sles15
Information about your key pair, such as the location of your identification and the public
key, will be displayedis rt
D Pa
Task 2: Upload the Public Key to a Remote Server
ot d

1. On server1
N an

2. Enter the following command to upload your public key to tux on server2:
ssh-copy-id -i ~/.ssh/id_rsa.pub tux@172.16.2.22
D al

When prompted, enter tux's password for server2


n

3. After authentication you should see a message that the key was uploaded successfully
er
o
t
In

Task 3: Verify Key Based Login and Store the Private Key in the SSH Agent
1. Using server1 enter the following command to connect to server2 via ssh as tux:
SE

ssh tux@172.16.2.22
You should be prompted for a passphrase to unlock the private key (sles15)
SU

2. Follow the on-screen instructions about logging into server2 (172.16.2.22), by typing:

ssh tux@172.16.2.22

3. You will be prompted to unlock your private key, use the password sles15 and click:

Unlock

You will then be in a shell on server2, confirm by looking at the prompt.

51
SUSE Linux Enterprise Server Administration

4. Then log out (of server2 aka 172.16.2.22) by entering:

exit
Your prompt should indicate you are now back on server1 as the tux user.
5. On server1, enter the following command to determine if the SSH Agent has been
started:

y
ps aux | grep -i ssh-agent

nl
You should see an ssh-agent process for your user account. If the SSH Agent is not yet

O
running for your account, start it by entering the following command:
eval $(ssh-agent -s)

e
You will see an Agent pid value returned confirming it’s been started.

te Us
6. Enter the following command to add your key to the SSH Agent:
ssh-add

bu r
tri ne
7. When prompted, enter the passphrase of each of the keys that are being added to the
ssh-agent (sles15)
8. On server1, enter the following command to connect to server2 via ssh as tux again:
is rt
D Pa
ssh tux@172.16.2.22
This time you are not prompted for a password or passphrase because the ssh-agent
provided the key for you
ot d
N an

Task 4: Disable Password Based Logins


D al

1. Using server2 enter:


n

su –
er

with password linux to become root


o

2. In the text editor of your choice, open the /etc/ssh/sshd_config file to be edited
t
In

3. Locate the line that begins with:


PasswordAuthentication
SE

and make sure it is set to:


no
SU

4. If the line is #commented out, remove the # symbol in front of the line and make it read:
PasswordAuthentication no
5. Locate the line that begins with:
UsePAM
and change the value to:
no
6. Save the file and close the text editor

52
SUSE Linux Enterprise Server Administration
7. Enter the following command to restart the ssh daemon:
systemctl restart sshd
8. While still on server2, enter the following command to connect back to localhost:
ssh tux@localhost
and when asked whether you want to continue connecting, enter:
yes

y
nl
You should see an error message and no prompt for a password
9. On server2, log out as root by entering:

O
exit

e
10. On server1, log out of your ssh connection to server2 by entering:

te Us
exit
11. From your tux account on server1, log back in to server2 by entering:

bu r
ssh tux@172.16.2.22

tri ne
12. Despite your changes of the sshd configuration on server2 you should still be able to
is rt
log in because you are using public key authentication
13. Switch to the root user account on server2 with the su – command and in the text
D Pa
editor of your choice, open the /etc/ssh/sshd_config file and undo the changes
made at the beginning of this task
ot d

14. Restart the ssh daemon:


N an

systemctl restart sshd


15. On server2, log out as root by entering:
D al

exit
n

16. Log out from server2 by entering:


er

exit
o
t
In

You should now be back on server1 as the tux user.


SE

Summary:
SU

In this exercise, you have practiced using SSH utilities with public key authentication.

(End of Exercise)

53
SUSE Linux Enterprise Server Administration

5- 3 Remote Administration using VNC

Description:

y
Configure and use remote administration. In this lab you will remotely manage server2

nl
from server1 using VNC.

O
e
Task 1: Check remote administration is not enabled on server2

te Us
1. Logged in as tux on server2 start Yast2 by clicking on the Activities menu and typing
in YaST in the search dialog, then click the YaST icon to start YaST, then when
prompted enter the root user's password:

bu r
tri ne
linux
2. In the Network Services category, select Remote Administration (VNC). Notice that
is rt
Remote Administration is currently disabled.
D Pa
3. Cancel the Remote Administration configuration dialogue box
4. Close the YaST interface
ot d

Task 2: Try to remotely administer server2 from server1


N an

1. On server1 logged in as tux open a terminal window


2. In the terminal window run the vncviewer command and attempt to connect to server2:
D al

vncviewer server2:1
n

The session will not connect.


er

3. Terminate the vncviewer:


o
t

Press Enter or click the Close button


In

At this point we know the remote administration function is disabled on server2 but
there could also be firewall issues.
SE

Task 3: Enable remote management on server2


SU

1. Logged in as tux on server2 start Yast2 by clicking on the Activities menu and typing
in YaST in the search dialog, then click the YaST icon to start YaST, then when
prompted enter the root user's password:
linux
2. Select:
Remote Administration (VNC)
3. Select the following:

54
SUSE Linux Enterprise Server Administration
Allow Remote Administration Without Session Management: Selected
Open Port in firewall: Checked
4. Select:
Next
To save your changes
5. Read the Display Manager warning and select:

y
nl
OK

O
6. Reboot the server2 system, by choosing the Virtual Manager menu path:

e
Virtual Machine > Shut down > Reboot

te Us
7. If during the boot process you are not presented with the graphical login, use the Send
Key option of the virtual machine manager software and select Ctrl + Alt + F7 to return

bu r
tri ne
to the graphical interface

is rt
D Pa
Task 4: Remotely administer server2 from server1
1. On server1 in a terminal window as tux start the vncviewer and connect to server2:
ot d

vncviewer server2:1
N an

2. If presented by a hostname mismatch error, click:


D al

Yes
n

to continue
er

3. At the Certificate Issuer unknown dialogue box select:


o
t
In

Yes
4. In the VNC session login as tux
SE

5. Close the remote administration session by clicking on the close control X on the x11 –
TigerVNC window.
SU

Summary:
Server2 was configured to allow remote administration and the port in the firewall was
opened. A remote session was initiated from server1 using the vncviewer client.

(End of Exercise)

55
SUSE Linux Enterprise Server Administration

6 System Initialization

Description:

y
You will examine the boot process. You will then manage services using systemd.

nl
O
e
te Us
bu r
tri ne
is rt
D Pa
ot d
N an
D aln
er
o
t
In
SE
SU

56
SUSE Linux Enterprise Server Administration

6- 1 Secure GRUB with a Password


Description:
In this exercise, you set a password on GRUB.

y
nl
Task 1: Open a terminal session

O
1. On server1, as the tux user, open a terminal by clicking on the Activities menu and
type:

e
te Us
terminal
When the Terminal icon appears, click on it to start a terminal session.
2. Become the root user:

bu r
tri ne
su -

is rt
3. Enter the root user’s password:
D Pa
linux
ot d

Task 2: Secure Access to GRUB with a Password


N an

1. Enter the following command to generate an encrypted password to be used for GRUB:
grub2-mkpasswd-pbkdf2
D al

2. Enter the following password once initially and again to confirm it:
n

secret
er

3. Copy the whole password from the terminal window into the clipboard
o
t

Attention: The password starts with grub.pbkdf2.sha512 and looks SIMILAR to this:
In

grub.pbkdf2.sha512.10000.B9CEAE5D663870390C7ACD3BF6C0C926B0715D0BAF2
7726FA211925712D0D38B9D573037D42B1C4B32029AF5AD3E9F641594C1181653D
SE

C2324F91F0D6CDA761D.9B5CCAADF00BD2C1DBC03FD80060EE1F8B9AB2F81F2
BD927F3B99C21406EA8D04BDD5E59336D89756A3BDB5A622365AB4BAD3575AC7
SU

A2F44B35BC8A9D4E5D9BF
4. In the text editor of your choice, open the /etc/grub.d/40_custom file to be edited
5. Add the end of the file append the following:
set superusers="root"
password_pbkdf2 root GRUB_PW
Replace GRUB_PW by the encrypted password you generated in step 2
6. Save the file and close the text editor
7. To import your changes, enter the following:

57
SUSE Linux Enterprise Server Administration
grub2-mkconfig -o /boot/grub2/grub.cfg

Task 3: Test the GRUB Password


1. Reboot server1
2. To stop the countdown, press the up or down arrow key
3. Try to open edit the menu entry by pressing:

y
e

nl
You should be prompted to enter a username

O
4. Enter:

e
root

te Us
and press Enter
5. You should be prompted to enter a password. Enter the password you set previously
(secret)

bu r
6. You should now be able to edit the menu items

tri ne
7. To return to the GRUB menu, press:
Esc is rt
D Pa
8. Select the default boot entry and continue to boot
9. Log in as root and undo the changes made previously in this task
ot d

Hint: Remove the lines from the configuration file and re-run the command to commit it
N an

to file/disk.
D aln

Summary:
er

In this exercise, you set a password on GRUB.


o
t
In

(End of Exercise)
SE
SU

58
SUSE Linux Enterprise Server Administration

2 Manage Services

Description:

y
In this exercise, you manage services with the systemctl command.

nl
O
Task 1: Open a terminal session

e
1. On server1, as the tux user, open a terminal by clicking on the Activities menu and

te Us
type:
terminal

bu r
When the Terminal icon appears, click on it to start a terminal session

tri ne
2. Become the root user:
su - is rt
D Pa
3. Enter the root user’s password:

linux
ot d
N an

Task 2: Manage Services


1. View the status of the Network Time Protocol (NTP) daemon:
D al

systemctl status chronyd


n

2. Unless it has been changed from the default installation, it is not enabled and not active.
er

The output should look like this:


o
t

chronyd.service - NTP Server Daemon


In

Loaded: loaded (/usr/lib/systemd/system/chronyd.service; disabled)


Active: inactive (dead)
SE

Docs: man:chronyd(1)
3. Start the NTP daemon:
SU

systemctl start chronyd

4. Alternatives for the above command are;

service chronyd start

or

rcchronyd start

59
SUSE Linux Enterprise Server Administration

5. Check the status again:


systemctl status chronyd
6. You should see that the service is active, with the last 10 lines of log messages from
NTP. The output should begin similar like this:
chronyd.service - NTP client/server
Loaded: loaded (/usr/lib/systemd/system/chronyd.service; disabled; pr>

y
Active: active (running) since Mon 2018-07-16 15:52:57 MDT; 16s ago

nl
Docs: man:chronyd(8)
man:chrony.conf(5)

O
Process: 2900 ExecStartPost=/usr/share/chrony-helper update-daemon
(code=exit>

e
Process: 2897 ExecStart=/usr/sbin/chronyd $OPTIONS (code=exited, status=0/
SUC>

te Us
Main PID: 2899 (chronyd)
Tasks: 1 (limit: 4915)
CGroup: /system.slice/chronyd.service

bu r
└─2899 /usr/sbin/chronyd

tri ne
Jul 16 15:52:57 server1 systemd[1]: Starting NTP client/server...
Jul 16 15:52:57 server1 chronyd[2899]: chronyd version 3.2 starting
is rt
Jul 16 15:52:57 server1 systemd[1]: Started NTP client/server.
D Pa
7. Check to see if the NTP daemon is enabled:
systemctl is-enabled chronyd
ot d

Notice that the service is marked as disabled


N an

8. Enable the NTP daemon to make sure it starts when the system boots:
systemctl enable chronyd
D al

9. Check the status again:


n

systemctl status chronyd


er
o

10. The output should begin like this:


t
In

● chronyd.service - NTP client/server


Loaded: loaded (/usr/lib/systemd/system/chronyd.service; enabled;
vendor pre>
SE

Active: active (running) since Mon 2018-07-16 15:52:57 MDT; 3min 56s
ago
SU

Notice that the service is now marked as enabled


11. Review systemd information regarding NTP daemon:
systemctl show chronyd.service | less
12. To exit less press:
q
13. Find out which target starts chronyd:
find /etc/systemd/ -name "*chrony*"

60
SUSE Linux Enterprise Server Administration
find /usr/lib/systemd/ -name "*chrony*"
14. The chronyd daemon is started in the multi-user target
15. View the currently active targets:
systemctl list-units --type=target
16. View the dependencies for the multi-user target:
systemctl show -p "Requires" multi-user.target

y
systemctl show -p "Wants" multi-user.target

nl
17. Disable the chronyd daemon:

O
systemctl disable chronyd
18. Check the status again:

e
te Us
systemctl status chronyd
19. The output should begin like this:
● chronyd.service - NTP client/server

bu r
tri ne
Loaded: loaded (/usr/lib/systemd/system/chronyd.service; disabled;
vendor preset: disabled)
Active: active (running) since Mon 2018-07-16 15:52:57 MDT; 28min ago
is rt
D Pa
Notice that the service is now marked as disabled, but it is still running
20. Stop the NTP daemon:
ot d

systemctl stop chronyd


N an

21. Check the status again:


systemctl status chronyd
D al

22. The output should begin like this:


n

● chronyd.service - NTP client/server


Loaded: loaded (/usr/lib/systemd/system/chronyd.service; disabled;
er

vendor preset: disabled)


o

Active: inactive (dead)


t
In

23. Mask the NTP daemon unit file:


systemctl mask chronyd
SE

24. Check the status again:


systemctl status chronyd
SU

25. The output should begin like this:


chronyd.service
Loaded: masked (/dev/null)
Active: inactive (dead)

26. Try to start chronyd again:

systemctl start chronyd

61
SUSE Linux Enterprise Server Administration
27. NTP does not start because it is masked
28. Unmask the chronyd service:
systemctl unmask chronyd
You should see an error message about chronyd failing to start.
29. Check the status again:
systemctl status chronyd

y
30. The output should begin like this:

nl
● chronyd.service

O
Loaded: masked (/dev/null; masked)
Active: inactive (dead)

e
te Us
Summary:

bu r
In this exercise you started, stopped, enabled, disabled, masked and unmasked the

tri ne
NTP service using the applicable systemctl commands.
is rt
D Pa
(End of Exercise)
ot d
N an
D aln
er
o
t
In
SE
SU

62
SUSE Linux Enterprise Server Administration

6- 3 Work with systemd Targets

Description:

y
In this exercise, you work with systemd's target units.

nl
O
Task 1: Open a terminal session

e
1. On server1, as the tux user, open a terminal by clicking on the Activities menu and

te Us
type:
terminal

bu r
When the Terminal icon appears, click on it to start a terminal session

tri ne
2. Become the root user:
su - is rt
D Pa
3. Enter the root user’s password:

linux
ot d

Task 2: Change to Different Targets


N an

1. View the configured targets:


D al

systemctl list-units --type target


n

2. In the terminal window, enter:


er

systemctl isolate multi-user.target


o

The graphical interface shuts down and you are switched to the first virtual console
t
In

3. From the Virtual Machine’s interface main menu select Send Key → Ctrl+Alt+F4 to
switch to the fourth virtual console
SE

4. Log in as the root user


5. In the virtual console enter:
SU

systemctl isolate rescue.target


You see a brief list of instructions on how to change to a different target or how to reboot
the system
6. At the prompt, enter the root password (linux)

Task 3: Boot into a Different Target


1. Reboot server1

63
SUSE Linux Enterprise Server Administration
2. When the boot screen appears, press
e
to edit the kernel command line
3. (Conditional) If you are prompted to enter a boot password, enter:
secret
4. Move the cursor down to the line that starts with linux and move the cursor to the end
of that line. Add the following text at the end:

y
systemd.unit=rescue.target

nl
5. From the virtual machine window select Send Key → F10 to boot

O
If the bootup takes an abnormally long time, hit the:
[ESC]

e
te Us
This will allow you to see what is taking the time
6. If requested at the prompt, enter the root password
7. Start the graphical user interface:

bu r
tri ne
systemctl isolate graphical.target
8. Conditional: Sometimes there is a problem starting the graphical interface on the kvm
is rt
machine, if you have a problem restart server2
D Pa
9. Log in to the graphical environment as tux
ot d

Task 4: Add Services to and Remove Services from a Target Unit


N an

1. Using server1, as root log in to a virtual terminal, or, in the graphical environment, open
a terminal window and su - to root
D al

2. Enter the following:


n

la /etc/systemd/system/multi-user.target.wants/ | grep sshd


er

You should see in the output that ssh.service is a link to /usr/lib/systemd/system/


o

sshd.service
t
In

3. To copy the existing sshd.service file to /etc/systemd/system/, enter the following


in one line:
SE

cp /usr/lib/systemd/system/sshd.service /etc/systemd/system/
4. Open the /etc/systemd/system/sshd.service file in an editor such as vi and replace
SU

the existing line:


WantedBy=multi-user.target
by
WantedBy=graphical.target
5. Save the file and close the editor
6. The configuration in /etc/systemd/system/sshd.service will override the
configuration in /usr/lib/systemd/system/sshd.service
7. Enable the new configuration:

64
SUSE Linux Enterprise Server Administration
systemctl reenable sshd
8. Enter the following:
la /etc/systemd/system/multi-user.target.wants/ | grep sshd
You should get no output. The link was removed
9. Enter the following:
la /etc/systemd/system/graphical.target.wants/ | grep sshd

y
You should see in the output that ssh.service is a link to

nl
/etc/systemd/system/sshd.service

O
10. To undo the change, remove the /etc/systemd/system/sshd.service file and
reenable the service again:

e
rm /etc/systemd/system/sshd.service

te Us
systemctl reenable sshd
As there is no /etc/systemd/service/sshd.service file anymore, the installed
configuration in /usr/lib/systemd/system/sshd.service is used again

bu r
tri ne
Summary: is rt
D Pa
In this exercise, you worked with systemd's target units.
ot d
N an

(End of Exercise)
D aln
er
o
t
In
SE
SU

65
SUSE Linux Enterprise Server Administration

7 Process Management

Description:

y
nl
In this section you will manage processes and schedule jobs using cron.

O
e
te Us
bu r
tri ne
is rt
D Pa
ot d
N an
D aln
er
o
t
In
SE
SU

66
SUSE Linux Enterprise Server Administration

7- 1 Modify Process Priorities

Description:
In this exercise you will view process information using gnome-system-monitor and ps,

y
nl
modify process priorities using the nice and renice commands and kill processes with
the kill and killall commands.

O
e
te Us
Task 1: Modify Process Priority
1. On server1 logged in as tux start the (GNOME) System Monitor tool:
Click on the Activities menu and type:

bu r
tri ne
System Monitor
2. In the System Monitor dialog, click the Processes tab and search for the gnome-
is rt
system-monitor entry in the list of processes. Record the PID (column ID) for gnome-
D Pa
system-monitor:
3. _________
4. Open a terminal window by clicking on the Activities menu and typing:
ot d

terminal
N an

When the Terminal icon appears, click on it to start a terminal session.


5. To view all running processes enter:
D al

ps xl (lower case L)
n

Notice that the nice value (NI) is currently at 0


er

6. Decrease the priority of the process to a nice value of 5 by entering:


o
t
In

renice 5 -p <PID_OF_SYSTEM-MONITOR_PROCESS>
7. Increase the priority of the process to a nice value of -5 by entering:
SE

renice -5 -p <PID_OF_SYSTEM-MONITOR_PROCESS>
Note: A regular user can change the nice value but is only allowed to decrease the
SU

priority.
8. Switch to root (su -)
9. Try setting the nice value to -5 again by entering:
renice -5 -p <PID_OF_SYSTEM-MONITOR_PROCESS>
10. Check that the setting is effective by entering:
ps xl (lower case L)
Notice that the process is not displayed, because ps xl only displays processes started

67
SUSE Linux Enterprise Server Administration
by the current user. The System Monitor program was started by tux not root
11. View all processes by entering:
ps axl (with a lower case L)
The System Monitor process is now displayed, with a nice value of -5
12. Change the nice value for the System Monitor process to a higher priority by entering:
renice -10 -p <PID_OF_SYSTEM-MONITOR_PROCESS>

y
13. Verify that the gnome-system-monitor process nice value is set to -10 by entering:

nl
ps axl (with a lower case L

O
14. Exit the shell running as root by entering:

e
exit

te Us
15. You should now be back as the user tux again

bu r
Task 2: Specify Process Priority at Program Start

tri ne
1. At the shell as the tux user, start the xeyes program in the background with the nice
value of +10 by entering:
is rt
D Pa
nice xeyes &
2. Verify that the xeyes process nice value is set to +10 by entering:
ot d

ps axl
N an

Task 3: Terminate Processes


D al

1. To kill the gnome-system-monitor, enter:


n

kill <PID_OF_SYSTEM-MONITOR_PROCESS>
er

2. To kill all xeyes processes, enter:


o
t

killall xeyes
In

3. Close your terminal window


SE
SU

Summary:
In this exercise you viewed process information using gnome-system-monitor and ps,
modified process priorities using the nice and renice commands and killed processes
with the kill and killall commands.

(End of Exercise)

68
SUSE Linux Enterprise Server Administration

7- 2 Manage Linux Processes and Jobs

Description:

y
In this exercise, you practice starting and stopping processes.

nl
O
Task 1: Open a terminal session

e
1. On server2, as the tux user, open a terminal by clicking on the Activities menu and

te Us
type:
terminal

bu r
When the Terminal icon appears, click on it to start a terminal session.

tri ne
2. Enter the following command to become the root user:
su -
is rt
When prompted, enter linux for the root user’s password.
D Pa
Task 2: Display Linux Processes
1. At the command line, display the processes that are currently owned by tux by entering:
ot d
N an

ps -lu tux (with a lowercase L)


2. Display the processes that are currently owned by root by entering:
D al

ps -lu root
n

Task 3: Manage Linux Jobs


er

1. In the terminal window, start the System Monitor program by entering:


o
t

gnome-system-monitor
In

Notice that the terminal is not available to receive new commands because no
command line is displayed. This is because the System Monitor program is running in
SE

the foreground
2. Arrange the System Monitor window and the terminal window so that you can see
SU

them both; then select the terminal window to activate it


3. Suspend the System Monitor program by pressing:
Ctrl+Z
4. Try using the System Monitor tool display processes
Because its process was suspended, the tool does not respond
5. View the job in the background by entering:
jobs

69
SUSE Linux Enterprise Server Administration
You should see that the gnome-system-monitor job is stopped
6. View the gnome-system-monitor process running from the current terminal by
entering:
ps -l
The process shows a status of T, which indicates that it is being traced or stopped
7. Resume the System Monitor program running in the background by entering:

y
bg 1

nl
Notice that the System Monitor program is running again. Because it’s running in the
background, you can now use the terminal window to enter other commands

O
8. Verify that the job status is running by entering:

e
jobs

te Us
You should see that the gnome-system-monitor job is now running
9. View the System Monitor branch in the process tree by entering

bu r
pstree -p | grep -C 5 gnome-system-mo

tri ne
(-C 5 displays 5 lines above and 5 lines below the line that matches)
is rt
Notice that the gnome-system-monitor process is listed at the end of the tree,
effectively because it was run from your terminal, not from the Activities menu.
D Pa
10. Bring the gnome-system-monitor process into the foreground by entering:
fg 1
ot d

11. Close the System Monitor program by pressing:


N an

Ctrl-c
D al

Task 4: Start Processes that Ignore HANGUP


n
er

1. Start the System Monitor in the background by entering:


o

nohup gnome-system-monitor &


t
In

The nohup command buffers or wraps a command in such a way that it ignores any
HANGUP kill signals sent to it.
SE

2. Close the terminal window.


SU

3. In the warning dialog, click Close Terminal


The System Monitor program remains running
4. Open a new terminal window and as user tux start the top program by entering:
top
5. View only the processes started by root by typing:
u
then entering:

70
SUSE Linux Enterprise Server Administration
root
6. Check for the System Monitor program (gnome-system-monitor) listed in top
(Conditional) If you cannot find the gnome-system-monitor process, try maximizing
the terminal window. You can also activate the System Monitor window and switch
between the Processes, Resources and File Systems lists. This should cause the
gnome-system-monitor process to be moved near the top of the output in top
7. You can also enter F in top and select PID as the sort column. If needed, you can also

y
reverse the sort order by pressing R

nl
8. Record the PID of the gnome-system-monitor process:
9. ______________

O
10. Exit top by typing:

e
q

te Us
11. View information about the gnome-system-monitor process by entering:
ps <PID_OF_SYSTEM-MONITOR_PROCESS>

bu r
Task 5: Terminate Linux Processes

tri ne
1. Switch to your root user account by typing:
su – is rt
D Pa
When prompted, enter linux for the root user’s password.
2. Stop the System Monitor program and check the status by entering the following
commands:
ot d

kill <PID_OF_SYSTEM-MONITOR_PROCESS>
N an

ps aux | grep gnome-system-monitor


3. Start the xeyes program in the background by entering:
D al

xeyes &
n

4. Start a second xeyes program in the background by entering:


er

xeyes &
o
t

5. Kill all xeyes programs by entering:


In

killall xeyes
6. Close your terminal with:
SE

exit
SU

Summary:
In this exercise you practiced starting and stopping processes.

(End of Exercise)

71
SUSE Linux Enterprise Server Administration

7- 3 Use the screen Command

Description:

y
In this exercise you use the screen command to launch processes in new pseudo

nl
terminals and then detach from and reattach to these pseudo terminals.

O
e
Task 1: Open a terminal session

te Us
1. On server1, as the tux user, open a terminal by clicking on the Activities menu and
type:

bu r
terminal

tri ne
When the Terminal icon appears, click on it to start a terminal session.
is rt
Task 2: Use the screen Command
D Pa
1. To log in server2 via SSH enter:
ssh 172.16.2.22
ot d

Conditional: If prompted, enter the password for the key:


N an

[sles15]
2. Enter the following command to launch a new screen session:
D al

screen
n

3. Press Enter to close the welcome screen and to see a command prompt
er

4. Enter the following command to launch the top process in the screen session:
o
t

top
In

5. You should see the top command running


SE

6. Enter the following keystrokes to detach from the screen sessions:


Ctrl+A, Ctrl+D
SU

You should the message that you’ve detached from the screen session
7. Enter the following command to view the list of currently running screen sessions:
screen -list
You should see only one screen session running. Its name is <PID>.<session_name>,
where <PID> is the process ID and <session_name> is the name of the pseudo
terminal and host name.
8. Enter the following command to reattach to the running screen session:
screen -r

72
SUSE Linux Enterprise Server Administration
You should be reattached to the screen session and should see the top command still
running
9. Detach from the screen session again (Ctrl+A, Ctrl+D), and log out of server2 by
entering:
exit
10. To log back into server2 again, enter:
ssh 172.16.2.22

y
nl
11. Open a terminal window and list the running screen session:

O
screen -list
You should see the screen sessions is still running

e
12. Enter the following command to launch a new command in a new screen session, give

te Us
the screen session a descriptive name and then immediately detach from the screen
session:
screen -S VIM -d -m vim

bu r
tri ne
13. List the currently running screen sessions again:
screen -list
is rt
D Pa
You should see two screen sessions running with the new one having the descriptive
name of VIM rather than the pseudo terminal number and host name
14. Enter the following command to reattach to the top screen session:
ot d

screen -r <PID>.<sessions_name>
N an

(Where the <PID> is the process ID and <session_name> is the pseudo terminal
number and host name) You may also just use the <PID> number to re-attach.
D al

You should be reattached to the top screen session


15. Terminate the top process by pressing:
n
er

q
o

You should see that the process is no longer running


t
In

16. List the current screen sessions again:


screen -list
SE

You should see that you are still attached to the top screen session
17. Enter the following command to terminate the screen session you are attached to:
SU

exit
18. List the screen sessions again:
screen -list
You should see that the screen session you were previously attached to is gone
19. Reattach to the other screen session:
screen -r

73
SUSE Linux Enterprise Server Administration
20. Terminate the VIM session by pressing:
:q!
You should see the command terminating and the screen session terminating as well
Note: Terminating a command that was launched in a detached screen session
terminates the screen session at the same time.
21. List the current running screen sessions again:

y
screen -list

nl
You should see that there are no screen sessions running

O
22. To log out of server2, enter:
exit

e
te Us
Ensure that you are now back on server1.

bu r
tri ne
Summary:
is rt
In this exercise you used the screen command to launch processes in new pseudo
D Pa
terminals and then detached from and reattached to these pseudo terminals.
ot d

(End of Exercise)
N an
D aln
er
o
t
In
SE
SU

74
SUSE Linux Enterprise Server Administration

7- 4 Schedule Jobs with cron

Description:

y
In this exercise you will schedule jobs using the cron management commands and

nl
daemon.

O
e
Task 1: Open a terminal session

te Us
1. On server2, as the tux user, open a terminal by clicking on the Activities menu and
type:

bu r
terminal

tri ne
When the Terminal icon appears, click on it to start a terminal session.
2. Enter the following command to become the root user:
is rt
su -
D Pa
When prompted, enter linux for the root user’s password.
ot d

Task 2: Schedule Jobs with cron


N an

1. At the shell prompt make sure you are logged in as tux, not root
2. Schedule a cron job as tux by entering the following at the shell prompt:
D al

crontab -e
n
er

The vi editor is displayed with tux’s crontab file loaded


o

3. Press the Insert key to enter insert mode


t
In

4. To schedule finger to run every minute and write the output to the ~/users.log file by
enter the following:
SE

* * * * * id >> ~/users.log
and press:
Esc
SU

5. To save the file and exit the vi editor by enter:


:wq
6. Watch the users.log file for a few minutes and validate that it is being updated by
entering the following at the shell prompt:
tail -F ~/users.log
The -F option is a shortcut for -f --retry that keeps trying to open a file even if it is
inaccessible when tail starts

75
SUSE Linux Enterprise Server Administration
7. When finished, press:
Ctrl+C
to break out of tail
8. Remove tux’s crontab file by entering the following at the shell prompt:
crontab -r
9. Verify that the crontab file no longer exists by entering the following at the shell prompt:

y
crontab -l

nl
10. Verify that the cron job you defined in Step 2 is no longer active by entering the

O
following at the shell prompt:
tail -f ~/users.log

e
te Us
Notice that entries to users.log are no longer being added
11. Press:
Ctrl+C

bu r
tri ne
Task 3: Schedule a cron Job as root
1. At the shell prompt, enter:
is rt
D Pa
su -
followed by a password of linux
2. Enter:
ot d
N an

crontab -e
3. Press the Insert key.
4. Add a job that runs at 2:00 a.m. every Tuesday and creates a tarball of /etc that is
D al

saved in /tmp by entering the following:


n

0 2 * * 2 tar czvf /tmp/etc.tgz /etc


er

5. Press:
o
t
In

Esc
6. To save the file and exit the vi editor by enter:
SE

:wq
7. Verify that the job is in the crontab file for root by entering the following at the shell
SU

prompt:
crontab -l
8. Remove root’s crontab file by entering the following at the shell prompt:
crontab -r
9. Verify that the crontab file no longer exists by entering the following at the shell prompt:
crontab -l
10. Close all open windows

76
SUSE Linux Enterprise Server Administration

Summary:
In this exercise you scheduled jobs using the cron management commands and
daemon.

y
nl
(End of Exercise)

O
e
te Us
bu r
tri ne
is rt
D Pa
ot d
N an
D aln
er
o
t
In
SE
SU

77
SUSE Linux Enterprise Server Administration

8 Identity and Security

Description:

y
nl
In this section you will manage users and groups. You will also manage permissions and

O
access control lists. You will then configure user privileges.

e
te Us
bu r
tri ne
is rt
D Pa
ot d
N an
D aln
er
o
t
In
SE
SU

78
SUSE Linux Enterprise Server Administration

8- 1 Manage Users with YaST

Description:
In this exercise you will use YaST to create and delete user accounts.

y
nl
O
Task 1: Start YaST

e
1. Make sure you are logged in to server1 as tux

te Us
2. Launch YaST by clicking on the Activities menu and type:
YaST

bu r
3. When the YaST icon appears, click on it to start YaST

tri ne
4. Enter the root user’s password when prompted.
is rt
D Pa
Task 2: Create a New User Account with YaST
1. Scroll down to the Security and Users section and select User and Group
Management
ot d

The interface will initialize briefly.


N an

2. On the Users tab, add a new user by selecting Add


3. Enter the following information:
D al

User’s Full Name: Emperor Penguin


n

Username: emperor
er

Password: linux
Confirm Password: linux
o
t
In

When you finish, click OK.


4. Confirm the password warning by clicking Yes
SE

5. Save the new settings by clicking OK


6. Close the YaST Control Center window
SU

Task 3: Log in as the New User


1. Close any open windows and log out as the user tux:
Click on the Power icon at the top right hand end of the Activities bar, select tux →
Logout → Logout
2. Log in as user Emperor Penguin with password linux
3. (Conditional) Close or cancel any displayed dialogs

79
SUSE Linux Enterprise Server Administration
Task 4: View the /etc/passwd File
1. Start the File Browser by clicking on the Activities menu and then click on the light-
blue filing cabinet icon on the Favorites strip on the left margin
The content of the user’s home directory are displayed
2. Browse the File System to the /home directory:
Other Locations --> Computer --> home
Notice there are directories for users emperor and tux

y
3. Browse the File System to the /etc directory:

nl
Other Locations --> Computer --> etc

O
4. Open the passwd file by double-clicking it
Notice the entries for users emperor and tux at the end of the file

e
5. Close all windows

te Us
6. Sign out as the user emperor

bu r
tri ne
Task 5: Remove the New User Account
1. Log in as Tux Penguin
is rt
2. Launch YaST by clicking on the Activities menu and type:
D Pa
YaST
3. When the YaST icon appears, click on it to start YaST
ot d

4. Enter the root user’s password when prompted.


N an

linux
5. Select Security and Users section select User and Group Management
D al

The interface will initialize briefly.


n

6. From the list of users, select emperor then click Delete


er

7. Select Delete Home Directory /home/emperor, click Yes and then OK


o
t

8. Close the YaST Control Center window


In

Task 6: Remove and Confirm the Removal of the New User Account
SE

1. Start the File Browser by clicking on the Activities menu and then click on the light-
blue filing cabinet icon on the Favorites strip on the left margin
SU

The content of the user’s home directory are displayed


2. Browse the File System to the /home directory:
Other Locations --> Computer --> home
Notice there is only a directory for the user tux
3. Browse to the /etc directory and open the passwd file
Note that the entry for emperor has been removed from the end of the file
4. Close all open windows

80
SUSE Linux Enterprise Server Administration

Summary:
In this exercise you used YaST to create and delete user accounts.

(End of Exercise)

y
nl
O
e
te Us
bu r
tri ne
is rt
D Pa
ot d
N an
D aln
er
o
t
In
SE
SU

81
SUSE Linux Enterprise Server Administration

8- 2 Manage Users and Groups from the Command Line

Description:

y
In this exercise you add, modify and remove local users and groups using the

nl
command line utilities.

O
e
Task 1: Open a terminal session

te Us
1. On server2, as the tux user, open a terminal by clicking on the Activities menu and
type:

bu r
terminal

tri ne
When the Terminal icon appears, click on it to start a terminal session.
2. Enter the following command to become the root user:
is rt
su -
D Pa
When prompted, enter linux for the root user’s password.
ot d

Task 2: Create a Local User Account from the Command Line


N an

1. Enter the following command to create a new local user:


D al

useradd -m -c "Emperor Penguin" emperor


n

2. Enter the following command to verify that the user was created:
er

getent passwd | grep emperor


o

You should see the new emperor user listed (getent is a command to get entries from
t
In

an administrative database, such as the user database).


3. Enter the following command to verify that the emperor user's home directory was
SE

created:
ls -l /home
SU

You should see the emperor user's home directory listed.


4. Enter the following command to view the emperor user entry in the /etc/passwd file:
grep emperor /etc/passwd
You should see the emperor user line listed.
5. Enter the following command to view the emperor user entry in the /etc/shadow file:
grep emperor /etc/shadow
You should see the emperor user line listed. You should also see that the password

82
SUSE Linux Enterprise Server Administration
field contains a “!”, indicating that no password is set for the emperor user.
6. Enter the following command to set the password for the emperor user:
passwd emperor
and enter and confirm the password of linux (ignore any warnings).
7. Look at the emperor entry in the /etc/shadow file again:
grep emperor /etc/shadow

y
You should see the encrypted password in the emperor user line now.

nl
O
Task 3: Create and Add Users to a New Local Group

e
1. Enter the following command create a new local group:

te Us
groupadd admins
2. Enter the following command to verify that the group was created:

bu r
getent group

tri ne
You should see the new admins group listed.
3. Enter the following command to view the admins group line of the /etc/group file:
is rt
D Pa
grep admins /etc/group
Notice that there are currently no members of the group admins.
4. Enter the following command to add the emperor user to the admins group:
ot d
N an

usermod -a -G admins emperor


Important: If you don't use option -a the previous members of the group are removed
from the group.
D al

5. Look at the admins group line of the /etc/group file again:


n

grep admins /etc/group


er

You should see that the emperor user is now a member of the admins group
o
t
In

Task 4: Create a New User Account with a Valid Password Automatically


SE

1. This is a challenge task. You are not given the step-by-step instructions to perform the
task. Rather you must use knowledge previously gained to successfully complete the
task.
SU

There are some methods available that can be used to create a user account and set a
valid password for the account without being prompted to enter the password
interactively. These methods can be used in scripting to automate the user account
creation or maintenance process.
Your task is to discover how to create a user account and set its password to a valid
password without being prompted to enter a password.

83
SUSE Linux Enterprise Server Administration
Summary:
In this exercise you added, modified and removed local users and groups using
command line commands.

(End of Exercise)

y
nl
O
e
te Us
bu r
tri ne
is rt
D Pa
ot d
N an
D aln
er
o
t
In
SE
SU

84
SUSE Linux Enterprise Server Administration

8- 3 Manage File Permissions

Description:

y
In this exercise, you will manage different file permissions.

nl
O
Task 1: Open a terminal session

e
1. On server1, as the tux user, open a terminal by clicking on the Activities menu and

te Us
type:
terminal

bu r
When the Terminal icon appears, click on it to start a terminal session.

tri ne
2. Enter the following command to become the root user:
su -
is rt
When prompted, enter linux for the root user’s password.
D Pa
Task 2: Create a Private and a Public Directory
ot d
N an

1. On server1 as the root user, create the /files directory by entering:


mkdir /files
D al

2. Change to the /files/ directory by entering:


n

cd /files
er

3. To create the private and public subdirectories under /files/, enter:


o
t

mkdir private public


In

4. Change the permissions on the private directory so that only root has read, write,
and execute permissions by entering:
SE

chmod 700 private


SU

5. Change permissions on the public directory so that everyone has rights to the
directory by entering:
chmod 777 public
6. Verify the changes by entering:
ls -l
7. Return to the tux user account by entering:
exit

85
SUSE Linux Enterprise Server Administration

Task 3: Create a File as a Normal User in both Directories


1. In a terminal window as the tux user, change to the /files/ directory by entering:
cd /files
2. Try to create a file named tuxfile in the private directory by entering:
touch private/tuxfile

y
nl
and you receive the message Permission is denied
3. Try to create a file named tuxfile in the public directory by entering:

O
touch public/tuxfile

e
4. Verify that the file is created by entering:

te Us
ls public
5. Change to the public directory by entering:

bu r
tri ne
cd public
6. List the permissions of the tuxfile file by entering:
ls -l tuxfile is rt
D Pa
Notice that members of the users group and others have only read permission for the
file
ot d

7. Change permissions so that members of the users group have write permissions and
others do not have any permissions by entering the following:
N an

chmod g+w,o-r tuxfile


8. Verify the change by entering:
D al

ls -l
n
er

You should see that the SGID has been added to the 2nd trio of permissions and read
access has been remove from the Other trio of permissions.
o
t

9. Close the terminal window


In
SE

Summary:
SU

In this exercise you managed different file permissions and ownership.

(End of Exercise)

86
SUSE Linux Enterprise Server Administration

8- 4 Configure Posix ACLs

Description:

y
In this exercise, you will practice viewing, setting, querying and removing permissions

nl
using ACLs.

O
e
Task 1: Open a terminal session

te Us
1. On server2, as the tux user, open a terminal by clicking on the Activities menu and
type:

bu r
terminal

tri ne
When the Terminal icon appears, click on it to start a terminal session.
2. Enter the following command to become the root user:
is rt
su -
D Pa
When prompted, enter linux for the root user’s password.
ot d

Task 2: Configure the ACLs of a Directory


N an

1. As the root user, change to the directory /tmp/:


D al

cd /tmp
n

2. Create a acl_test directory and set the permissions to rwx for the owner (700):
er

mkdir -m 700 acl_test


o

3. Open a second terminal window as the tux user


t

4. Try changing to the acl_test directory:


In

cd /tmp/acl_test/
SE

The command fails because tux (who is not the owner of the directory) has no
permission to read and change into the directory.
5. Switch to the root terminal session. Display the minimum ACL of the directory:
SU

getfacl /tmp/acl_test
It should should show the rwx permissions for the owning user and no permission for
anyone else.
6. Add an extended ACL:
setfacl -m u:tux:rwx /tmp/acl_test
7. Switch to the tux terminal and try to access the directory again by entering:
cd /tmp/acl_test
Because of the extended ACL, you can now change into the directory.

87
SUSE Linux Enterprise Server Administration
8. Switch to the root terminal and display the extended ACL of the directory:
getfacl /tmp/acl_test/
It should show the additional permissions for the named user tux
9. View the regular permissions of the /tmp/acl_test/ directory:
ls -ld /tmp/acl_test
The + sign signifies that ACLs are set for this file. Note the group permissions – when
there is a + sign, the group permissions no longer reflect the permissions of the owning

y
group but the setting of the ACL mask.

nl
O
Task 3: Configure Default ACLs for a Directory
1. In the root terminal window, change to the directory acl_test:

e
cd /tmp/acl_test

te Us
2. Create a file:
touch without_default_acl
3. Display the ACL of the new file:

bu r
tri ne
getfacl without_default_acl
Because there is no default ACL for the parent directory, the new file does not have an
extended ACL either. is rt
D Pa
4. Set a default ACL for the acl_test directory:
setfacl -d -m u:tux:rwx /tmp/acl_test/
5. View the ACLs of /tmp/acl_test/:
ot d

getfacl /tmp/acl_test/
N an

6. Create another test file:


touch with_default_acl
D al

7. Display the ACL of the new file:


getfacl with_default_acl
n

Because this file was created after the default ACL of the parent directory was set, the
er

new file inherited the ACL. It has an entry for the named user tux.
o
t

8. Create a directory within /tmp/acl_test/:


In

mkdir subdirectory
9. Display the ACL of the new directory:
SE

getfacl subdirectory
Because this directory was created after the default ACL of the parent directory was set,
SU

the new directory inherited the default ACL as its ACLs and also the same default ACLs
that were set on the parent directory.
Task 4: Delete ACLs
1. In the root terminal window, remove the ACL:
setfacl -x u:tux with_default_acl
2. Display the ACL again:
getfacl with_default_acl
The ACL for the user tux has been removed. If there were ACLs for other users, they

88
SUSE Linux Enterprise Server Administration
would remain unaffected
3. Repeat the same for subdirectory:
setfacl -x u:tux subdirectory
getfacl subdirectory
The ACL for the user tux has been removed. The default ACLs remained unaffected
4. View the file attributes of with_default_acl:
ls -l with_default_acl

y
The + sign signifies that there are still extended attributes (such as the mask) set for the

nl
file
5. Remove all ACLs by entering:

O
setfacl -b with_default_acl

e
6. Display the ACL again by entering the following commands:

te Us
getfacl with_default_acl
ls -l with_default_acl
Notice that the ACL has been removed

bu r
7. Close all terminal windows

tri ne
is rt
D Pa
Summary:
In this exercise, you will have practiced viewing, setting, querying and removing
permissions using ACLs.
ot d
N an

(End of Exercise)
D aln
er
o
t
In
SE
SU

89
SUSE Linux Enterprise Server Administration

8- 5 Use the su Command to Elevate Privileges

Description:

y
In this exercise, you use the su command to gain root permissions at the command

nl
line.

O
e
Task 1: Open a terminal session

te Us
1. On server2, as the tux user, open a terminal by clicking on the Activities menu and
type:

bu r
terminal

tri ne
When the Terminal icon appears, click on it to start a terminal session.
is rt
D Pa
Task 2: Use the su Command
1. In a terminal window as the tux user, type:
ot d

/sbin/yast
N an

YaST will start up in ncurses (text) mode


2. In the warning dialog press:
D al

Enter
n

You should see that YaST has only a limited set of modules available.
er

3. Quit YaST by pressing:


o
t

ALT + q
In

4. In the same terminal session, as the tux user, switch to root by entering:
SE

su -
And when prompted enter the root user’s password linux.
SU

5. Check to make sure you are logged in as root by entering:


id
6. Start YaST by entering:
yast
7. You should see YaST running in ncurses mode with all modules available
8. Quit YaST by pressing:

90
SUSE Linux Enterprise Server Administration
ALT + q
9. Become the user tux again by entering:
exit
10. Exit the tux user terminal session by typing:
exit

y
Summary:

nl
In this exercise, you used the su command to gain root permissions at the command

O
line.

e
te Us
(End of Exercise)

bu r
tri ne
is rt
D Pa
ot d
N an
D aln
er
o
t
In
SE
SU

91
SUSE Linux Enterprise Server Administration

8- 6 Configure sudo for Delegation of Administration

Description:

y
In this exercise you configure sudo to delegate administrative privileges to a non-root

nl
user.

O
e
Task 1: Open a terminal session

te Us
1. On server1, as the tux user, open a terminal by clicking on the Activities menu and
type:

bu r
terminal

tri ne
When the Terminal icon appears, click on it to start a terminal session.
2. Enter the following command to become the root user:
is rt
su -
D Pa
When prompted, enter linux for the root user’s password.
ot d

Task 2: Open a terminal session


N an

1. At the shell prompt enter:


visudo
D al

This opens the /etc/sudoers file in the VIM editor


n

2. Scroll down to the line that starts with:


er

Defaults targetpw.
o
t

3. Comment out the following lines by placing a # at the beginning of the following two
In

lines:
#Defaults targetpw # ask for the password of the ...
SE

#ALL ALL=(ALL) ALL # WARNING! Only use this together ...


SU

Task 3: Define sudo Aliases


1. Still in /etc/sudoers define a User_Alias named POWERUSERS that contains the
tux user account by adding the following line to the end of the file:
User_Alias POWERUSERS = tux
2. Define a Cmnd_Alias named KPROCS that contains the kill and killall commands by
adding the following line to the end of the file:
Cmnd_Alias KPROCS = /bin/kill, /usr/bin/killall

92
SUSE Linux Enterprise Server Administration
3. Define a Host_Alias named HOSTS that contains the server1 host by adding the
following line to the end of the file:
Host_Alias HOSTS = server1
4. Using the aliases defined above, allow the tux user to run the specified commands on
server1 as root by adding the following line to the end of the file:
POWERUSERS HOSTS = (root) KPROCS

y
5. To save your changes and close the text editor press:

nl
Esc
6. Then enter:

O
:wq

e
te Us
Task 4: Test the sudo Aliases
1. At the shell prompt (as root), enter:

bu r
top

tri ne
The top process will start and display.
is rt
2. Open a new terminal window as the tux user
D Pa
3. At the shell prompt in the new terminal window, type:
sudo killall top
and when prompted, enter the tux user’s password.
ot d

You should see that top is unloaded in the first terminal window.
N an

4. Close all open windows on the desktop


D al

Task 5: Grant the Tux User the Ability to Change Users Passwords
n

1. This is a challenge task. You are not given the step-by-step instructions to perform the
er

task. Rather you must use knowledge previously gained to successfully complete the
o
t

task.
In

Use the knowledge and skills you have learned in the previous tasks to grant the tux
SE

user the ability to change other users' passwords. tux should be able to change the
password of any user but the root user without having to know their previous password.
SU

There is an example in the sudo man page.

Summary:
In this exercise you configured sudo to delegate administrative privileges to a non-root
user.

93
SUSE Linux Enterprise Server Administration
(End of Exercise)

y
nl
O
e
te Us
bu r
tri ne
is rt
D Pa
ot d
N an
D aln
er
o
t
In
SE
SU

94
SUSE Linux Enterprise Server Administration

8- 7 Grant Administrative Privilege with PolicyKit

Description:

y
In this exercise you use PolicyKit to grant the ability to change the system time to a

nl
non-root user.

O
e
Task 1: Open a terminal session

te Us
1. On server2, as the tux user, open a terminal by clicking on the Activities menu and
type:

bu r
terminal

tri ne
When the Terminal icon appears, click on it to start a terminal session.
is rt
D Pa
Task 2: Try to Use the GNOME Date & Time Tool
1. Launch Settings by clicking on the Activities menu and type:
ot d

settings
N an

When the Settings (screwdriver and wrench) icon appears, click on it to launch
Settings.
2. To open the Date & Time tool, select:
D al

Details --> Date & Time


n

Note most of the buttons are not active


er

3. In the Date and Time window, on the top right, click:


o
t
In

Unlock
You should be presented with an Authenticate window prompting you for the root
SE

password.
4. To close the Authenticate window, click
SU

Cancel
5. Close the Date & Time window

Task 3: Grant the Privilege to Use GNOME Date & Time Tool
1. On server2, as the tux user, open a terminal by clicking on the Activities menu and
type:
terminal

95
SUSE Linux Enterprise Server Administration
When the Terminal icon appears, click on it to start a terminal session.
2. Enter the following command to become the root user:
su -
When prompted, enter linux for the root user’s password.
3. To view the default PolKit settings for the GNOME Date & Time Tool enter the following
command:

y
less /etc/polkit-1/rules.d/90-default-privs.rules

nl
4. Search for:

O
org.gnome.controlcenter.datetime.configure
The privileges should be auth_admin_keep three times

e
5. To change the default settings do the following:

te Us
6. Open the file /etc/polkit-default-privs.local with an editor of your choice
7. Add the following at the end of the file:

bu r
org.gnome.controlcenter.datetime.configure yes

tri ne
8. Save your changes and exit the editor
is rt
9. As root execute the following command:
D Pa
set_polkit_default_privs
10. To view your changes run the following command:
ot d

less /etc/polkit-1/rules.d/90-default-privs.rules
N an

11. Search for:


org.gnome.controlcenter.datetime.configure
D al

The privileges should be listed as:


n

'org.gnome.controlcenter.datetime.configure':
er

[ 'yes', 'yes', 'yes' ],


o

12. To test your changes, do the following:


t
In

13. Launch Settings by clicking on the Activities menu and type:


settings
SE

When the Settings (screwdriver and wrench) icon appears, click on it to launch
Settings.
SU

Most of the buttons are active now, and there is no Unlock button in the top right corner
14. Close the Date & Time window

Task 4: Execute a Command as Another User


1. Make sure you are logged in on server2 and are in a terminal window as user tux
2. To try to start YaST, enter:
/sbin/yast

96
SUSE Linux Enterprise Server Administration
A warning should appear, that you need root privileges.
3. Proceed by clicking:
OK
4. Notice that the YaST dialog lists only a few modules.
5. Press:
Alt+Q

y
to quit YaST.

nl
6. Now start YaST as the root user:

O
pkexec /sbin/yast

e
When prompted to enter the root password, enter:

te Us
linux
YaST starts normally and all YaST modules are available.

bu r
tri ne
7. To quit YaST press:
Alt+Q
is rt
D Pa
Summary:
ot d

In this exercise you used PolicyKit to grant the ability to change the system time to a
N an

non-root user.
D al

(End of Exercise)
n
er
o
t
In
SE
SU

97
SUSE Linux Enterprise Server Administration

9 Software Management

Description:

y
nl
You will manage software using rpm, zypper and zypper repositories.

O
e
te Us
bu r
tri ne
is rt
D Pa
ot d
N an
D aln
er
o
t
In
SE
SU

98
SUSE Linux Enterprise Server Administration

9- 1 Manage Software with RPM

Description:
In this exercise, you practice gathering information on installed software and installing

y
nl
software packages.

O
Task 1: Open a terminal session as root

e
te Us
1. On server1, as the tux user, open a terminal by clicking on the Activities menu and
type:
terminal

bu r
tri ne
When the Terminal icon appears, click on it to start a terminal session.
2. Enter the following command to become the root user:
su -
is rt
D Pa
When prompted, enter linux for the root user’s password.
ot d
N an

Task 2: Get Information on Software Packages


1. As the root user, to find out information on the wget package enter:
D al

rpm -qf /usr/bin/wget


n

Notice that the wget package installed the wget file.


er

2. To find out information about the wget package enter:


o

rpm -qi wget


t
In

3. To show all the files installed by the wget package enter:


SE

rpm -ql wget


Where can you find more detailed information on the wget package? (Notice the
location of the README files)
SU

Notice that the information includes the install date and a description

Task 3: Verify Changes to Software Packages


1. To see what has changed in the files on your hard drive since the wget RPM was
originally installed enter:
rpm -V wget
If there is no output then no files were changed.

99
SUSE Linux Enterprise Server Administration
2. Enter the following:
vi /etc/wgetrc
3. Using the Arrow keys, move the cursor to the first line and the first space after the three
comment marks (###)
To enter new content in vi, press a and type the following:
This is a test.

y
4. To exit vi press:

nl
Esc

O
and type:
:wq

e
te Us
You are returned to the command prompt.
5. To see what has changed in the files contained in the wget package on your hard drive
since the wget RPM was originally installed enter:

bu r
tri ne
rpm -V wget
6. The following is displayed:
S.5....T c /etc/wgetrcis rt
D Pa
7. To view the documentation files for the wget program enter:
rpm -qd wget
ot d

Notice that some of the files are still compressed (*.gz)


N an

Task 4: Install Software with RPM BETA FIX


D al

1. Check to see if a given package is yet installed:


n

rpm -q gvim
er
o

You should see the following output:


t
In

package gvim is not installed


2. Switch to the root user with su -, then execute the following to copy an rpm locally for
SE

inspection:
zypper in -d gvim
SU

3. To list all files included in the not-yet-installed gvim package enter:


rpm -qpl \
/var/cache/zypp/packages/Desktop-Applications-Module_15-0/Module-
Desktop-Applications/x86-64/gvim-8.0.1568-3.20.x86_64.rpm
4. Feel free to use the Tab key to autocomplete
5. To install the gvim package enter:
rpm -ihv \
/var/cache/zypp/packages/Desktop-Applications-Module_15-0/Module-

100
SUSE Linux Enterprise Server Administration
Desktop-Applications/x86-64/gvim-8.0.1568-3.20.x86_64.rpm
6. To test the installation of the software package enter:
gvim
A graphical instance of gvim will open on screen.
7. Close the VIM window

y
Task 5: Remove Software with RPM

nl
1. To list all files included in the installed gvim package enter:

O
rpm -ql gvim

e
2. To remove the gvim package enter:

te Us
rpm -e gvim
3. To verify that the package is no longer installed enter:

bu r
rpm -ql gvim

tri ne
4. Close the terminal window by entering exit and log out as root
is rt
D Pa
Summary:
ot d

In this exercise, you practiced gathering information on installed software, installing


N an

and removing software packages.


D al

(End of Exercise)
n
er
o
t
In
SE
SU

101
SUSE Linux Enterprise Server Administration

9- 2 Install Software with zypper

Description:

y
In this lab you will install and remove software packages using the zypper command

nl
line tool.

O
e
Task 1: Open a terminal session

te Us
1. On server1, as the tux user, open a terminal by clicking on the Activities menu and
type:

bu r
terminal

tri ne
When the Terminal icon appears, click on it to start a terminal session.
is rt
D Pa
Task 2: Install a Software Package with zypper
1. As the root user, list the available repositories:
ot d

zypper lr
N an

Note the number of the repository is 1 (one).


2. Selectively refresh the metadata for the installation source by entering the following
D al

command:
n

zypper ref 1
er

3. To search for a single package in the active Installation Sources enter the following
o

command:
t
In

zypper se gv
SE

4. Packages that contain the string gv in their name are listed


5. To install a package enter the following command:
SU

zypper in gvim
Answer n when prompted to cancel or stop the installation
6. To install the package, enter:
zypper --non-interactive in gvim
This time you are not prompted, this is a useful option to use in scripts
7. Test the software by entering gvim at the command prompt
8. Exit the gvim application using the close control on the window or with the keystrokes:

102
SUSE Linux Enterprise Server Administration
:q
Task 3: Removing a Package with Zypper
1. To remove a package enter the following command:
zypper rm gvim
Answer y when prompted to approve the removal. The –non-interactive option can be
used when removing packages

y
nl
Task 4: Use zypper to Install a Pattern

O
1. This is a challenge task. You are not given the step-by-step instructions to perform the
task. Rather you must use knowledge previously gained to successfully complete the

e
task.

te Us
zypper has the ability to install entire patterns as well as single packages. Your task is
to install the Mail and News Server pattern using the zypper command.

bu r
tri ne
Summary:
is rt
D Pa
In this lab you installed and removed software packages using the zypper command
line tool.
ot d
N an

(End of Exercise)
D aln
er
o
t
In
SE
SU

103
SUSE Linux Enterprise Server Administration

9- 3 Manage Software Sources with zypper

Description:

y
In this exercise, you add, remove, and rename software installation sources using the

nl
zypper command.

O
e
Task 1: Open a terminal session

te Us
1. On server1, as the tux user, open a terminal by clicking on the Activities menu and
type:

bu r
terminal

tri ne
When the Terminal icon appears, click on it to start a terminal session.
2. Enter the following command to become the root user:
is rt
su -
D Pa
When prompted, enter linux for the root user’s password.
ot d

Task 2: Add an Installation source with zypper


N an

1. As the root user on server1 list your existing installation sources by entering the
following command:
D al

zypper lr
n

2. Execute the lsblk command to determine which block device is connected to the SLE
er

12 SP2 iso:
o
t

lsblk
In

The device that shows a size of 3.1 G is the one you want. It will likely be either sr0 or
SE

sr1
3. Mount the SLES 12 SP2 iso to the /mnt directory by executing the following command
(if the above command shows it is sr1, use /dev/sr1 below):
SU

mount -o loop /dev/sr0 /mnt


4. Add the new installation source by entering the following command:
zypper ar /mnt sles12-sp2
5. List your installation sources again:
zypper lr
You should see the new installation source

104
SUSE Linux Enterprise Server Administration
6. Make a note of the new repository, it should likely be number 5. Refresh the repository
to get a current list of available software:
zypper ref <repo-number>

Task 3: Install a Software Package from the New Repository


1. Disable the original repository:

y
zypper mr -d SLES15-15-0

nl
2. Check the original repository is disabled:

O
zypper lr

e
3. Now install the package emacs from the new repository:

te Us
zypper install emacs
zypper identifies the dependencies installs all required packages

bu r
If prompted about continuing, enter:

tri ne
y

is rt
Task 4: Rename an Installation Source with zypper
D Pa
1. To rename an installation source enter the following command:
zypper nr sles12-sp2 sles12-sp2-new
ot d
N an

2. List the installation sources again to see the change:


zypper lr
D al

You should see that the alias for the repository has changed
n
er

Task 5: Remove an Installation Source with zypper


o
t

1. To remove the installation source enter the following command:


In

zypper rr sles12-sp2-new
SE

2. List the installation sources again to see the change:


zypper lr
SU

You should no longer see the repository in the list


3. Enable the original repository:
zypper mr -e SLES15-15-0
4. Check the repository has been enabled:
zypper lr

105
SUSE Linux Enterprise Server Administration
Summary:
In this exercise, you added, removed, and renamed software installation sources using
the zypper command.

(End of Exercise)

y
nl
O
e
te Us
bu r
tri ne
is rt
D Pa
ot d
N an
D aln
er
o
t
In
SE
SU

106
SUSE Linux Enterprise Server Administration

9- 4 Manage Software with YaST

Description:

y
In this exercise, you install and remove software with YaST.

nl
O
Task 1: Start YaST

e
1. Make sure you are logged in to server1 as tux

te Us
2. Launch YaST by clicking on the Activities menu and type:
YaST

bu r
tri ne
3. When the YaST icon appears, click on it to start YaST
4. Enter the root user’s password when prompted.
is rt
D Pa
Task 2: Install Software Packages with YaST
1. Once inside the YaST Control Center, launch the YaST Software Management
module:
ot d
N an

Software > Software Management


2. In the search field at the top left, enter:
D al

eog
n

Notice that the icon in front of the eog entry on the right shows an empty box. This
indicates that the package is not yet installed.
er
o

3. From the list on the right select eog


t
In

The icon changes to a green check mark. Any shown dependencies will also be
indicated.
SE

4. Click Accept to install the eog package


Conditional: If prompted, click:
SU

Continue
5. In the Installation dialog, click Finish
6. Close the YaST interface
7. Open a terminal window as tux and enter:
eog
8. Close the eog window and the terminal window

107
SUSE Linux Enterprise Server Administration
Task 3: Remove Software Packages with YaST
1. Make sure you are logged in to server1 as tux
2. Launch YaST by clicking on the Activities menu and type:
YaST
3. When the YaST icon appears, click on it to start YaST
4. Enter the root user’s password when prompted.

y
5. In the YaST Control Center, navigate to:

nl
Software > Software Management

O
6. In the search field at the top left, enter:

e
7. In the search field at the top left, enter eog

te Us
Notice that the icon in front of eog now shows a box already checked. This means that
the package is installed.
8. In the list on the right either click eog twice until a red X appears to the left or right-click

bu r
tri ne
on eog and select Delete from the context menu
Conditional: If prompted to remove dependencies, click the button associated with
is rt
deinstallation and then click:
D Pa
Ok – Try Again
9. Click Accept at the bottom right
ot d

10. In the Installation Report dialog click Finish


N an

11. Close the YaST Control Center window


D al

Summary:
n
er

In this exercise you installed and removed software with YaST.


o
t
In

(End of Exercise)
SE
SU

108
SUSE Linux Enterprise Server Administration

10Network Management

Description:

y
nl
You will learn to configure networking manually and using Wicked. You will then

O
configure firewalld.

e
te Us
bu r
tri ne
is rt
D Pa
ot d
N an
D aln
er
o
t
In
SE
SU

109
SUSE Linux Enterprise Server Administration

10- 1 Configure the Network Connection Manually

Description:
The purpose of this exercise is to familiarize you with manually configuring network

y
nl
settings.

O
Task 1: Open a terminal session

e
te Us
1. On server1, as the tux user, open a terminal by clicking on the Activities menu and
type:
terminal

bu r
tri ne
When the Terminal icon appears, click on it to start a terminal session.
2. Enter the following command to become the root user:
su - is rt
D Pa
When prompted, enter linux for the root user’s password.
ot d

Task 2: Note the Current Network Configuration


N an

1. To test the network connection at the shell prompt enter:


ping 172.16.2.22
D al

You should see that the network connection is working


n

2. To exit ping press:


er
o

Ctrl+C
t
In

3. Enter:
ip address show
SE

4. Under eth0 find the line starting with inet and record the IP address with the subnet
mask displayed in that line:
SU

IP_ADDR: ___________________________
Subnet mask:__________________________
5. Enter:
ip route show
6. Find the line starting with default and record the IP address of the default router:
Router address:__________________________
7. Enter:
ip link show eth0

110
SUSE Linux Enterprise Server Administration
8. Find the line starting with link/ether and record the MAC address of the network card:
MAC address:__________________________

Task 3: Delete the Current Network Setup with YaST


1. Launch YaST by clicking on the Activities menu and type:
YaST

y
nl
When the YaST icon appears, click on it to start YaST
2. Enter the root user’s password when prompted.

O
3. Select Network Settings

e
4. Select eth0 then click Delete

te Us
5. Click OK
6. Close YaST
7. To test the network connection at the shell prompt enter:

bu r
tri ne
ping 172.16.2.22
You should see a message indicating that the network is unreachable
is rt
8. At the shell prompt enter:
D Pa
ip address show
Note that the state of your eth0 device is DOWN
ot d
N an

Task 4: Configure the Network Manually


1. At the shell prompt enter:
D al

ip address add 172.16.2.21/24 brd + dev eth0


n

2. To activate the network device enter:


er
o

ip link set eth0 up


t
In

3. To set the default route enter:


ip route add default via 172.16.2.22
SE

4. Verify that the network connection is working again by entering:


ping 172.16.2.22
SU

Summary:
In this exercise you have manually configured your network using command line tools.

(End of Exercise)

111
SUSE Linux Enterprise Server Administration

10- 2 Configure Local Name Resolution

Description:

y
In this exercise you configure and test a local host name resolution.

nl
O
To successfully complete this exercise, you must have both server1 and server2 running.

e
Task 1: Open a terminal session

te Us
1. On server2, as the tux user, open a terminal by clicking on the Activities menu and
type:

bu r
terminal

tri ne
When the Terminal icon appears, click on it to start a terminal session.
2. Enter the following command to become the root user:
is rt
su -
D Pa
When prompted, enter linux for the root user’s password.
ot d

Task 2: Configure Local Name Resolution


N an

1. To open /etc/hosts in the vi editor enter:


vi /etc/hosts
D al

2. At the end of the file there should be lines like the following:
n

172.16.2.21 server1.suse.com server1


er

172.16.2.22 server2.suse.com server2


o
t

3. Modify the server2 line as shown below:


In

172.16.2.22 server2.suse.com server2 database


SE

4. Save the file and exit vi


SU

Task 3: Test Name Resolution


1. To test the name resolution for server1 enter:
ping server1

server1 should reply to the ping packets


2. To test the name resolution for server2 enter:
ping server2.suse.com

112
SUSE Linux Enterprise Server Administration
server2 should reply to the ping packets.
3. To test the database alias for server2, enter:
ping database
server2 should reply to the pig packets.

y
nl
Summary:

O
In this exercise you have manually configured your network using command line tools.

e
te Us
(End of Exercise)

bu r
tri ne
is rt
D Pa
ot d
N an
D aln
er
o
t
In
SE
SU

113
SUSE Linux Enterprise Server Administration

10- 3 Save the Network Configuration to a File

Description:

y
In this exercise you save your network configuration to a file.

nl
O
To successfully complete this exercise, you must have both server1 and server2 running.

e
Task 1: Open a terminal session

te Us
1. On server2, as the tux user, open a terminal by clicking on the Activities menu and
type:

bu r
terminal

tri ne
When the Terminal icon appears, click on it to start a terminal session.
2. Enter the following command to become the root user:
is rt
su -
D Pa
When prompted, enter linux for the root user’s password.
ot d

Task 2: Save the Network Configuration to a File


N an

1. In the server2 terminal window enter:


cd /etc/sysconfig/network
D al

2. Make a copy of the network configuration template by entering:


n
er

cp ifcfg.template ifcfg-eth0
o

3. Open the copied file in a text editor by entering:


t
In

vi ifcfg-eth0
4. Find the following options, press the Insert and enter the indicated values:
SE

STARTMODE='auto'
BOOTPROTO='static'
SU

IPADDR='172.16.2.22'
NETMASK=’255.255.255.0’
BROADCAST=’172.16.2.255’
5. Press:
Esc
then save the file and exit vi by entering:
:wq
6. View the /etc/sysconfig/network/routes file with less by entering:
less routes

114
SUSE Linux Enterprise Server Administration
The content should be:
default 172.16.2.1 - -

Task 3: Test the Network Configuration


1. Ensure you are logged in on server2 as tux and if needed, open a terminal window
2. Verify that the network configuration loaded correctly by entering the following

y
commands:

nl
ip address show eth0

O
ip route show

3. Verify that the network connection is working properly by entering:

e
te Us
ping server1
4. Close all open windows
If the network configuration doesn’t work properly, use the YaST Network Settings

bu r
module to reconfigure the network card with the proper settings recorded earlier in the

tri ne
lab.

is rt
D Pa
Summary:
In this exercise you saved your network configuration to a file.
ot d
N an

(End of Exercise)
D aln
er
o
t
In
SE
SU

115
SUSE Linux Enterprise Server Administration

10- 4 Manage Network Configuration with Wicked

Description:

y
In this exercise you manage your network interface using wicked.

nl
O
Task 1: Open a terminal session

e
1. On server2, as the tux user, open a terminal by clicking on the Activities menu and

te Us
type:
terminal

bu r
When the Terminal icon appears, click on it to start a terminal session.

tri ne
2. Enter the following command to become the root user:
su -
is rt
When prompted, enter linux for the root user’s password.
D Pa
Task 2: Manage Network Configuration with Wicked
ot d
N an

1. To display the status of your network interfaces enter:


systemctl status wicked.service
D al

2. To display the status of your network enter:


n

systemctl status wickedd.service


er

3. To display detailed information about your network interfaces, enter


o
t

wicked show all


In

4. To bring down your eth0 interface enter:


SE

wicked ifdown eth0


5. To display detailed information about your network interfaces enter:
SU

wicked show all


You should see only some hardware information for eth0
6. To test the eth0 interface enter:
ping 172.16.2.22
You should see a message, that the network is unreachable
7. To restart your network service enter:
systemctl restart network.service

116
SUSE Linux Enterprise Server Administration
8. To display detailed information about your network interfaces enter:
wicked show all
You should see that an IP address is assigned to eth0 again
9. To test the eth0 interface enter:
ping 172.16.2.22
10. The network should be reachable again

y
nl
O
Summary:

e
In this exercise you managed your network interface using wicked.

te Us
bu r
(End of Exercise)

tri ne
is rt
D Pa
ot d
N an
D aln
er
o
t
In
SE
SU

117
SU
SE
In
ert
D aln
o
N an
ot d

118
D Pa
is rt
tri ne
SUSE Linux Enterprise Server Administration

bu r
te Us
e
O
nl
y
SUSE Linux Enterprise Server Administration

10- 5 Configure a Host Based Firewall with firewalld

Description:
In this exercise you use firewalld to configure a host based firewall.

y
nl
O
Task 1: Open a terminal session

e
1. On server2, as the tux user, open a terminal by clicking on the Activities menu and

te Us
type:
terminal

bu r
When the Terminal icon appears, click on it to start a terminal session.

tri ne
2. Enter the following command to become the root user:
su -
is rt
When prompted, enter linux for the root user’s password.
D Pa
Task 2: Viewing your system’s iptables configuration
ot d
N an

1. On server2 as the root user type:


iptables -L -nv | less
D al

You should see output about your iptables configuration displayed in the less
command’s interface.
n

2. Try searching for output mentioning an external interface with the following search
er

command:
o
t

/external
In

There should be reference to external found


SE

3. Quit the less command interface with the q keystroke


4. Exit the terminal
SU

Task 3: Changing the Zone of an Interface


1. On server2, launch YaST:
Activities > YaST
Enter the root user password when prompted
2. Navigate to:
Security and Users > Firewall

119
SUSE Linux Enterprise Server Administration
3. Select Interfaces on the left, then highlight:
eth0
4. Click on the Change Zone button
5. Choose the zone:
external zone from the drop-down menu

y
Click Ok

nl
This will change the eth0 interface to be mapped to the external zone.

O
Task 4: Set the Allowed Services for an Interface

e
1. From the left pane under Zones, select external

te Us
2. Scroll down the list of Services and select the following:
samba

bu r
vnc-server

tri ne
x11
ssh (may already be added)
is rt
You will need to highlight each of the above services and click the Add → button
D Pa
3. Click Accept
4. Close the YaST Control Center
ot d
N an

Task 5: Confirm your iptables Configuration is active


1. In the server2 terminal as the root user, run the following command:
D al

iptables -L -nv | grep external


n

You should see output that shows your system now has an interface configured to be in
er

the external zone and a number of services that are configured to allow incoming
o

packets via the interface.


t
In

2. Now initiate a reboot of server2


3. When server2 is back online, re-enter the Firewall Configuration module in YaST and
SE

confirm that your previously selected zone and service configurations from Task 2
above are present and active.
SU

Task 6: Confirm your iptables Configuration is permanent


1. In the server2 terminal as the root user, run the following command:
iptables -L -nv | grep external
You should see output that shows your system still has an interface configured to be in
the external zone and a number of services that are configured to allow incoming
packets via the interface.
2. Close all open windows

120
SUSE Linux Enterprise Server Administration

Summary:
In this exercise you used firewalld to configure a host based firewall.

y
(End of Exercise)

nl
O
e
te Us
11 Storage Administration

bu r
tri ne
Description:

is rt
You will learn to partitions disks, create filesystems, You will then configure disks using
D Pa
LVM. You will setup a software RAID. You will use the configure and use the features of
Btrfs. The last topic will cover configuring and using NFS.
ot d
N an
D aln
er
o
t
In
SE
SU

121
SUSE Linux Enterprise Server Administration

11- 1 Manage Partitions with YaST

Description:
In this exercise you create some partitions using YaST.

y
nl
O
Task 1: Start YaST
1. Make sure you are logged in to server1 as tux

e
2. Launch YaST by clicking on the Activities menu and type:

te Us
YaST
3. When the YaST icon appears, click on it to start YaST

bu r
tri ne
4. Enter the root user’s password when prompted.

is rt
Task 2: Manage partitions with YaST
D Pa
1. With YaST running, In the System section click on Partitioner
2. In the warning dialog, click Yes
ot d

3. In the System View panel on the left, click the arrow icon in front of the Hard Disks item
N an

4. You should see four hard disks. We will be focussing on three of them:
sdb
D al

sdc
sdd
n
er

5. Click on the sdc item in the left System View panel. This disk currently has no
partitions on it
o
t

6. To add a new primary partition, do the following:


In

Click the Add button


SE

7. Make sure that Primary Partition is selected, then click Next


8. Make sure that Custom Size is selected and enter 2GiB in the Size text box, then click
Next
SU

9. Make sure that Data and ISV Applications is selected, then click Next
10. Make sure that Format partition is selected and the file system is XFS
11. Select Mount partition and for the Mount Point enter:
/data1
12. Click Finish
13. To add a new extended partition to the same disk, make sure sdc is still select in the
System View and click the Add button

122
SUSE Linux Enterprise Server Administration
14. Select Extended Partition, then click Next
15. Make sure that Maximum Size is selected, then click Finish
16. To add a new logical partition click the Add button
17. Make sure that Custom Size is selected and enter 3GiB in the Size text box, then click
Next
18. Make sure that Data and ISV Applications is selected, then click Next
19. Make sure that Format partition is selected and the file system is XFS

y
20. Select Mount partition and for the Mount Point enter:

nl
/data2

O
21. Click Finish
22. To add a second logical partition, do the following:

e
23. Click the Add button

te Us
24. Select Maximum Size, then click Next
25. Make sure that Data and ISV Applications is selected, then click Next

bu r
26. Make sure that Format partition is selected and the file system is XFS

tri ne
27. Select Mount partition and for the Mount Point enter:
28. /data3 and click Finish
is rt
29. In the Expert Partitioner dialog, click Next
D Pa
30. In the Summary dialog, click Finish
31. Close the YaST dialog
ot d

Task 3: View the new partitions and filesystems


N an

1. On server1, as the tux user, open a terminal by clicking on the Activities menu and
type:
D al

terminal
n

2. When the Terminal icon appears, click on it to start a terminal session.


er

3. To view the mounted filesystems enter:


o
t
In

mount
4. At the bottom of the list the following three mounted files systems are listed:
SE

/dev/sdc1 on /data1
/dev/sdc5 on /data2
SU

/dev/sdc6 on /data3
There can be either a maximum of four primary partitions per disk or three primary
partitions and one extended partition which can contain multiple logical partitions.
5. Change to the root user:
su -
and enter roots password:
linux

123
SUSE Linux Enterprise Server Administration
6. Create a new file on each of the new file systems:
touch /data1/testfile1 /data2/testfile2 /data3/testfile3
7. List the contents of data1, data2 and data3:
ls -al /data1 /data2 /data3

y
nl
O
e
te Us
bu r
tri ne
is rt
D Pa
ot d
N an
D aln
er
o
t
In
SE
SU

124
SUSE Linux Enterprise Server Administration

Summary:
In this exercise you create a new primary partition, added a xfs filesystem to it and
configured it to automatically mount on /data1. You then created an extended parition
and put two logical partitions in it, formatted both with the xfs filesystem and mounted

y
nl
them on /data2 and /data3.

O
(End of Exercise)

e
te Us
bu r
tri ne
is rt
D Pa
ot d
N an
D aln
er
o
t
In
SE
SU

125
SUSE Linux Enterprise Server Administration

11- 2 Manage Partitions with parted

Description:

y
In this exercise you create a new partition using parted.

nl
O
Task 1: Open a terminal session

e
1. On server2, as the tux user, open a terminal by clicking on the Activities menu and

te Us
type:
terminal

bu r
When the Terminal icon appears, click on it to start a terminal session.

tri ne
2. Enter the following command to become the root user:
su -
is rt
When prompted, enter linux for the root user’s password.
D Pa
Task 2: View the Existing Partitions
ot d
N an

1. List the block devices:


lsblk
D al

You can see four virtual disk, (vdx) devices


n

2. To start parted and access the first disk enter:


er

parted /dev/sda
o

3. To view the existing partitions enter:


t
In

print
SE

A linux-swap partition, a BtrFS partition and a XFS partition should be listed


4. Exit parted for /dev/sda by entering:
SU

quit

Task 3: Create a New Partition


1. Access /dev/sdb with parted:
parted /dev/sdb
2. View the current partitions:
print

126
SUSE Linux Enterprise Server Administration
There are no partitions on /dev/sdb
3. Create a new partition table:
mklabel msdos
At the warning about all the data being destroyed answer:
y

y
4. Try the following:

nl
mkpart primary 0 20%

O
A warning is displayed about the partition not being aligned for best performance.

e
Enter:

te Us
C
to cancel

bu r
tri ne
5. In a second terminal window as root run the following commands to obtain the
information required to aligned the partition:
is rt
cat /sys/block/sdb/queue/optimal_io_size
D Pa
cat /sys/block/sdb/alignment_offset
cat /sys/block/sdb/queue/physical_block_size
ot d

6. To create a new primary partition using 20% of the available space in /dev/sdb enter:
N an

mkpart primary 1 20%


You can use -1 as end value of a partition if you want the partition to use the whole left
D al

space on the hard disk


7. To view the existing partitions enter:
n
er

print
o
t

The new partition is listed


In

8. Check the partition number from the previous command, it should be 1. Check the
alignment:
SE

align-check optimal 1
SU

9. Print the partition details:


print

10. Change the units used to sectors. This is used to both display output and the default
unit used to enter data if not specified):
unit s

127
SUSE Linux Enterprise Server Administration
11. Print the partition details and compare the units with the previous output:
print
Notice the letter s after the Start, End and Size which indicates sectors
12. Before you create a new extended partition you need to check where the free space is:
print free

y
nl
13. Use the sector numbers displayed in the previous command to create an extended
partition:

O
mkpart extended <enter-start-sector-of free-space> <end-sector-of-free-

e
space>

te Us
14. Display the partition details including the free space:
print free

bu r
Notice there is still some free space available.

tri ne
15. Create a logical partition within the free space in the extended partition:
mkpart logical <start-sector-of -free-space> 30%
is rt
D Pa
16. At the warning message enter:
I
to ignore.
ot d
N an

Upper or lowercase I will work

17. Check the results:


D al

print free
n

18. Create a second logical partition using 50% of the remaining space in the extended
er

partition:
o
t

mkpart logical <start-sector-of -free-space> 50%


In

19. At the warning message enter:


SE

Y
20. At the second warning message enter:
SU

I
to ignore
21. View the existing partitions enter:
print free

22. Create a final logical partition using all the remaining disk space:
mkpart logical <start-sector-of -free-space> <end-sector-of -free-
space>

128
SUSE Linux Enterprise Server Administration
23. At the warning message enter:
Y
24. At the second warning message enter:
I
to ignore
25. View the existing partitions enter:

y
print free

nl
O
26. change the units to the default:

e
unit compact

te Us
27. Display the partition details and free space:
print free

bu r
tri ne
You need the number of the extended partition for the next command
is rt
28. To check the alignment of your extended partition enter:
D Pa
align-check optimal <extended-partition-number>
ot d
N an

This partition should be aligned


29. To check the alignment of your three logical partitions enter:
D aln

align-check optimal <logical-partition-number>


er
o

30. These partitions are not aligned


t
In

31. To exit parted enter:


quit
SE
SU

Summary:
In this exercise you created a new primary and extended partitions and checked they
are aligned for best performance. You then changed the default units used by parted
for displaying data and accepting input. Finally three logical partitions were added to
the extended partition. You have not created any filesystems on any of the partitions
you created.

129
SUSE Linux Enterprise Server Administration
(End of Exercise)

y
nl
O
e
te Us
bu r
tri ne
is rt
D Pa
ot d
N an
D aln
er
o
t
In
SE
SU

130
SUSE Linux Enterprise Server Administration

11- 3 Create a File System in an Empty Partition

Description:

y
In this exercise you create a new ext4 file system in an empty partition.

nl
O
Task 1: Open a terminal session

e
1. On server2, as the tux user, open a terminal by clicking on the Activities menu and

te Us
type:
terminal

bu r
When the Terminal icon appears, click on it to start a terminal session.

tri ne
2. Enter the following command to become the root user:
su -
is rt
When prompted, enter linux for the root user’s password.
D Pa
Task 2: Create an ext3 File System
ot d

1. View the partitions available on /dev/sdb:


N an

parted /dev/sdb print


Notice there are no file systems listed in the partitions
D al

2. Enter the following commands to create a new ext3 file system on /dev/sdb1 and to
n

give it the label "data1":


er

mkfs.ext4 -L data1 /dev/sdb1


o
t
In

Make sure you specify the correct device in the above command. If you specify the
wrong device, no warning message will be displayed and the file system on the device
SE

will be overwritten.
3. To get the block ID (UUID) of /dev/sdb1, enter the following:
SU

blkid /dev/sdb1
4. Copy the UUID to the clipboard
5. Enter the following to create the directory named data1 under /export/:
mkdir -p /export/data1
6. Enter the following to verify that the directories were created:
ls -l /export
7. As root, add entries to the /etc/fstab file for the new file systems. At the terminal

131
SUSE Linux Enterprise Server Administration
prompt, enter the following to open the file /etc/fstab in the vi editor:
vi /etc/fstab
8. To open a new line at the bottom of the file enter:
G
o
9. Add the following new lines:

y
UUID=<UUID_of_sdb1> /export/data1 ext4 defaults 1 2

nl
These new entries ensure the sdb1 partition is mounted when starting or rebooting the

O
system
10. Save the changes to /etc/fstab by pressing:

e
Esc

te Us
and then entering:
:wq

bu r
tri ne
11. In the terminal window, enter the following to reread the /etc/fstab file and mount all
of the new file systems:
mount -a is rt
D Pa
12. Enter the following to view the information about mounted file systems as listed in /etc/
mtab:
ot d

mount
N an

13. You should see an entry for the new partition you just created at the end of the output:
/dev/sdb1 on /export/data1 type ext4 (rw,relatime,data=ordered)
D al

14. Enter to show the kernel's view of mounted file systems:


n

cat /proc/mounts
er

15. You should see an entry for the new partition you just created at the end of the output:
o
t

/dev/sdb1 /export/data1 ext4 rw,relatime,data=ordered 0 0


In

The mount and umount commands maintain the entries in the /etc/mtab table. The
/etc/mtab table contains more information than /proc/mounts, but may not be as up-
SE

to-date as the kernel's view. Whenever there is a question about whether a file system
is mounted or not, refer to the kernel view in /proc/mounts.
SU

Summary:
In this task you created an ext4 file system labeled “data1” on vdb1. The partition will
be mounted into the /export/data1 directory during the system startup.

(End of Exercise)

132
SUSE Linux Enterprise Server Administration

11- 4 Configure a LVM Volume Group and a Logical Volume

Description:

y
In this exercise you will use the LVM command line commands to create a LVM volume

nl
group and a basic logical volume.

O
e
Task 1: Open a terminal session

te Us
1. On server2, as the tux user, open a terminal by clicking on the Activities menu and
type:

bu r
terminal

tri ne
When the Terminal icon appears, click on it to start a terminal session.
2. Enter the following command to become the root user:
is rt
su -
D Pa
When prompted, enter linux for the root user’s password.
ot d

Task 2: List Partitions on a disk


N an

1. List the block devices on server2:


lsblk
D al

Notice that /dev/sdc contains no partitions


n

2. Start YaST and enter the roots password when prompted:


er

linux
o
t
In

3. Run the Partitioner module and click Yes at the warning


4. From the System View select sdc and add an MS-DOS partition table
SE

Expert > Create New Partition Table > MS-DOS


Click Yes on the warning about deleting data on /dev/sdc
SU

5. Select sdc on the left create the following partitions:


1) Primary,
10GB,
Raw Volume (unformatted),
Partition ID of Linux,
Do not mount device

2) Extended, Maximum Size


6. In the extended partition add the following:

133
SUSE Linux Enterprise Server Administration
7GB,
Raw Volume (unformatted),
Partition ID of Linux,
Do not Mount Device
6GB,
Raw Volume (unformatted),
Partition ID of Linux,
Do not Mount Device

y
7. Save your changes and exit YaST

nl
8. List the block devices again:

O
lsblk

e
te Us
Task 3: Configure an LVM Group
1. Some of the commands in this task will produce more output than can be displayed on

bu r
the screen. Remember to pipe the output to less so you can navigate the output.

tri ne
2. As root, View the current LVM physical volumes on server2:
pvscan
is rt
D Pa
3. Enter the following command to create LVM Physical Volume(s), using the partitions
sdc1, sdc5 and sdc6 created above:
pvcreate /dev/sdc1 /dev/sdc5 /dev/sdc6
ot d

4. View the LVM physical volumes:


N an

pvscan
5. View details of the new LVM physical volumes:
D al

pvdisplay
n
er

Notice that there is no Volume Group name listed


o

6. Use the following command to create an LVM Volume Group named vg0 using the
t

physical volumes you just created:


In

vgcreate vg0 /dev/sdc1 /dev/sdc5 /dev/sdc6


SE

7. Verify that the volume group was created successfully by entering the following
commands (notice the similarities and differences in their outputs):
SU

vgs
vgdisplay
8. To see how the physical volumes created are being used, enter the following commands
(notice the similarities and differences in their outputs):
pvs
pvdisplay
Notice the Alloc PE/Size is 0 and the Free PE/Size is approximately 23GB

134
SUSE Linux Enterprise Server Administration
Task 4: Configure a Basic LVM Logical Volume
1. View the current LVM logical volumes, (there are none at present):
lvs
lvdisplay
2. In the terminal window as the root user use the following command to create one
Logical Volume in the vg0 Volume Group:

y
lvcreate -L 8GB -n lv_basic0 vg0

nl
3. Verify that the logical volume was created by entering the following commands:

O
lvs
lvdisplay

e
te Us
Task 5: Format the Basic LVM Volume with a File System
1. Enter the following command to create a file system in the lv_basic0 logical volume:

bu r
tri ne
mkfs.ext4 /dev/vg0/lv_basic0
2. Enter the following command to create a mount point for the logical volume and mount
it: is rt
D Pa
mkdir -p /export/data
mount /dev/vg0/lv_basic0 /export/data
3. To see that the volume successfully mounted, enter the following command:
ot d
N an

mount
4. To specify the UUID of the logical volume enter:
D al

blkid /dev/mapper/vg0-lv_basic0
n

Copy the UUID to the clipboard


er

5. Open /etc/fstab in the editor of your choice


o

6. Add the following line at the end of the file:


t
In

UUID=<UUID_of_/dev/mapper/vg0-lv_basic0> /export/data ext4 defaults 1 2


SE

Then save and exit the /etc/fstab.


7. Unmount /export/data:
SU

umount /export/data
8. To activate the new /etc/fstab configuration, enter:
mount -a
9. To check the correct mounting enter:
mount
At the end of the output the logical volume should be listed

135
SUSE Linux Enterprise Server Administration
Task 6: Resize the volumegroup and ext4 file system
1. When you created the volume group vg0 you did not use all the available space in the
three partitions. Check for free space in the volume group:
vgdisplay
Look at the Alloc PE/Size and the Free PE/Size. There is approximately 14GB of free
space in the physical extent (PE)

y
nl
2. Check the size of the file system mounted on /export/data:

O
df -h /export/data

e
The size is approximately 7.8GB

te Us
3. Extend the logical volumes by adding 10GB to it:
lvextend -L 10GB /dev/mapper/vg0-lv_basic0

bu r
tri ne
4. View the volume group details:
vgdisplay is rt
D Pa
Notice the Alloc PE/Size and the Free PE/Sizes
ot d

5. Check the size of the file system mounted on /export/data:


N an

df -h /export/data
The size is still approximately 7.8GB
D al

6. Resize the file system:


n

resize2fs /dev/mapper/vg0-lv_basic0
er
o

7. Check the size of the file system mounted on /export/data:


t
In

df -h /export/data
The file system size reported now reflects the extra space added to the logical volume
SE
SU

Task 7: Rename an Existing Logical Volume


1. This is a challenge task. You are not given the step-by-step instructions to perform the
task. Rather you must use knowledge previously gained to successfully complete the
task.
2. Logical Volumes can be renamed after they are created. Your task is to rename the
logical volume you just created using only the CLI LVM utilities.

136
SUSE Linux Enterprise Server Administration
Summary:
In this exercise you used the LVM command line commands to create a LVM volume
group and a basic logical volume. You then configured the volume to mount using the
UUID when the system starts. You then increased the size of the logical volume and
the ext4 file system.

y
nl
(End of Exercise)

O
e
te Us
bu r
tri ne
is rt
D Pa
ot d
N an
D aln
er
o
t
In
SE
SU

137
SUSE Linux Enterprise Server Administration

11- 5 Create a Linear RAID1 Array

Description:

y
In this exercise, you use the mdadm command line utility to create a linear RAID1 array.

nl
O
Task 1: Add the Dev-Tools module to Server2

e
1. Make sure you are logged in to server2 as tux

te Us
2. Launch YaST by clicking on the Activities menu and type:
YaST

bu r
tri ne
3. When the YaST icon appears, click on it to start YaST
4. Enter the root user’s password when prompted.
5. is rt
Under Software, select Add-On Products
D Pa
6. Select Add, then select DVD, then Next
7. Select the device defined with /dev/sr0, then select Continue
8. From the list of Available Extensions and Modules, select the Development-Tools-
ot d

Module, then select Next


N an

9. When the Management Software window loads, select Accept, then Finish.
10. Notice that the Development Tools Module is now listed in the Installed Add-on
Products window. Select OK.
D aln

Task 2: Prepare the disks


er
o

1. In YaST, navigate to
t
In

System -> Partitioner


2. Answer Yes to the warning
SE

3. From the System View select:


sdb
SU

It should contain /dev/sdb1 formatted with ext4 and three logical partitions in an
extended partition.
4. Click on the Expert button and select:
Create New Partition Table
5. Change the type to MSDOS and click OK
6. At the warning click Yes to remove everything from /dev/sdb
7. Perform same steps (3 through 6) for /dev/sdc
8. Click Next → Finish and close YaST

138
SUSE Linux Enterprise Server Administration
Notice that /dev/sdb /dev/sdc and /dev/sdd are now empty

Task 3: Create a RAID1 Array


1. On server2, open a terminal by clicking on the Activities menu and type:
terminal
When the Terminal icon appears, click on it to start a terminal session.

y
2. Enter the following command to become the root user:

nl
su -

O
When prompted, enter linux for the root user’s password.

e
3. To load the RAID kernel module enter:

te Us
modprobe md_mod
There is no visual indication the command will have succeeded.

bu r
4. Enter the following command to see the status of the arrays:

tri ne
watch -d cat /proc/mdstat

is rt
5. Open another terminal window (as root) and enter the following command to create a
new RAID1 array (enter this command as a single line):
D Pa
mdadm -C /dev/md0 \
--force \
--level=1 \
ot d

--bitmap=internal \
N an

--raid-devices=2 \
--spare-devices=1 \
--assume-clean \
D al

/dev/sdb /dev/sdc /dev/sdd


n

If prompted to “Continue creating array” enter:


er

yes
o
t

In the terminal that is running the watch command, you should see the newly created
In

array listed along with its status and component devices. Depending on the size of the
component devices, you may see that the array is still syncing.
SE

Task 4: Create an mdadm.conf file


SU

1. Enter the following command to create the mdadm.conf file:


mdadm -E -s >> /etc/mdadm.conf
2. To see the content of the /etc/mdadm.conf file enter:
less /etc/mdadm.conf
3. Press:
q

139
SUSE Linux Enterprise Server Administration
to quit less

Task 5: Mount the RAID Array into the Filesystem


1. Enter the following command to create a mount point for the RAID device:
mkdir /raiddev
2. Enter the following command to create a filesystem on the RAID device:

y
mkfs.ext4 /dev/md0

nl
3. Enter the following command to mount the array into the filesystem:

O
mount /dev/md0 /raiddev

e
4. Enter the following command to verify that the device is mounted:

te Us
mount
You should see the device listed as mounted

bu r
tri ne
Summary: is rt
D Pa
In this task you created a RAID1 array /dev/md0 that includes two raid devices and
one spare device. You then created the mdadm.conf configuration file. You completed
the task by creating and ext3 file system on the RAID device and mounted it into the
ot d

/raiddev directory.
N an
D al

(End of Exercise)
n
er
o
t
In
SE
SU

140
SUSE Linux Enterprise Server Administration

11- 6 Simulate a Failed RAID Disk

Description:

y
In this exercise you simulate a failing disk in the RAID. You then add the disk back into

nl
the array as a spare.

O
e
Task 1: Open a terminal session

te Us
1. On server2, as the tux user, open a terminal by clicking on the Activities menu and
type:

bu r
terminal

tri ne
When the Terminal icon appears, click on it to start a terminal session.
2. Enter the following command to become the root user:
is rt
su -
D Pa
When prompted, enter linux for the root user’s password.
ot d

Task 2: Simulate a Failing Disk in RAID


N an

1. View the current RAID status:


watch -d cat /proc/mdstat
D al

The RAID devices have names such as sdb[0] and sdc[1] and their status [UU]
n

The first U refers to the first device, indicated by [0], the second U to the second,
er

indicated by [1]. If a device failed, it would be displayed as [_U] if the first device
o

failed, and as [U_] if the second one failed


t
In

2. Open another terminal window and switch to the root account


3. Enter the following command to mark one of the devices as faulty:
SE

mdadm --manage /dev/md0 --fail /dev/sdc


In the other terminal window you should see the device you marked faulty is designated
SU

with an underscore instead of a U. You will also see that the spare device became active
and the array began to resync. When the resync is finished you should see the status
return to UU
As both devices were currently working, it does not matter which one you chose, but if
you are dealing with a damaged hard disk, you have to mark the device faulty that
corresponds to the device with the underscore.
4. To view the current activity of the RAID enter the following command:
cat /sys/block/md0/md/sync_action

141
SUSE Linux Enterprise Server Administration
If it is still resyncing it should display recover
If it has finished resyncing it should display idle
Wait until the synchronization has completed before continuing
5. Enter the following command to remove the failed disk from the array:
mdadm --manage /dev/md0 --remove /dev/sdc
In the other terminal window you should see the array now only contains 2 disks. The
device you removed is no longer listed

y
nl
6. Test if you can still use the /raiddev directory, for instance by creating a file in that
directory

O
Hint: Use the touch command.

e
te Us
Task 3: Add a New Spare Disk to the Array
1. Enter the following command to wipe the existing superblock of the device just
removed:

bu r
tri ne
mdadm --zero-superblock /dev/sdc
2. Enter the following command to add the device back into the array:
is rt
mdadm --manage /dev/md0 --add /dev/sdc
D Pa
In the other terminal window you should see the device listed in the array as a spare
(S)
ot d

3. Enter:
N an

ctrl + c
to stop the raid monitoring
D aln
er

Summary:
o
t

In this task you marked /dev/sdc as faulty and removed the failed disk from the RAID
In

array. You then wiped the existing superblock of /dev/sdc to remove the existing RAID
metadata. Then you will added a new /dev/sdc hard drive to the array.
SE
SU

(End of Exercise)

142
SUSE Linux Enterprise Server Administration

11- 7 Create a Btrfs File System

Description:

y
In this exercise you convert an existing directory into a BtrFS subvolume.

nl
O
Task 1: Create some free space for a BtrFS filesystem

e
1. Make sure you are logged in to server1 as tux

te Us
2. Launch YaST by clicking on the Activities menu and type:
YaST

bu r
tri ne
3. When the YaST icon appears, click on it to start YaST
4. Enter the root user’s password when prompted.
5. is rt
In the System section of the YaST interface click on Partitioner
D Pa
6. In the warning dialog, click Yes
7. In the System View expand Hard Disks and select sdb – it currently has no free space
on it
ot d

8. Now remove /dev/sdc5 and /dev/sdc6:


N an

From the right select /dev/sdc6


Click Delete
D al

9. At the warning click Unmount


10. At the Really Delete warning click Yes
n

11. From the right select /dev/sdc5 and click Delete


er

12. At the warning click Unmount


o
t

13. At the Really Delete warning click Yes


In

14. Click Next → Finish to commit your changes


SE

Task 2: Create a BtrFS filesystem


SU

1. Launch YaST by clicking on the Activities menu and type:


YaST
2. When the YaST icon appears, click on it to start YaST
3. Enter the root user’s password when prompted.
4. In the System section of the YaST interface click on Partitioner
5. In the warning dialog, click Yes
6. In the System View expand Hard Disks and select sdc

143
SUSE Linux Enterprise Server Administration
7. Click Add and enter 12GiB as the size
8. Click Next
9. For the Role leave Data and ISV Applications selected and click Next
10. Under the Formatting Options for the File System select BtrFS
11. Under the Mounting Options select Mount partition and for the mount point enter:

y
/mybtrfs

nl
O
12. Click Finish → Next → Finish

e
13. Close YaST

te Us
14. Check the filesystem is mounted:
mount

bu r
tri ne
You should see output that indicates the filesystem is mounted.
Summary:
is rt
D Pa
In this task you created a new BtrFS filesystem and mounted it on /mybtrfs.
ot d

(End of Exercise)
N an
D aln
er
o
t
In
SE
SU

144
SUSE Linux Enterprise Server Administration

11- 8 Convert an Existing Directory into a Subvolume

Description:

y
In this exercise you convert an existing directory into a BtrFS subvolume.

nl
O
Task 1: Open a terminal session

e
1. On server1, as the tux user, open a terminal by clicking on the Activities menu and

te Us
type:
terminal

bu r
When the Terminal icon appears, click on it to start a terminal session.

tri ne
2. Enter the following command to become the root user:
su -
is rt
When prompted, enter linux for the root user’s password.
D Pa
Task 2: Convert an Existing Directory into a Subvolume
ot d
N an

1. To create a new directory, enter:


mkdir /btrfssubvol
D al

2. To create some content for the data directory, enter


n

cp /bin/* /btrfssubvol
er

3. Open a terminal window and enter the following command to list the existing
o

subvolumes in /:
t
In

btrfs subvolume list /


You may have to scroll back up the buffer to view the subvolumes that are not
SE

snapshots
4. Enter the following command to view the contents of the /btrfssubvol directory:
SU

ls -l /btrfssubvol
5. Enter the following command to convert an existing directory into a subvolume:
mv /btrfssubvol /mybtrfs-orig
btrfs subvolume create /btrfssubvol
cp -a /mybtrfs-orig/. /btrfssubvol/
rm -r /mybtrfs-orig
6. Enter the following commands to view the changes:
ls -l /btrfssubvol

145
SUSE Linux Enterprise Server Administration
7. You should see the same contents in the /btrfssubvol subvolume as was in the
original /btrfssubvol directory.
8. Enter the following commands to view the changes:
btrfs subvolume list /
9. You should also see that /btrfssubvol is listed as a new subvolume.

y
nl
O
e
te Us
bu r
tri ne
is rt
D Pa
ot d
N an
D aln
er
o
t
In
SE
SU

146
SUSE Linux Enterprise Server Administration

Summary:
In this task you created a new directory /btrfssubvol and copied the content of the /
bin directory into it. This directory was then converted into a BtrFS subvolume.

y
nl
(End of Exercise)

O
e
te Us
bu r
tri ne
is rt
D Pa
ot d
N an
D aln
er
o
t
In
SE
SU

147
SUSE Linux Enterprise Server Administration

11- 9 Work with Btrfs

Description:

y
In this exercise you will work with BtrFS.

nl
O
Task 1: Display Volume and Subvolume Information

e
1. On server1, as the tux user, open a terminal by clicking on the Activities menu and

te Us
type:
terminal

bu r
When the Terminal icon appears, click on it to start a terminal session.

tri ne
2. Enter the following command to become the root user:
su - is rt
D Pa
When prompted, enter linux for the root user’s password.
3. Display what is mounted on server1 with:
ot d

mount
N an

Notice that /dev/sda2 appears to be mounted many times, but with different mount
points
D al

1. List the subvolumes of the root filesystem:


n

btrfs subvolume list /


er

The output will look similar to that below:


o
t

server1:~ # btrfs subvolume list /


In

ID 257 gen 2955 top level 5 path @


ID 258 gen 2957 top level 257 path @/.snapshots
ID 259 gen 3139 top level 258 path @/.snapshots/1/snapshot
SE

ID 260 gen 2618 top level 257 path @/boot/grub2/i386-pc


ID 261 gen 2593 top level 257 path @/boot/grub2/x86_64-efi
ID 262 gen 2607 top level 257 path @/opt
SU

ID 263 gen 2760 top level 257 path @/srv


2. Notice in the example above the ID for @ is 275, it is in the left hand column
Note the top level id is 257 for @/opt which links it to @
Notice the top level it for @ is 5 which is the root files system and will always be 5
3. Look at the output from the command on your system and observe how the subvolumes
are linked together.
4. View the /etc/fstab file:
cat /etc/fstab

148
SUSE Linux Enterprise Server Administration
Look for the subvol= in the options column
5. View how file systems are mounted by systemd mount units:
systemctl list-units --type mount
Task 2: Work with BtrFS
1. Create a new subvolume using YaST
Start YaST and enter the root users password when prompted

y
2. Select System > Partitioner.

nl
3. In the Warning dialog, select Yes

O
4. In the left pane, select Btrfs
5. In the right pane, select /dev/sda2

e
6. Click Edit

te Us
7. In the Edit Btrfs dialog, click Add
8. In the New Subvolume field, type

bu r
@/data4

tri ne
and click OK
is rt
9. In the Edit Btrfs dialog, click OK
D Pa
10. In the Expert Partitioner dialog, click Finish, then click Finish
11. Close YaST
12. Open a terminal and become the root user with:
ot d

su -
N an

13. View the content of the / directory:


ls /
D al

As a subvolume appears as a directory in the filesystem, the /data4 directory exists


n

14. Create a file in /root and try to create a hardlink to /data4/mytest-link:


er
o

touch /root/mytestfile
t

ln /root/mytestfile /data4/mytest-link
In

Despite the fact that /root and /data4 reside on the same harddisk partition, the
creation of the link fails because hardlinks cannot cross subvolumes
SE

15. Mount the new volume:


mount -a
SU

16. View the currently mounted filesystems:


mount
systemctl list-units --type mount
Look for data4.mount
17. View the disk space utilization:
df -h
btrfs filesystem df /
btrfs filesystem show /dev/sda2

149
SUSE Linux Enterprise Server Administration
Task 3: Work with BtrFS Snapshots
1. Still on server1 as the root user in a terminal, create a file in the /data4 subvolume:
touch /data4/newfile
2. Create a snapshot of the /data4 volume:
btrfs subvolume snapshot /data4 /data4-snapshot
3. Compare the content of /data4 and /data4-snapshot

y
nl
ls /data4
ls /data4-snapshot

O
You should see the file newfile file in both directories
4. Remove the file just created:

e
te Us
rm /data4/newfile
5. Compare the content of /data4 and /data4-snapshot again:

bu r
ls /data4

tri ne
ls /data4-snapshot
You should see the newfile file in the /data4-snapshot directory only.
is rt
Deleting a file does not free any disk space as long as there is a snapshot of that
D Pa
subvolume. This is a reason why you need to allocate more hard disk space with BtrFS
when using snapshots than you would need with ext3, for instance
6. Remove the snapshot:
ot d

btrfs subvolume delete /data4-snapshot


N an

7. To amplify the fact mentioned in the note above, enter the following:
Note that it can sometimes take a few moments for the utilization values to become
D al

updated, so you may have to wait and enter the btrfs commands again to see the
n

effects.
er

df -h
o

btrfs filesystem show /


t

btrfs filesystem df /
In

btrfs filesystem usage /


8. Create a big file and compare the new “used” values to those from the above step:
SE

dd if=/dev/urandom of=/data4/bigfile bs=1M count=250


df -h
SU

btrfs filesystem show /


btrfs filesystem df /
btrfs filesystem usage /
9. Create a snapshot of the /data4 subvolume:
btrfs subvolume snapshot /data4 /data4-snapshot
ls -l /data4
ls -l /data4-snapshot
10. Remove /data4/bigfile and compare again:
rm /data4/bigfile

150
SUSE Linux Enterprise Server Administration
df -h
btrfs filesystem show /
btrfs filesystem df /
Note that the “used” values have not significantly changed compared to the call of the
commands in the previous step, despite the fact that you deleted a 250 MB file.
btrfs filesystem usage /
11. Remove the /data4-snapshot subvolume and compare again:

y
btrfs subvolume delete /data4-snapshot

nl
df -h
btrfs filesystem show /

O
btrfs filesystem df /
btrfs filesystem usage /

e
12. To observe ref-linked copies and how they influence disk space utilization and the

te Us
values displayed by various utilities, do the following:
Note that it can sometimes take a few moments for the utilization values to become
updated, so you may have to wait and enter the btrfs commands again to see the

bu r
tri ne
effects.
df -h / ; btrfs filesystem show /
is rt
btrfs filesystem df / ; btrfs filesystem usage /
D Pa
13. Create a file with a size of 250 MB and compare the new “used” values to those from
the above step:
dd if=/dev/urandom of=/data4/bigfile bs=1M count=250
ot d

df -h / ; btrfs filesystem show /


N an

btrfs filesystem df / ; btrfs filesystem usage /


14. Create a ref-linked copy of the file and compare the values again:
D al

cp --reflink=always /data4/bigfile /data4/reflinkedcopy


df -h / ; btrfs filesystem show /
n

btrfs filesystem df / ; btrfs filesystem usage /


er

15. Remove the original file and check the values again:
o
t
In

rm /data4/bigfile
df -h / ; btrfs filesystem show /
btrfs filesystem df / ; btrfs filesystem usage /
SE

16. Remove the /data4/reflinkedcopy file and check the values again:
rm /data4/reflinkedcopy
SU

df -h / ; btrfs filesystem show /


btrfs filesystem df / ; btrfs filesystem usage /

Task 4: Work with BtrFS Subvolumes


1. On server1, as the tux user, in a terminal session, wnter the following command to
become the root user:
su -
When prompted, enter linux for the root user’s password.

151
SUSE Linux Enterprise Server Administration
2. Using YaST, create an additional partition on /dev/sdb with a size of 5GB, format with
BtrFS and mount it on /btrfs
Create two subvolumes, subvol1 and subvol2 on /btrfs:
btrfs subvolume create /btrfs/subvol1
btrfs subvolume create /btrfs/subvol2
Then create a few files in /btrfs and the subvolumes:
touch /btrfs/btrfsmain.txt

y
touch /btrfs/subvol1/fileinsubvol1.txt

nl
touch /btrfs/subvol2/fileinsubvol2.txt

O
3. List the currently available subvolumes in /btrfs:
btrfs subvolume list /btrfs

e
4. Unmount /btrfs:

te Us
umount /btrfs
5. Make subvol1 the default subvolume instead of the current root volume:

bu r
mount /dev/sdb1 /btrfs

tri ne
btrfs subvolume list /btrfs
Note the ID of subvol1
is rt
6. Make subvol1 the default subvolume:
D Pa
btrfs subvolume set-default <ID> /btrfs
umount /btrfs
ot d

7. Make sure to not add any subvol= option:


N an

mount /dev/sdb1 /btrfs


ls -l /btrfs
You should see fileinsubvol1.txt
D aln
er

Summary:
o
t
In

In this lab you viewed BtrFS subvolume information including disk space. You then
created a snapshot. Finally you changed the default so a snapshot volume was
SE

mounted.
SU

(End of Exercise)

152
SUSE Linux Enterprise Server Administration

11- 10 BtrFS: In-Place Migration and Maintenance

Description:

y
In this exercise you will perform an in-place migration from ext4 to BtrFS and perform

nl
maintenance tasks.

O
e
Task 1: Convert an ext4 Filesystem to BtrFS

te Us
1. On server1, as the tux user, open a terminal by clicking on the Activities menu and
type:

bu r
terminal

tri ne
When the Terminal icon appears, click on it to start a terminal session.
2. Enter the following command to become the root user:
is rt
su -
D Pa
When prompted, enter linux for the root user’s password.
3. Use YaST -> System -> Partitioner to create an additional partition on /dev/sdb using
ot d

the following details:


N an

Primary Partition
Maximum Size
For the Role select: Data and ISV Applications
D al

Format: ext4
n

Mount point: /toconvert


er

4. Create a few directories and files within the filesystem:


o
t

mkdir /toconvert/dir-{a,b,c}
In

touch /toconvert/dir-{a,b,c}/file{a,b,c}
5. Umount the filesystem:
SE

umount /toconvert
6. Convert the filesystem to BtrFS:
SU

btrfs-convert -l convertedfs /dev/sdb2


7. Mount the filesystem again:
mount /dev/sdb2 /toconvert
8. View the filesystem type:
mount
Note that the filesystem of /toconvert is of type btrfs

153
SUSE Linux Enterprise Server Administration
9. View the BtrFS information:
btrfs filesystem show
10. View the subvolumes:
btrfs subvolume list /toconvert
11. View the content of /toconvert:
ls -a /toconvert

y
nl
12. Also look at the content of /toconvert/ext2_saved
ls -a /toconvert/ext2_saved

O
13. Check the file type of /toconvert/ext2_saved/image:

e
file /toconvert/ext2_saved/image

te Us
14. (Conditional)You can mount (and unmount) this image:
mount -o loop /toconvert/ext2_saved/image /mnt

bu r
mount

tri ne
15. (Filesystem: ext4)
ls /mnt
umount /mnt
is rt
D Pa
16. (Conditional) You can also mount (and unmount) the subvolume:
mount -o subvol=ext2_saved /dev/sdb7 /mnt
ot d

mount
N an

17. (Filesystem: btrfs)


ls /mnt
D al

umount /mnt
n

18. Create a few more files:


er

mkdir /toconvert/dir-{d,e,f}
o

touch /toconvert/dir-{d,e,f}/btrfsfile
t
In

19. Check the files exist:


ls -al /toconvert/dir-d/
SE

20. Roll back to the ext4 filesystem:


umount /toconvert
SU

btrfs-convert -r /dev/sdb2
21. Mount the filesystem again:
mount /dev/sdb2 /toconvert
22. View the filesystem type:
mount
Note that the filesystem of /toconvert is of type ext4
23. View the files in /toconvert

154
SUSE Linux Enterprise Server Administration
ls /toconvert
Notice that the directories you created on the BtrFS are gone, only those created initially
on the ext4 file system are there
24. Unmount the filesystem:
umount /toconvert

y
Task 2: Perform BtrFS Maintenance Tasks

nl
1. Log in to server1 as tux:

O
2. Open two terminal windows and:
su -

e
te Us
to root in both of them
3. In one of the terminals, enter
watch btrfs scrub status /

bu r
tri ne
4. Switch to the other terminal window and enter:
btrfs scrub start /
is rt
The watch at the first prompt will show the scrubbing progress
D Pa
5. In the terminal running watch press Ctrl+c to end the watch process
6. Defragment the filesystem recursively, starting from /:
ot d

btrfs filesystem defragment -r /


N an

Note that you will see some errors about files being busy. This is normal.
7. Review the content of the btrfsmaintenance package:
D al

rpm -ql btrfsmaintenance


n

8. Review the parameters that can be set in /etc/sysconfig/btrfsmaintenance:


er

less /etc/sysconfig/btrfsmaintenance
o
t
In

9. In one of the terminals, enter :


watch btrfs balance status /
SE

For now the output will just be “No balance found on /”


10. In the other terminal, start a BtrFS tree balance:
SU

btrfs balance start /


It takes some time for the prompt to return with a message of how many chunks were
relocated. Leave the balance running

Summary:
In this lab you converted a ext4 fileystem to btrfs. You then converted from BtrFS to

155
SUSE Linux Enterprise Server Administration
ext4 proving you can reverse the conversion. You then performed some basic BtrFS
maintenance.

(End of Exercise)

y
nl
O
e
te Us
bu r
tri ne
is rt
D Pa
ot d
N an
D aln
er
o
t
In
SE
SU

156
SUSE Linux Enterprise Server Administration

11- 11 Configure NFS

Description:

y
In this exercise you will configure server1 to export directories using NFSv4 and use

nl
server2 as a client to import them.

O
e
Task 1: Setup an NFS Server

te Us
1. On server1, as the tux user, open a terminal by clicking on the Activities menu and
type:

bu r
terminal

tri ne
When the Terminal icon appears, click on it to start a terminal session.
2. Enter the following command to become the root user:
is rt
su -
D Pa
When prompted, enter linux for the root user’s password.
3. Stop the firewall:
ot d

systemctl stop firewalld


N an

4. Create the /export/documentation/ directory:


mkdir -p /export/documentation
D al

setfacl -m g:users:rwx /export/documentation


setfacl -d -m g:users:rwx /export/documentation
n

5. Copy some files into the documentation directory:


er
o

cd /export/documentation
t

cp -r /usr/share/doc/release-notes/* .
In

6. Install and execute the YaST2 NFS Server configuration module:


SE

zypper in yast2-nfs-server

yast2 nfs_server &


SU

7. In the NFS Server Configuration dialog, in the NFS Server pane make sure the radio
button has Start selected
8. Make sure that the Enable NFSv4 check box is enabled, change the NFSv4 domain
name to suse.com and click Next
9. Now you will add the /export/documentation/ directory to the list of directories:
10. Select Add Directory
11. A dialog appears where you have to specify the directory to export
12. Type /export/documentation, then select OK

157
SUSE Linux Enterprise Server Administration
13. A dialog appears with fields for specifying a Host Wild Card and Options
14. Change the preset values to match the following, then select OK
Hosts Wild Card: *
Options: rw,root_squash,sync,no_subtree_check
(make sure you replace “ro” with “rw”)
When completed click OK
The directory is added to the list

y
15. Repeat the above step to export the /home directory

nl
16. Save the changes to the system by selecting Finish

O
17. At the terminal window, verify that the file system was exported:
showmount -e localhost

e
te Us
18. View the entry made by YaST to the /etc/exports file
cat /etc/exports

bu r
You should see the settings you entered in YaST

tri ne
Task 2: Setup an NFS Client
is rt
D Pa
1. On server2, as the tux user, open a terminal by clicking on the Activities menu and
type:
terminal
ot d

When the Terminal icon appears, click on it to start a terminal session.


N an

2. Enter the following command to become the root user:


su -
D al

When prompted, enter linux for the root user’s password.


n

3. Stop the firewall:


er
o

systemctl stop firewalld


t
In

4. Create the /import/docs directory:


mkdir -p /import
SE

5. Start the NFS Client Configuration from the terminal window:


SU

yast2 nfs &


The NFS Client Configuration dialog appears
6. Select the NFS Shares tab and click Add
7. Enter the following values, then click OK
NFS Server Hostname: server1
Remote Directory: /export/documentation
NFSv4 Share: select
Mount Point (local): /import/docs

158
SUSE Linux Enterprise Server Administration
Options: defaults
8. Click OK
9. Select the NFS Settings tab, make sure that the Enable NFSv4 check box is enabled
and change:
NFSv4 domain name: localdomain

10. Click OK

y
11. View the content of the /import/docs directory:

nl
ls /import/docs

O
12. Find out if tux can write to the directory (in a terminal as tux user):

e
touch /import/docs/file

te Us
13. View the /etc/fstab file:
cat /etc/fstab

bu r
14. From a terminal as root mount the pseudo root directory from server1 to /mnt:

tri ne
mount server1:/ /mnt
is rt
15. Have a look at the content of /mnt:
D Pa
ls /mnt
You can see export, home and source
ot d

16. Unmount /mnt again:


N an

umount /mnt
D aln

Summary:
er

In this lab you configured two directories to be exported from server1. You also
o
t

configured extended ACL on the exported folders. You then imported to documentation
In

nfs export into server2 and tested tux’s permissions to the nfs share.
SE

(End of Exercise)
SU

159
SUSE Linux Enterprise Server Administration

12Administration and Monitoring

Description:

y
nl
You will configure time synchronization with NTP. You will then configure logging.

O
e
te Us
bu r
tri ne
is rt
D Pa
ot d
N an
D aln
er
o
t
In
SE
SU

160
SUSE Linux Enterprise Server Administration

12- 1 Configure the NTP Service

Description:
In this exercise you use the YaST NTP Configuration module to configure a chronyd

y
nl
NTP server, then use the chronyc command to explore the NTP information on the
host.

O
e
te Us
Task 1: Configure the NTP Server
1. Make sure you are logged in to server1 as tux
2. Launch YaST by clicking on the Activities menu and type:

bu r
tri ne
YaST
3. When the YaST icon appears, click on it to start YaST
is rt
4. Enter the root user’s password when prompted.
D Pa
5. In the YaST interface, click in the Search dialogue and type
NTP
ot d

6. Click the NTP Configuration icon on the right side panel to start the configuration
N an

module
7. On the NTP Configuration screen, select the
D al

Now and on Boot radio button


n

8. From the Configuration Source dropdown list, select:


er

Choose Static
o
t
In

9. Add a new Synchronization Server by navigating to the bottom left of the


Synchronization Servers dialogue:
SE

Click Add
172.16.2.1
SU

Ensure the Quick Initial Sync checkbox is checked


Ensure the Start Offline checkbox remains unchecked
Click Ok
10. To close the NTP Configuration module
Click Ok
11. Close the YaST interface

161
SUSE Linux Enterprise Server Administration
Task 2: Ensure NTP is Loaded and Running
1. Open a terminal by clicking on the Activities menu and type:
terminal
When the Terminal icon appears, click on it to start a terminal session
2. Switch to the root user by typing:
su -

y
Enter the root user password

nl
3. Ensure the chronyd service is running by typing:

O
systemctl status chronyd.service

e
4. The output should indicate that the service is:

te Us
active (running) in the Loaded and Active lines of the output
5. Quit the less output using the q keystroke

bu r
tri ne
Task 3: Query your system for NTP information
is rt
1. In a terminal on server1, as the root user:
D Pa
2. Verify your sources are active and being queried with the command:
chronyc sources -v
ot d

The -v option causes extra column descriptive text to be displayed.


N an

3. Query the chrony service for it’s activity with the command:
chronyc activity
D al

The activity argument shows information about sources and their online/offline status
4. Verify the tracking information with the command:
n
er

chronyc tracking
o

The tracking argument shows a wealth of information including the stratum of your
t
In

server, how accurate (fast/slow) your system time is calculated to be and any skew
information, to include how often updates are occuring.
SE

5. Query your system’s full set of NTP data with the command:
chronyc ntpdata | less
SU

The ntpdata argument displays the most full set of NTP-related information about your
host’s configuration, settings, interactions with other NTP servers and it’s time accuracy
or lack thereof.
6. Quit the less output by pressing the q keystroke.
7. Exit the root login session and close the terminal application

162
SUSE Linux Enterprise Server Administration
Summary:
In this exercise you used the YaST NTP Configuration module to configure a chronyd
NTP server, then used the chronyc command to explore the NTP information on the
host.

y
(End of Exercise)

nl
O
e
te Us
bu r
tri ne
is rt
D Pa
ot d
N an
D aln
er
o
t
In
SE
SU

163
SUSE Linux Enterprise Server Administration

12- 2 Manage System Logging

Description:

y
In this exercise you practice configuring rsyslog and logrotate.

nl
O
Task 1: Modify the rsyslog Configuration

e
1. On server2, as the tux user, open a terminal by clicking on the Activities menu and

te Us
type:
terminal

bu r
When the Terminal icon appears, click on it to start a terminal session.

tri ne
2. Enter the following command to become the root user:
su -
is rt
When prompted, enter linux for the root user’s password.
D Pa
3. In the text editor of you choice, open the /etc/rsyslog.conf file
4. Add the following lines at the bottom of the file to create entries for the messages you
ot d

want to log:
N an

local4.=debug -/var/log/local4.debug
local4.=info -/var/log/local4.info
local4.* -/var/log/local4
D al

Save the changes and close the editor


n

5. To restart the rsyslog daemon enter:


er

systemctl restart rsyslog.service


o
t

6. Open a new terminal window and enter:


In

su –
to become root
SE

7. Now lets check the configuration by logging an entry to the info level in the local4
facility. Enter the following in one of your terminal sessions to monitor the activity of the
SU

log file:
tail -F /var/log/local4.info
You will see a warning regarding the fact that the file does not yet exist. You can
disregard this error as the file will be created when you complete the next step.
8. In the other terminal window, log an entry to the info level in the local4 facility by
entering:
logger -p local4.info "Info message 1"
Check the results in the second terminal window

164
SUSE Linux Enterprise Server Administration
The message should also be logged in the /var/log/local4 file and, because of other
entries in /etc/rsyslog.conf, in /var/log/localmessages
9. In the terminal window where the log activity is being monitored with tail, stop the
monitoring by pressing:
Ctrl+c
10. Repeat this process for the debug log level by using the following command in the first
terminal window:

y
tail -F /var/log/local4.debug

nl
11. Use the following command in the second terminal window:

O
logger -p local4.debug “Debug Info message 2”

e
Only those level4 log files with entries will be compressed during log rotation in Task II

te Us
of this exercise.
12. In the terminal window where the log activity is being monitored with tail, stop the
monitoring by pressing:

bu r
tri ne
Ctrl+c

Task 2: Configure logrotate


is rt
D Pa
1. Using server1 at the shell prompt as the root user, in the text editor of your choice,
open:
ot d

/etc/logrotate.d/local4
N an

2. Add the following content to the file making sure the directories in the first line are
separated with spaces:
D al

/var/log/local4.debug /var/log/local4.info /var/log/local4


{
n

compress
er

dateext
o

maxage 1
t

rotate 5
In

size 20
postrotate
SE

date >> /var/log/local4.info


endscript
}
SU

3. Save the changes and close the editor


4. Switch to virtual terminal 1. From the virtual machine menu select Send Key and select
Ctrl+Alt+F1 (or enter chvt 1 in the terminal window)
5. Log in as root with a password of linux
6. Rotate the logs manually:
logrotate /etc/logrotate.conf
7. Check the directory /var/log for the compressed local4 log files:
ls -l /var/log | less

165
SUSE Linux Enterprise Server Administration
You see the following files:
local4.debug-<current_date>.xz
local4.info-<current_date>.xz
For example, if the current date is November 15, 2018 then the zipped file for
local4.info will be local4.info-20181115.xz
The .xz extension is used because the command to compress files is set to /usr/bin/
xz in /etc/logrotate.conf

y
Only those log files with entries are compressed

nl
8. Exit less by entering:

O
q
9. Check the contents of the local4.info zipped archive:

e
te Us
less /var/log/local4.info-<current_date>.xz
10. Press:

bu r
q

tri ne
to exit the pager program
11. Log out as root by entering:
exit
is rt
D Pa
12. Return to the GNOME desktop by pressing:
Ctrl+Alt+F7
ot d
N an

13. Close all open windows


D al

Summary:
n
er
o
t
In

(End of Exercise)
SE
SU

166
SU
SE
In
ert
D aln
o
N an
ot d

167
D Pa
is rt
tri ne
SUSE Linux Enterprise Server Administration

bu r
te Us
e
O
nl
y

You might also like