Updated: 2014-12-01 13:37 EST
Do not print this assignment on paper!
- On paper, you will miss updates, corrections, and hints added to the online version.
- On paper, you cannot follow any of the hyperlink URLs that lead you to hints and course notes relevant to answering a question.
- On paper, scrolling text boxes will be cut off and not print properly.
23h59 (11:59pm) Friday December 5, 2014 (end of Week 14)
This is a BONUS assignment for extra credit. It is optional.
This assignment is based on your weekly Class Notes.
Remember to READ ALL THE WORDS to work effectively and not waste time.
This is an overview of how you are expected to complete this assignment. Read all the words before you start working.
For full marks, follow these directions exactly.
Do not print this assignment on paper. On paper, you cannot follow any of the hyperlink URLs that lead you to hints and course notes relevant to answering a question. You also don’t get any of the later updates to the assignment.
You will create some minimal file system structure in your HOME directory on the CLS.
Most work will involve changes in your own Linux Virtual Machine running Centos 6.6. You can use the Checking Program to check your work as you go. You can check your work with the Checking Program as often as you like before you submit your final mark.
When you are finished, leave the files and directories in place on both the CLS and your own CentOS Virtual Machine as part of your deliverables. Do not delete any assignment work until after the term is over! Assignments may be re-marked at any time on the CLS; you must have your term work available on the CLS right until term end.
All course notes are available on the Internet and also on the CLS. You can learn about how to read and search these CLS files using the command line on the CLS under the heading Copies of the CST8207 course notes near the bottom of the page Course Linux Server.
Review course notes Booting and GRUB.
Use the on-line help (man
command) for the commands listed below for more information.
chkconfig
– display or change Run Level information and servicesgrub
– GRand Unified Bootloader (legacy version 0.9x - not the Version 2 GRUB numbered 1.9x). The man page is useless. See this instead: GRUB manualrunlevel
– display previous and current Run Leveltelinit
– change Run Levelsuname
– print system information: display system name, kernel release and version number, machine, processor, and O/S type/etc/inittab
– documentation on Run Levels; contains the default Run Level/boot/grub/grub.conf
– the GRUB Legacy (version 1) configuration fileParts of this lab must be done using root
user privileges (i.e. using sudo
).
If you start a root
subshell, your prompt will tell you if you are the root
user by changing to include a #
character instead of a $
character. You can also use the commands id
or whoami
to show your current userid.
Some answers require you to record command lines. Do not include the shell prompt with your command lines. Give only the part of the command line that you would type yourself.
Make sure you know the difference between a command line (which is what you type into the shell) and command output (which is what the command displays on your screen). Pay attention to whether the question asks you to record the command line or the command output.
I recommend that once you have booted your CentOS VM, you connect to it and work using a remote login session (e.g. ssh
or PuTTY
) where copy-and-paste works and where you can have multiple simultaneous connections into the VM. The VMware console is not friendly.
Note that SSH sessions (and whatever you are doing inside them) do not survive across a VMware suspend. Make sure you save your editor files and exit your SSH session before you pause or suspend your virtual machine. (Editor sessions inside the VMware console do survive across suspend and resume.) (Editor sessions that run inside the VMware console do survive across suspend and resume, since they don’t depend on a network connection.)
Advanced users may look into the various virtual terminal programs such as
tmux
andscreen
that do allow you to suspend and resume your sessions even from a remote login.
answer.txt
Where you are required to record or save a command line or its output into The Answer File, do the command and then copy and record the command line or its output as a separate line into an answer.txt
file in your CentOS Base Directory. You will be told how many lines to save in the file.
If you can’t answer a question, leave a blank line in this answer file. (The vim
option :set number
may be useful to you as you edit.)
You can use either nl
or cat -n
to show the contents of a file with line numbers, to make sure each answer is on its correct line number.
Warning: If you try to use appending redirection to write lines onto the end of this file, you can make a mistake and accidentally overwrite and erase the entire file. I recommend setting the shell option
set -o noclobber
to prevent overwriting the file.
You must have successfully completed the CentOS Install and Configure to do this assignment.
Create the CLS directory ~/CST8207-14F/Assignments/assignment13
on the Course Linux Server.
Create the same directory in your sysadmin account on your CentOS VM. This CentOS directory will be the base directory for this assignment.
This CentOS assignment13
directory is the base directory for all pathnames in this assignment. Store your files and answers in this CentOS base assignment13
directory.
Pay careful attention to whether you are working on the CLS or CentOS, and which account you are using! Watch the userid and hostname values in your
PS1
prompt string! All answer files in this assignment get stored in the CentOS base directory, not on the CLS.
Review Booting and GRUB.
You can select a different GRUB configuration file at boot time.
Record the number of lines in a standard Linux boot menu entry as Line 1 in The Answer File (one number).
myconfig
in its same grub
directory.
myconfig
file:
title
line of the first boot menu entry in the file, change the word CentOS
to MY OWN CentOS
myconfig
file.Compare the current GRUB configuration file with the new myconfig
GRUB configuration file. The new file should have two more words. A file difference using the diff
command should show the one line change, similar to this (your version number may differ):
$ diff grub.conf myconfig
14c14
< title CentOS (2.6.32-504.1.3.el6.i686)
---
> title MY OWN CentOS (2.6.32-504.1.3.el6.i686)
You can preview much of a GRUB configuration file from multi-user mode without having to reboot the system to test it, but you can’t actually select a new kernel until you reboot.
myconfig
GRUB configuration file in its correct partition.
(xxx,x)/xxxxx
GRUB can be run as a shell-like utility that has many built-in commands. Start the command-line GRUB utility by running the command named grub
as root
from your shell without rebooting the machine. When you run this grub
command you will see a grub>
prompt:
# grub
Probing devices to guess BIOS drives. This may take a long time.
GNU GRUB version 0.97 (640K lower / 3072K upper memory)
[ Minimal BASH-like line editing is supported. For the first word, TAB
lists possible command completions. Anywhere else TAB lists the possible
completions of a device/filename.]
grub>
The comments about TAB completion don’t apply to this command-line version of GRUB. (Sorry – this is a bug!) TAB only works when GRUB is run at boot time as the boot loader.
help
at thegrub>
prompt to see a partial list of GRUB utility commands. You can also type help commandname
to get a bit more help on commandname
^C
will also terminate this GRUB utility.)Note (and try) which GRUB command will display partitions on a disk:
grub> geometry (hd0)
drive 0x80: C/H/S = 261/255/63, The number of sectors = 4194304, /dev/sda
Partition num: 0, Filesystem type is ext2fs, partition type 0x83
Partition num: 1, Filesystem type unknown, partition type 0x82
grub> geometry (hd1)
drive 0x81: C/H/S = 130/255/63, The number of sectors = 2097152, /dev/sdb
Partition num: 0, Filesystem type is ext2fs, partition type 0x83
Partition num: 1, Filesystem type is ext2fs, partition type 0x83
Partition num: 3, Filesystem type is fat, partition type 0xc
Partition num: 4, Filesystem type unknown, partition type 0x82
Partition num: 5, Filesystem type unknown, partition type 0x7
GRUB is not very intelligent about the file systems inside partitions. Above, it mistakes both ext3
and ext4
file systems as type ext2fs
. (You can actually mount both ext3
and ext4
file systems as type ext2
and the journalling feature will be disabled. Don’t do it!)
Note (and try) which GRUB command displays (and sets) the current partition/device prefix, and which command displays a text file:
grub> cat /etc/hosts
Error 1: Invalid device requested
grub> root
(fd0): Filesystem type unknown, partition type 0x0
grub> root (hd0,0)
Filesystem type is ext2fs, partition type 0x83
grub> root
(hd0,0): Filesystem type is ext2fs, partition type 0x83
grub> cat /etc/hosts
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
127.0.0.2 abcd0001
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
myconfig
file name:
configfile
command you will need to specify both the partition and the pathname to the new GRUB configuration file you edited above.When you get the configfile
command and GRUB pathname to your myconfig
file right, you will see output similar to this (your version number may differ):
GNU GRUB version 0.97 (640K lower / 3072K upper memory)
-------------------------------------------------------------------
0: MY OWN CentOS (2.6.32-504.1.3.el6.i686)
1: CentOS 6 (2.6.32-504.el6.i686)
-------------------------------------------------------------------
Use the ^ and v keys to select which entry is highlighted.
Press enter to boot the selected OS, 'e' to edit the
commands before booting, 'a' to modify the kernel arguments
before booting, or 'c' for a command-line.
Ignore the information about which keys work – none of these keys work in this command-line version of GRUB. The keys only work after a reboot in the boot loader version of GRUB. We are only using GRUB in command-line mode to preview our GRUB menu to make sure it works.
MY OWN CentOS
menu, break out of (interrupt) the GRUB utility and return to the BASH shell prompt.
MY OWN CentOS
menu, edit and fix the myconfig
file until you do.MY OWN CentOS
menu entry, as shown above, you are ready to try your new file in the real GRUB boot process:
grub>
prompt.grub>
prompt, use the exact same configfile
line you used earlier to select your new myconfig
GRUB configuration file. (In this boot loader version of GRUB, TAB completion now works for both GRUB command names, disk names, partition names, and file names. Use TAB to help you type the correct GRUB command line.)MY OWN CentOS
menu entry, like this (your version number and the number of boot menu entries may differ):Run the Fetch and Checking Program to verify your work so far.
See the course notes on Legacy Run Levels and Services. As with most system maintenance activities, you will need to use the root
user to run the privileged commands in this section.
root
) sysadmin account.
Use a command to list all services and all run level information into file chkconfig-before.txt
in your CentOS assignment13
directory. It should be approximately 22 lines. Two of the lines should look like this:
ntpdate 0:off 1:off 2:off 3:off 4:off 5:off 6:off
postfix 0:off 1:off 2:on 3:on 4:on 5:on 6:off
Use the same command name to enable (turn on) the NTP Date service only in Run Level 4 (a normally unused Run Level in CentOS).
Use the same command name to disable (turn off) the above Postfix Mail Service service in Run Level 4.
Save a second listing of all services and all run levels into file chkconfig-after.txt
in your CentOS assignment13
directory. It should still be approximately 22 lines. Two of the lines should now look like this:
ntpdate 0:off 1:off 2:off 3:off 4:on 5:off 6:off
postfix 0:off 1:off 2:on 3:on 4:off 5:on 6:off
Use the diff
command to compare the before listing file with the after listing file. Only two lines should have changed.
postfix
.
postfix.txt
file.Record as Line 5 in The Answer File the Linux absolute pathname of the system configuration file that gives the default Run Level for your CentOS system.
Record as Line 6 in The Answer File the one line from the above system configuration file that sets the default Run Level for your CentOS system. (Hint: It’s the only non-comment line in the file!)
Use a command to confirm that your current Run Level is the same as the CentOS default Run Level. (This should be true unless you are running in single-user mode, which you should not be.)
udev
event manager will retrigger some events.ntpdate
service will try to synchronize the time, and fail.Use the command that displays the previous and current Run Level (two words on one line) and record this line of output as Line 7 in The Answer File.
ntpdate
service did not work:
ntpdate
talks about a socket being in use.ntpdate
log message as Line 9 in The Answer File.postfix
userid.
postfix
userid will be found. (You might see a process run by you, searching for postfix
.)udev
event manager will retrigger some events.Use the command that displays the previous and current Run Level (two words on one line) and record this line of output as Line 10 in The Answer File.
Confirm that the postfix
processes are again running.
Run the Fetch and Checking Program to verify your work so far.
See the section on Starting and Stopping Services in the Booting and GRUB page. As with most system maintenance activities, you will need to use the root
user to run the privileged commands in this section.
Make sure your system is running as the default CentOS Run Level.
postfix
service:
pid
of the service and say that the master
process is running.pid
) as Line 11 in The Answer File.postfix
service:
Shutting down postfix: [ OK ]
postfix
service:
master
service is stopped.postfix
service:
Starting postfix: [ OK ]
ntpdate
service:
[FAILED]
Run the Fetch and Checking Program to verify your work so far.
That is all the tasks you need to do.
Log in to the CLS and submit your mark from the CLS following the Checking Program instructions below.
Optional: Keeping your main configuration snapshots, remove any intermediate snapshots you no longer require, to free up disk space. - Be careful not to remove your current work!