Professional Documents
Culture Documents
LAB MANUAL-SUSE Linux Enterprise Server Administration - LMS
LAB MANUAL-SUSE Linux Enterprise Server Administration - LMS
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.
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
applications.
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
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 3: Navigate in and Save an Existing File as a New File with Changes.........................................45
er
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
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
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
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
8
SUSE Linux Enterprise Server Administration
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
2. If you like you can view other log files by selecting other entries from the drop-down list
o
OK
SE
10
SUSE Linux Enterprise Server Administration
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
/var/log/boot.log
And press Enter
SE
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
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
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
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
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
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
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
Summary:
SE
(End of Exercise)
17
SUSE Linux Enterprise Server Administration
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
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
zypper in tree
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
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
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
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
man 5 crontab
Notice the man page shown is the crontab man page from section 5, which is
SE
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
q
er
o
Summary:
In this exercise, you used the whatis, man, apropos and info commands and
SU
(End of Exercise)
24
SUSE Linux Enterprise Server Administration
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
!in
The info top command history item will be executed
SE
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
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
wc -l dir-listing.txt
Note the number of lines indicated for later reference.
D al
ls ~ > dir-listing.txt
o
t
In
Compare this number of lines with the previous steps number, indicating the file was
overwritten by the contents of your home directory.
SU
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
1. Prepare a raw text file on disk for printing and display the identical output on the console
er
with:
o
t
In
G
Note the number of lines in the output, for comparison in the next step.
SU
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
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
cd ~
er
pwd
In
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
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
mv myfile firstfile
SE
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
mkdir -p ~/test/tuxdir/emptydir
In
ls ~/test
5. Verify that emptydir was created by entering:
SU
ls ~/test/tuxdir
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
rm -r ~/mybin
and if prompted confirm every warning by entering:
n
er
y
o
ls ~/mybin
SE
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
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
/root
t
In
5. Navigate through the output by using the cursor keys and the Page Up and the Page
Down keys
SU
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
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
ls -l bin-archive.tar
SE
Note the size of the .tar file for comparison with future compressed versions.
SU
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.
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:
ls -a ~/mybackups
D al
ls -a ~/mybackups/bin
o
5. To sync the content of the mybackups directory into the destinationdir directory
enter:
SE
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
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
<h2>Features (SL9.3)</h2>
<h2>Implementation</h2>
n
<h2>The files</h2>
er
directory that include the word “configuration” by entering the following (on one line):
t
In
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
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
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
This will open the file and place your cursor to the left of the first occurrence of text by
default.
n
: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
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
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
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
[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
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
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
yes
er
exit
4. From the terminal on server1, enter the following on server1 to view the processes
running on server2:
SU
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
3. Enter the following command to copy the /bin/date program from server2 to tux’s
o
home directory:
t
In
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
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
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
51
SUSE Linux Enterprise Server Administration
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
su –
er
2. In the text editor of your choice, open the /etc/ssh/sshd_config file to be edited
t
In
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
exit
n
exit
o
t
In
Summary:
SU
In this exercise, you have practiced using SSH utilities with public key authentication.
(End of Exercise)
53
SUSE Linux Enterprise Server Administration
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
vncviewer server2:1
n
At this point we know the remote administration function is disabled on server2 but
there could also be firewall issues.
SE
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
Yes
n
to continue
er
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
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
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
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
(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
2. Unless it has been changed from the default installation, it is not enabled and not active.
er
Docs: man:chronyd(1)
3. Start the NTP daemon:
SU
or
rcchronyd start
59
SUSE Linux Enterprise Server Administration
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
8. Enable the NTP daemon to make sure it starts when the system boots:
systemctl enable chronyd
D al
Active: active (running) since Mon 2018-07-16 15:52:57 MDT; 3min 56s
ago
SU
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
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
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
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
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
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
sshd.service
t
In
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
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
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
ps xl (lower case L)
n
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
kill <PID_OF_SYSTEM-MONITOR_PROCESS>
er
killall xeyes
In
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
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 root
n
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
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
Ctrl-c
D al
The nohup command buffers or wraps a command in such a way that it ignores any
HANGUP kill signals sent to it.
SE
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
xeyes &
n
xeyes &
o
t
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
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
[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
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
q
o
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
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
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
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
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
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
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
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
Username: emperor
er
Password: linux
Confirm Password: linux
o
t
In
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
linux
5. Select Security and Users section select User and Group Management
D al
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
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
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
2. Enter the following command to verify that the user was created:
er
You should see the new emperor user listed (getent is a command to get entries from
t
In
created:
ls -l /home
SU
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
You should see that the emperor user is now a member of the admins group
o
t
In
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
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
cd /files
er
4. Change the permissions on the private directory so that only root has read, write,
and execute permissions by entering:
SE
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
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
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
Summary:
SU
(End of Exercise)
86
SUSE Linux Enterprise Server Administration
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
cd /tmp
n
2. Create a acl_test directory and set the permissions to rwx for the owner (700):
er
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
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
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
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
Enter
n
You should see that YaST has only a limited set of modules available.
er
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
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
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
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
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
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
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
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
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
'org.gnome.controlcenter.datetime.configure':
er
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
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
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
Notice that the information includes the install date and a description
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
rpm -q gvim
er
o
inspection:
zypper in -d gvim
SU
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
(End of Exercise)
n
er
o
t
In
SE
SU
101
SUSE Linux Enterprise Server Administration
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
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
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
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
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
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>
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
You should see that the alias for the repository has changed
n
er
zypper rr sles12-sp2-new
SE
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
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
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
The icon changes to a green check mark. Any shown dependencies will also be
indicated.
SE
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
Summary:
n
er
(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
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
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:__________________________
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
Summary:
In this exercise you have manually configured your network using command line tools.
(End of Exercise)
111
SUSE Linux Enterprise Server Administration
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
2. At the end of the file there should be lines like the following:
n
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
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
cp ifcfg.template ifcfg-eth0
o
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 - -
y
commands:
nl
ip address show eth0
O
ip route show
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
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
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
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
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
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
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
confirm that your previously selected zone and service configurations from Task 2
above are present and active.
SU
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
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
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
1. On server1, as the tux user, open a terminal by clicking on the Activities menu and
type:
D al
terminal
n
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
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
parted /dev/sda
o
print
SE
quit
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
print
o
t
8. Check the partition number from the previous command, it should be 1. Check the
alignment:
SE
align-check optimal 1
SU
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
print free
n
18. Create a second logical partition using 50% of the remaining space in the extended
er
partition:
o
t
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
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
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
2. Enter the following commands to create a new ext3 file system on /dev/sdb1 and to
n
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
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
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
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
linux
o
t
In
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
pvscan
5. View details of the new LVM physical volumes:
D al
pvdisplay
n
er
6. Use the following command to create an LVM Volume Group named vg0 using the
t
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
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
df -h /export/data
The size is still approximately 7.8GB
D al
resize2fs /dev/mapper/vg0-lv_basic0
er
o
df -h /export/data
The file system size reported now reflects the extra space added to the logical volume
SE
SU
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
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
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
1. In YaST, navigate to
t
In
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
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
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
139
SUSE Linux Enterprise Server Administration
to quit less
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
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
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
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
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
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
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
cp /bin/* /btrfssubvol
er
3. Open a terminal window and enter the following command to list the existing
o
subvolumes in /:
t
In
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
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
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
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
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
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 df /
In
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
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
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
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
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
Primary Partition
Maximum Size
For the Role select: Data and ISV Applications
D al
Format: ext4
n
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
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
umount /mnt
n
mkdir /toconvert/dir-{d,e,f}
o
touch /toconvert/dir-{d,e,f}/btrfsfile
t
In
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
Note that you will see some errors about files being busy. This is normal.
7. Review the content of the btrfsmaintenance package:
D al
less /etc/sysconfig/btrfsmaintenance
o
t
In
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
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
cd /export/documentation
t
cp -r /usr/share/doc/release-notes/* .
In
zypper in yast2-nfs-server
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
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
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
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
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
Choose Static
o
t
In
Click Add
172.16.2.1
SU
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
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
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
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
/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
compress
er
dateext
o
maxage 1
t
rotate 5
In
size 20
postrotate
SE
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
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