Tuesday, August 30, 2016

fdisk - Managing MBR Partitions


Managing Master Boot Record (MBR) Disk Partitions

The fdisk utility is used from the command line to view, create, or delete MBR partitions at the shell prompt. To use fdisk to create a new partition, first open a terminal session. Then, at the shell prompt, change to your root account by entering su – followed by your root user’s password.
At the shell prompt, enter fdisk device. For example, if you want to manage partitions on the first hard disk in your system, you would enter fdisk /dev/sda. At this point, you need to enter a command to tell fdisk what you want to do with the hard disk. 

You can enter at the command prompt to display a list of all available commands.

You can also display the partition table for a specified hard disk by entering fdisk device –l at the shell prompt. The output is similar to that shown here. 

In the next example, a new hard disk (/dev/sdb) has been installed in the system and fdisk is being used to create a partition:
openSUSE:~ # fdisk /dev/sdb
Welcome to fdisk (util-linux 2.23.2).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.
Device does not contain a recognized partition table
Building a new DOS disklabel with disk identifier 0x8239827b.
Command (m for help):

Notice that, because this is a new disk in the system, it has to be initialized with a disk label.
The fdisk utility takes care of this for you when you load the program. However, the change won’t
be applied until you write your changes to the disk.
With fdisk running, you have a Command: prompt that you can use to enter fdisk commands.
At this point, one of the best things you can do is to enter to view the fdisk help. When you
do, a list of commands is displayed that you can use to perform actions with fdisk, as shown in
this example:
Command (m for help): m
Command action
 a    toggle a bootable flag
 b    edit bad disklabel
 c    toggle the dos compatibility flag
 d    delete a partition
 g   create a new empty GPT partition table
 G   create an IRIX (SGI) partition table
 l   list known partition types
 m    print this menu 
 n    add a new partition
 o    create a new empty DOS partition table
 p    print the partition table
 q    quit without saving changes
 s    create a new empty Sun disk label 
 t    change a partition's system id 
 u    change display/entry units
 v    verify the partition table
 w    write table to disk and exit
 x    extra functionality (experts only)

Command (m for help):


CAUTION You can enter to delete an existing partition. Be very careful about using this action. Any data on that partition will be lost! Once the changes are committed to disk, they are not reversible. You can back off from changes made with fdisk without committing them to disk by entering q. With disk, is your friend!

Before creating a partition, you should enter to view any existing partitions on the disk. This
will help you determine whether there is sufficient space and, if there is, what number must be
assigned to a new partition created on the disk.
To create a new partition, you enter n. You can then specify whether you want to create a
primary disk partition or an extended disk partition. Any hard disk in your system can have up to
four partitions defined in its partition table. These can be either primary or extended partitions. If
you intend to create four partitions or fewer, you can simply use primary partitions.
However, if you want to create more than four partitions on the disk, you must create at least
one extended partition. Extended partitions are great. Within one extended partition, you can
create many logical partitions. This allows you to get around the four-partition limitation. The
general rule of thumb is to create your primary partitions first; then create your extended partition
using the remaining space on the drive and create your logical partitions within it.
To create a primary partition, enter when prompted. To create an extended partition, enter e.
You are then prompted to specify a partition number, as shown in this example:
Command (m for help): n
Partition type:
   p   primary (0 primary, 0 extended, 4 free)
   e   extended
Select (default p): p
Partition number (1-4, default 1): 1

You need to specify the next available partition number for the partition being created. In
other words, if your disk already has two partitions on it, you would enter 3. In the preceding
example, no partitions currently exist on the drive, so I’ve entered to create the first primary
partition. If you try to enter a partition number that has already being used by an existing parti-
tion, the fdisk utility will complain!
At this point, you must specify the size of the partition. This is done by specifying the beginning and ending cylinders. You first specify the cylinder on which you want to begin the partition.
By default, fdisk displays the next available cylinder. If you don’t have any partitions on the disk,
this will be cylinder 1. If you already have partitions on the disk, the next unused cylinder will be
listed. After specifying your start cylinder, you have several options for specifying the overall size
of the partition, as shown here:
Partition number (1-4, default 1): 1
First sector (2048-2097151, default 2048): 2048
Last sector, +sectors or +size{K,M,G} (2048-2097151, default 2097151):
2097151
Partition 1 of type Linux and of size 1023 MiB is set

You can

• Enter the last cylinder to be used in the partition.
• Specify the size of the partition in gigabytes by entering sizeG. For example, you could
create an 800GB partition by entering 800G.
After specifying the size, you should verify your new partition by entering p. This will display
all partitions for the disk, as shown in the next example:
Command (m for help): p
Disk /dev/sdb: 1073 MB, 1073741824 bytes, 2097152 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk label type: dos
Disk identifier: 0xd489eb71
   Device Boot      Start         End      Blocks   Id  System
/dev/sdb1            2048     2097151     1047552   83  Linux
Command (m for help):


It’s important to note that, at this point, the partition hasn’t been written to disk. All changes
are saved in memory before being committed to disk. This allows you to tweak your partitions
before actually committing the changes.
Before committing the partition to disk, however, you may need to change the partition type.
Notice in the preceding example that the partition being created is a standard Linux partition by default. Usually, this is sufficient. However, suppose you were creating a swap partition. You would need to use a different type of partition. This is done by entering and then entering the
ID of the partition type you want to change to. If you don’t know the ID number of the partition
type you want to use, you can enter (lowercase L) to list all the valid partition types and their
associated ID numbers, as shown here:


Command (m for help): l
0  Empty
1  FAT12
2  XENIX root
3  XENIX usr
4  FAT16 <32M
5  Extended
6  FAT16
7  HPFS/NTFS/exFAT 4d  QNX4.x          88  Linux plaintext de  Dell Utility
24  NEC DOS         81  Minix / old Lin bf  Solaris
27  Hidden NTFS Win 
82  Linux swap / So 
c1  DRDOS/sec
39  Plan 9        
83  Linux           
c4  DRDOS/sec
3c  PartitionMagic  84  OS/2 hidden C:  c6  DRDOS/sec
40  Venix 80286     85  Linux extended  c7  Syrinx
41  PPC PReP Boot   86  NTFS volume set da  Non-FS data
42  SFS             87  NTFS volume set db  CP/M / CTOS
8  AIX             4e  QNX4.x 2nd part 8e  Linux LVM
9  AIX bootable    4f  QNX4.x 3rd part 93  Amoeba
a  OS/2 Boot Manag 50  OnTrack DM      94  Amoeba BBT
b  W95 FAT32       51  OnTrack DM6 Aux 9f  BSD/OS
df  BootIt
e1  DOS access
e3  DOS R/O
e4  SpeedStor
c  W95 FAT32 (LBA) 52  CP/M            a0  IBM Thinkpad hi eb  BeOS fs
e  W95 FAT16 (LBA) 53  OnTrack DM6 Aux a5  FreeBSD
ee GPT
ef EFI (FAT-12/16)
f0 Linux/PA-RISC
f1 SpeedStor
f W95 Ext'd (LBA)
10 OPUS
11 Hidden FAT12
54 OnTrackDM6
55 EZ-Drive
56 Golden Bow
a6 OpenBSD
a7 NeXTSTEP
a8 Darwin UFS
12 Compaq diagnost 5c Priam Edisk a9 NetBSD
14 Hidden FAT16 <3 61 SpeedStor ab Darwin boot
16 Hidden FAT16 63 GNU HURD or Sys af HFS / HFS+
17 Hidden HPFS/NTF 64 Novell Netware b7 BSDI fs
18 AST SmartSleep 65 Novell Netware b8 BSDI swap
1b Hidden W95 FAT3 70 DiskSecure Mult bb Boot Wizard hid fe LANstep
1c Hidden W95 FAT3 75 PC/IX be Solaris boot ff BBT
1e Hidden W95 FAT1 80 Old Minix
f4 SpeedStor
f2 DOS secondary
fb VMware VMFS
fc VMware VMKCORE
fd Linux raid auto
For example, the ID for a Linux swap partition is 82. To change the type of the partition, you could
enter and specify a partition ID of 82 if you wanted to change the partition to a swap partition.
You can also delete partitions using fdisk. To do this, enter at the command prompt and then
specify the partition number you want to delete. Remember, any data that resides on this partition
will be lost once you commit the change to disk!
At this point, you’re ready to commit your partition to disk. If you’re unhappy with the parti-
tioning proposal, you can always enter to quit without applying the changes. If you are happy,
however, you can apply your changes by entering w. This will commit the partition to disk and
exit fdisk, as shown in this example:
Command (m for help): w
The partition table has been altered!
Calling ioctl() to re-read partition table.
Syncing disks.
openSUSE:~ #
It’s important to note here that you must reboot the system before the Linux kernel will
recognize the partition changes you made with fdisk. However, you can also use the partprobe
command at the shell prompt to force the kernel to recognize the new partition table without
rebooting. The syntax is partprobe –s. The –s option causes the partprobe command to show a
summary of devices and their partitions, as shown in this example:
openSUSE:~ # partprobe –s
/dev/sda: msdos partitions 1 2 3
/dev/sdb: msdos partitions 1
openSUSE:~ #
Now that you know how to manage partitions with fdisk, let’s look at creating GUID partitions.

gdisk - Manage GPT Partitions

Enter gdisk /dev/sdb at the shell prompt. If you’re comfortable using fdisk, then the process of using gdisk will be a snap for you because many of the commands are the same. At the gdisk prompt, you can enter to view a list of commands available. This is shown in the following example: 
openSUSE:~ # gdisk /dev/sdb
GPT fdisk (gdisk) version 0.8.7
Partition table scan:
  MBR: not present
  BSD: not present
  APM: not present
  GPT: not present
Creating new GPT entries.
Command (? for help): ?
. b        back up GPT data to a file
.
. c        change a partition's name
.
. d        delete a partition
.
i       show detailed information on a partition
l       list known partition types
. n        add a new partition
.
. o        create a new empty GUID partition table (GPT)
.
. p        print the partition table
.
. q        quit without saving changes
.
. r        recovery and transformation options (experts only)
.
. s        sort partitions
.
. t        change a partition's type code
.
. v  verify disk 
. w        write table to disk and exit
.
. x        extra functionality (experts only)
.
?       print this menu
Command (? for help):
In this situation, I want to add a new partition to the disk, so I would enter at the gdisk prompt. When I do, I’m prompted to specify the following: 
The partition number 
The size of the partition This can be done by specifying the beginning and ending sectors of the partition. You can also specify where on the disk you want the partition to start and end (such as at the 10GB and 20GB points on the disk). 
The type of partition The partition type numbers with gdisk are different from those used with MBR partitions. For example, to create a Linux partition, you use a partition type of 8300. You can press at the gdisk prompt to view a list of all possible partition types and their codes.
This process is shown in the following example: 
Command (? for help): p
Disk /dev/sdb: 33554432 sectors, 16.0 GiB
Logical sector size: 512 bytes
Disk identifier (GUID): 1D3E9F48-D822-4DDF-AB94-C59B7A4E12C8
Partition table holds up to 128 entries
First usable sector is 34, last usable sector is 33554398
Partitions will be aligned on 2048-sector boundaries
Total free space is 12582845 sectors (6.0 GiB)
Number  Start (sector)    End (sector)  Size       Code  Name
   1            2048        20973567   10.0 GiB    8300  Linux filesystem
Command (? for help): w
Final checks complete. About to write GPT data. THIS WILL OVERWRITE EXISTING
PARTITIONS!!
Do you want to proceed? (Y/N): y
OK; writing new GUID partition table (GPT) to /dev/sdb.
The operation has completed successfully.
Once this is done, you can enter at the gdisk prompt to view a list of the partitions on the disk. As with fdisk, the changes you make with gdisk are not actually committed to disk until you write them. If you like the changes you made to the disk partitioning, press at the gdisk prompt. If you want to delete a partition, press d. If you want to change a partition’s type, press and then enter the partition type code you want to use. If you want to quit and start over without saving any changes, press instead. 

parted - Manage GPT Partitions

In addition to gdisk, you can also use the parted command at the shell prompt to manage GPT partitions. You can use it to add, delete, and edit the partitions on your disk. 
Unlike gdisk and fdisk, the parted command writes the partition changes you specify immediately to the disk. Be absolutely certain of the changes you want to make before using parted! 
To use parted, enter parted at the shell prompt and then use the select command to specify which disk you want to manage. Be very careful, because if you don’t manually specify a disk to manage, parted will automatically select your first hard disk for you—you know, the one with your system partitions and your home partition on it? Accidentally deleting a partition on this disk could be bad! If you intend to work on a disk other than /dev/sda, be sure you use the select command. 
After selecting the appropriate hard disk, you can create a new partition using the mkpart command at the parted prompt. You need to specify the following: 
• The type of partition to be created For example, to create a standard Linux partition, you would specify a value of linux
• The starting point on the disk for the partition (in megabytes) For example, to create a partition that starts at the 1GB point on the disk, you would specify a value of 1024
• The ending point on the disk for the partition (in megabytes) For example, to create a partition that ends at the 11GB point on the disk, you would specify a value of 11264
To view the partitions that have been created on the disk, you can use the print command at the parted prompt. In the following example, a 10GB partition is created on the second hard disk in the system (/dev/sdb): 
openSUSE:~ # parted
GNU Parted 2.4
Using /dev/sda
Welcome to GNU Parted! Type 'help' to view a list of commands.
(parted) select /dev/sdb
Using /dev/sdb
(parted) mkpart linux 1024 11264
(parted) print
Model: VMware Virtual disk (scsi)
Disk /dev/sdb: 17.2GB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Number  Start   End     Size    File system  Name   Flags
 1      1024MB  11.3GB  10.2GB               linux
(parted) 
You can also use the following commands at the parted prompt to manage disk partitions: 
To rename a partition, enter name partition name
To move a partition to a different location on the disk (which is a very handy thing to be able to do), enter move partition start_point end_point
To resize a partition on the disk (another very handy thing to be able to do), enter resize partition start_point end_point
To delete a partition from the disk, enter rm partition.

Monday, August 29, 2016

LVM

LVM Components:

Create in this order:
  • physical volumes
  • volume groups
  • logical volumes

Physical Volumes:
  • pvcreate <device>
  • pvscan -v
Volume Groups:
  •  vgcreate <volume_group_name> <physical_volume1><physical_volume2> ...
  • pvscan -v
Additional volume group commands:
  • vgexpand: add additional physical volumes to volume group
  • vgreduce: remove physical volume. Run pvmove first to move data to another physical volume
  • vgremove: delete volume group first, remove all logical volumes

Creating Logical Volumes:
  •  lvcreate -L <volume_size> -n <volume_name> <volume_group_name>
  • -->lvcreate -L 7G -n research Data

Additional logical volume management commands:
  • lvextend: increase size of logical volume. you must first add additional physical volume(s)
  • lvreduce: reduce size of logical volume
  • lvremove: remove logical volume. Use caution when using lvremove, you could chop off data  

mount and umount

Mount

mount -t <file_system_type> <device> <mount_point>

mount -t ext4 /dev/sdb1 /mnt/extraspace

If you don't know the file system type use -a instead of -t:

mount -a /dev/sdb1 /mnt/extraspace

Use -o with mount to include options:

mount -t ext4 -o ro /dev/sdb1 /mnt/extraspace

Mount ISO image:

mount -t loop <filename.iso> <mount_point>

Mount Optical Drive:

mount -t iso9660 <device> <mount_point>

Mount USB or FireWire:

mount -t auto <device> <mount_point>

Unmount a Device:

umount <device> | <mount_point>

mkswap

mkswap

type 82

Creating and enabling swap partition:
  • mkswap <device>
  • swapon <device>

Disabling swap partition:
  • swapoff <device>

To activate swap partitions at once:
  •  swapon -a

Deactivate all currently enabled swap partitions:
  • swapoff -a

mkfs

mkfs is a front-end for real commands that make each file type filesystem

i.e.

/sbin/mkfs.ext4
/sbin/mkfs.nfs

...

syntax:

mkfs -t ext4 /dev/sdb1

options:

-b: blocksize
-N <inodes>: number of inodes
-i <bytes per inode>: sets size of inode
-j: creates a journal of file system

Reiser:

mkfs -t reiserfs <device> OR

mkreiserfs <device>

Does distribution support  xfs file type?

find / -name mkfs*

mkfs -t xfs <device>

vfat:

mkfs -t vfat <device>

GUID Partitions (Globally Unique Idenitifier Partiitions)

  • no primary, extended or logical partions
  • supports gigantic disk and partion sizes
  • 128 GPT (GUID Partition Table) partitions per disk
  • fault tolerance - stores copy of partition table on first and last sectors of disk
  • GPT provides cyclical redundancy checks (CRC) of partion table
  • GPT assigns unique ids to each disk and partition
  • utility called gdisk 
  • -->convert MBR partition table to GPT partition table
  • -->gdisk /dev/sda
  • ------>many of the same commands are the same as fdisk
  • ------>type of partition enter: linux
  • ------>delete partition
  • ------------>rm <partition>

fdisk

fdisk /dev/sda
m: print menu
n: new partition
  • p: primary
  • e: extended
  • -->1: partition number
  • -->first sector
  • -->last sector
  • ---->sizeG|K|M
  • p: verify - print partition
  • (type 83 is the default)
  • t: type
  • -->l: list available types
  • w: write - commit changes
Run partprobe -s 

partprobe forces Linux to recognize new partition without rebooting

Exercise 11-4: Establishing Disk Quotas

In order of operation:

STARTS with QUOTA:

quotacheck -amvug
quotaon -av


ENDS WITH QUOTA:

repquota -av

edquota -u|-g|-t <>



etc/fstab
  1. usrquota,grpquota
  2. (or usrjquota=aquota.user,grpjquota=aquota.grp,jqfmt=vfsv0)

quotacheck –amvug
Created files after running quota check -amvug
  1. aquota.user
  2. aquota.groups

Turn quotas on
  1. quotaon –av

Report on quotas
  1. repquota –av

Create disk quota for user
  1. edquota –u student.


Complete the following: 
1. Verify that you are logged in to your system.
2. If necessary, switch to your root user account with the su – command and a password of student.
3. Configure your mounted file systems to use quotas by doing the following: 
a. Open your /etc/fstab file in a text editor.
b. Add the usrquota and grpquota parameters to the mount options for the / file system.
c. Save your changes to the file and exit the editor.
d. Restart your system so that the changes can take effect.
4. After the system has rebooted, create your quota files by doing the following: 
a. Open a terminal session and switch to your root user account using the su
command.
b. At the shell prompt, enter quotacheck –amvug.
5. When quotacheck is complete, two files named aquota.user and aquota.groups should have been created in /.
6. Enable quotas on your file system by entering quotaon –av at the shell prompt.
7. View the current disk space used by your users by entering repquota –av at the shell prompt. A report is displayed on the screen showing how much space each user is consuming. Notice that no limits have been configured for any users.
8. Create disk quotas for your users by doing the following: 
a. At the shell prompt, enter edquota –u student.
b. Use the vi editor to set the following:
Block hard quota: 15000 Block soft quota: 10000 Inode hard quota: 1000 Inode soft quota: 800
c. Save your changes and exit the editor.
d. Repeat this process for the rest of your users.
9. Check your new quotas by entering repquota –av at the shell prompt. You should now see quotas established for your users.
10. Enter exit to leave the root user account.
11. Verify that you are logged in as a user account that quotas have been set for.

12. Create a big file by entering time dd if=/dev/zero of=bigfile.bin bs=1024 count=10000 at the shell prompt. You should see an error indicating the quota has been exceeded.

Administering Disk Quotas

 Disk quotas are a valuable management tool when you’re administering a Linux system. The problem here is that, because Linux is a multiuser system, it’s possible for one or two users to completely monopolize all the disk space available in the file system. This is especially a problem in today’s networked world where users are downloading large music files and even larger movie files from the Internet. How do you keep these users from consuming more than their fair share of disk space? You use disk quotas. 
Put simply, disk quotas establish space limitations for users on the system. You can specify that users are each allowed only a certain amount of disk space or inodes (a quota). Users are not allowed to exceed this quota. 
To implement quotas on your Linux file system, you first need to install the quota package on your system. Some distributions, especially server distributions, install this package as part of the base installation. Most distributions, however, will require you to install it separately after the system has been set up. To see if quota is already installed on your system, enter rpm –qi quota at the shell prompt. If it isn’t installed, use rpm or another appropriate package management utility to install it. 
Once the package has been installed, complete the following to establish quotas: 
1. Open a terminal session and change to your root user account with su.
2. Configure your mounted file systems to use quotas by doing the following: 
a. Open your /etc/fstab file in a text editor.
b. Add the usrquota and grpquota (or usrjquota=aquota.user,grpjquota=aquota.grp,jqfmt=vfsv0) parameters to the mount options for the file system you want to establish quotas on. In the example that follows, quotas have been established for the / file system:

c. Save your changes to the file and exit the editor.

d. Restart your system so that the changes can take effect. 
3. After the system has rebooted, create your quota files by doing the following: 
a. Open a terminal session and switch to your root user account with su.
b. At the shell prompt, enter quotacheck –amvug. 

4. Enable quotas on your file system by entering quotaon –av at the shell prompt. 
5. View the current disk space used by your users by entering repquota –av at the shell prompt. A report is displayed on the screen showing how much space each user is consuming, as shown here:

Notice in this report that no limits have been configured for any users. 
6. Create disk quotas for your users by doing the following: 
a. At the shell prompt, enter edquota –u username. A screen similar to that shown next for the rtracy user is displayed: 

7. Create disk quotas for your groups by doing the following: 
a. At the shell prompt, enter edquota –g groupname.
b. Use the vi editor to set block and/or inode soft and hard quotas.
c. Save your changes and exit the editor.
8. In the preceding steps, you created soft quotas for blocks and/or inodes. The default value is to allow users to exceed their soft quotas for a maximum of seven days. This is the grace period. You can change this by doing the following:

  1. At the shell prompt, enter edquota –t. The following is displayed: 
b. Edit your grace period settings.
c. Save your changes and exit vi.
9. Check your new quotas by entering repquota –av at the shell prompt. You should now see quotas established for your users. In the example that follows, quotas have been established for the rtracy user: 







Sunday, August 28, 2016

Shutting Down System

You can use several commands to properly shut down a Linux system, including the following: 

init 0: Switches the system to runlevel 0, which halts the system 
init 6: Switches the system to runlevel 6, which reboots the system 
halt:  Shuts down the system  
reboot:  Reboots the system 

In addition to these commands, you can also use the shutdown command to either shut down or reboot the system. It has several key advantages over the preceding commands: 
You can specify that the system go down after a specified period of time. This gives your users time to save their work and log out before the system goes down. It also allows you to shut down the system at a specified time even if you’re not there to do it.
It allows you to send a message to all logged-in users warning them that a shutdown is pending.
It does not allow other users to log in before the pending shutdown.
The syntax for using shutdown is shutdown +m –h|–r message. The +m option specifies the amount of time (in minutes) before shutting down the system. You can also use the now option instead of +m to specify that the system go down immediately. If you need the system to go down at a specific time, you can replace +m with the time (entered as hh:mm) when the shutdown should occur. The –h option specifies that the system be halted, whereas the –r option specifies that the system be rebooted. Some examples of using shutdown are shown here:
shutdown +10 –h Please save your work and log out.

When you enter this command, all other logged-in users see the following message:
tux@ws1:~/Desktop>
Broadcast message from root@ws1 (pts/3) (Thu Feb 17 10:29:59 2011):

Please save your work and log out.
The system is going DOWN for system halt in 10 minutes!

If you’ve scheduled a shutdown using the shutdown command and later need to cancel that shutdown, enter shutdown –c at the shell prompt.
You can also use the wall command to send messages to users to inform them of system events, such as a system reboot or a runlevel change. To use wall, you must send the message to the stdin of the wall command. An example is shown here: 
openSUSE:~ # echo "The system is going down for a reboot." | wall
Broadcast Message from rtracy@openSUSE
        (/dev/pts/1) at 16:26 ...

The system is going down for a reboot.

Exercise 6-4: Working with Linux Runlevels

. Complete the following:
1. Boot your Linux system and log in as your student user using a password of student.
2. Open a terminal session.
3. Switch to your root user account by entering su – followed by your root user’s password (student).
4. Change your default boot target to the equivalent of runlevel 3 by doing the following: 
a. Open a terminal session.
b. At the shell prompt, change to your root user account using the su – command.
c. At the shell prompt, enter systemctl set-default multi-user.target.
d. Reboot your system by entering init 6 at the shell prompt.
Notice that this command still works even though the system doesn’t use the init daemon. Your system should boot into a text-based login shell.
e. Log in as your root user.
f. At the shell prompt, use the systemctl command to change the default boot target back to graphical.
g. Power off the system by entering init 0 at the shell prompt. Again, notice that the command works even though the system doesn’t use the init daemon.
h. Power the system back on and log back in to your system as a normal user.
5. Practice enabling the ntp daemon at system boot. Complete the following: 
a. Open a terminal session and change to your root user account.
b. At the shell prompt, enter vi /etc/ntp.conf.
c. Scroll down to the lines that read
server 127.127.1.0 #local clock (LCL)
        fudge      127.127.1.0 stratum 10 #LCL is unsynchronized
d Press insert.
e Add a new line below the fudge line.
f. Add the following directive on the new line: server bigben.cac.washington.edu
This directive configures the ntp service to synchronize your local computer time with the time on the bigben.cac.washington.edu public ntp server on the Internet.
g. Press esc; then enter :exit.
h. Start the ntp service by entering systemctl start ntp.service at the shell prompt.

i Check the status of the ntp daemon by entering systemctl status ntp.service at the shell prompt.

Managing Services

You manage system daemons on a system using systemd in much the same manner that you do on a system that uses init. However, the command used is different. If you need to stop, start, restart, or view the status of a particular service on the system, you enter systemctl followed by the action you want performed, followed by the service name. Use the following syntax:

  •  To start a service, enter systemctl start service.service. For example, to start the ntp daemon, you would enter systemctl start ntp.service
  • To stop a service, enter systemctl stop service.service. For example, to stop the ntp daemon, you would enter systemctl stop ntp.service
  •  To restart a service, enter systemctl restart service.service. For example, to restart the ntp daemon, you would enter systemctl restart ntp.service
  •  To check the status of a service, enter systemctl status service.service. For example, to check the status of the ntp daemon, you would enter systemctl status ntp.service

On System Boot:

 You can also use the systemctl command to enable or disable a particular service on system boot. You can also check see whether or not it has been enabled. To do this, you use the following commands:

  •  To enable a service on system start, enter systemctl enable service.service. For example, to enable the ntp daemon on system boot, you would enter systemctl enable ntp.service.
  •  To disable a service on system start, enter systemctl disable service.service. For example, to disable the ntp daemon on system boot, you would enter systemctl disable ntp .service.
  •  To check and see whether a service is enabled or not on system startup, enter systemctl is-enabled service.service. For example, to check the status of the ntp daemon, you would enter systemctl is-enabled ntp.service.