In this lab, you will create and edit a new system file using vim.
| Resources | |
|---|---|
| Files: |
/etc/motd
|
| Machines: |
desktopX
|
Outcomes
An updated /etc/motd file on desktopX.
N/A
You have been asked to update the
Message-Of-The-Day (MOTD) file on
desktopX. This file is called /etc/motd,
and its contents are displayed to users upon a successful login on the
command line.
Update the /etc/motd file on desktopX
to read exactly as it read in below text block without replacing the value of "X" in this step:
desktopX.example.com
Please be careful.
Log into your desktopX system as student
and open a terminal.
Since /etc/motd is a system file, you will
need to elevate your privileges.
[student@desktopX ~]$su -Password:redhat
Open /etc/motd in vim.
[root@desktopX ~]#vim /etc/motd
Enter insert mode by pressing i or a, then type the following text:
desktopX.example.com
Please be careful.
Press Esc to exit insert
mode and return to command mode, then type
:wq to enter ex mode to save
and quit.
Test your changes by using ssh to connect to the
student account on localhost. If all goes
well, you should see your new message after authentication. Close the
ssh connection when you are done testing.
[root@desktopX ~]#ssh student@localhostThe authenticity of host 'localhost (::1) can't be established. RSA key fingerprint is xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx.Are you sure you want to continue connecting (yes/no)?yesWarning: Permanently added 'localhost' (RSA) to the list of known hosts.student@localhost's password:studentdesktopX.example.com Please be careful.[student@desktopX ~]$exit
Edit /etc/motd again. This time, replace the
X in desktopX.example.com with your actual
station number, using search and replace. You are also asked to
repeat the “Please be careful.” line two
more times.
Open /etc/motd in vim.
Make sure that you are still working as root.
[root@desktopX ~]#vim /etc/motd
Use search and replace to replace X with your actual
station number. The example that follows assumes that you are
station number 99.
From command mode, enter
ex mode and replace all occurrences of
X with 99 by typing the following:
:%s/X/99/gMove your cursor to line number three by typing the following from command mode:
:3
Yank (copy) the current line, then put (paste) it twice, by
typing yy2p.
The yy part yanks the current line, and
2p puts it twice.
Save and quit by typing :wq.
Test your changes by using ssh to connect to
student@localhost again.