Operate running systems Flashcards

1
Q

To reboot the system

A
# reboot
# systemctl reboot
# shutdown -r now
# init 6
#telinit 6
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

To shutdown the system

A
# halt
# systemctl halt
# shutdown -h now
# init 0
#telinit 0
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

To switch off the system

A
# poweroff
# systemctl poweroff
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

To suspend the system

A

systemctl suspend

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

To put the system into hibernation

A

systemctl hibernate

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

To put the system into hibernation and suspend it

A

systemctl hybrid-sleep

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

using systemd

A

systemctl rescue: to move to single user mode/maintenance level with mounted local file systems,
systemctl emergency: to move to single user mode/maintenance with only /root mounted file system,
systemctl isolate multi-user.target: to move to multi-user level without graphical interface (equivalent to previous run level 3),
systemctl isolate graphical.target: to move to multi-user level with graphical interface (equivalent to previous run level 5),
systemctl set-default graphical.target: to set the default run level to multi-user graphical mode,
systemctl get-default: to get the default run level.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

Interupt boot process

A

In RHEL 7, the procedure to get access to a system during the boot process and modify the root password has changed because of the adoption of systemd.

At the beginning of the boot process, at the GRUB 2 menu, type the e key to edit.

Then, go to the kernel line, remove the rhgb quiet options and add the following string at the end:
init=/bin/sh
Press Ctrl+x to resume the boot process.

When the shell prompt appears, load the SELinux policy:
# /usr/sbin/load_policy -i
Then, mount the / partition as read/write:
# mount -o remount,rw /
Change the root password:
# passwd
Changing password for user root.
Mount the / partition as read-only:
# mount -o remount,ro /
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

To get an instantaneous image of a server activity (use ‘virt-top‘ on a KVM hypervisor), type:

A

top

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

To get details about processes, type:

A

ps -edf

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

To start a process (here script.sh) with a low priority, type:

A

nice -n 10 ./script.sh

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

To change the priority (here +5) of an already running process, get its PID (Process ID) through top or ps (here 789) and type:

A

renice +5 789

alternatively
# renice +5 `pgrep script.sh`
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

To kill the process, get its PID through top or ps (here 789) and type:

A

kill -9 789

alternatively
# pkill script.sh
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

To display details about IO activities, type:

A

iostat

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

To show network card activities, type:

A

netstat -i

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

To display socket activities, type:

A

netstat -a

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
17
Q

To get details about virtual memory activities (memory, swap, run queue, cpu usage, etc) every 5 second, type:

A

vmstat 5

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
18
Q

To get a full report of a server activity, type:

A

sar -A

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
19
Q

ystemd primary task is to manage the boot process and provides informations about it.
To get the boot process duration, type:

A

systemd-analyze

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
20
Q

To get the time spent by each task during the boot process, type:

A

systemd-analyze blame

21
Q

In addition, Systemd handles the system event log, a syslog daemon is not mandatory any more.
To get the content of the Systemd journal, type:

A

journalctl

22
Q

To get all the events related to the crond process in the journal, type:

A

journalctl /sbin/crond

Note: You can replace /sbin/crond by which crond.

23
Q

To get all the events since the last boot, type:

A

journalctl -b

24
Q

To get all the events that appeared today in the journal, type:

A

journalctl –since=today

25
Q

To get all the events with a syslog priority of err, type:

A

journalctl -p err

26
Q

To get the 10 last events and wait for any new one (like tail -f /var/log/messages), type:

A

journalctl -f

27
Q

With KVM, to access the virtual machine’s console under X Window, type:

A

virt-manager

28
Q

if you aren’t under X Window, how to access the virtual machine’s console

A

If you aren’t under X Window, there is another way to access a virtual machine’s console: you can go through a serial console.

On the virtual machine, add ‘console=ttyS0‘ at the end of the kernel lines in the /boot/grub2/grub.cfg file:
# grubby --update-kernel=ALL --args="console=ttyS0"

Note: Alternatively, you can edit the /etc/default/grub file, add ‘console=ttyS0‘ to the GRUB_CMDLINE_LINUX variable and execute ‘# grub2-mkconfig -o /boot/grub2/grub.cfg‘.

Now, reboot the virtual machine:

29
Q

With KVM, connect to the virtual machine’s console (here vm.example.com):

A

virsh console vm.example.com

30
Q

Connect to the physical host and shut down your virtual machine

A

virsh destroy vm.example.com

31
Q

Define where the virtual machine image file is located (by default in the /var/lib/libvirt/images directory with a name like vm.example.com.img):

A

virsh dumpxml | grep “source file=”

32
Q

Map your virtual machine image file into the host environment (-a for add and -v for verbose):

A

kpartx -av /var/lib/libvirt/images/vm.example.com.img

From the previous display, you know that you’ve got two partitions (in fact /boot and /, distinguishable by their respective size).
You need to mount the /boot partition to be able to change the grub configuration:
# mount /dev/mapper/loop0p1 /mnt
Then, edit the /mnt/grub2/grub.cfg file and add ‘console=ttyS0‘ at the end of every line containing /vmlinuz (the linux kernel).
Unmount the partition:
# umount /mnt
Unmap the virtual machine image file (-d for delete and -v for verbose):
# kpartx -dv /var/lib/libvirt/images/vm.example.com.img
33
Q

Restart your virtual machine:

A

virsh start vm.example.com

34
Q

Connect to your virtual machine console:

A

virsh console vm.example.com

35
Q

Virsh VM commands

A
To start a virtual machine
# virsh start vm.example.com
To stop a virtual machine 
# virsh shutdown vm.example.com
To stop immediately a virtual machine 
# virsh destroy vm.example.com
To delete a virtual machine
# virsh undefine vm.example.com
To reboot a virtual machine
# virsh reboot vm.example.com
To display configuration information 
# virsh dominfo vm.example.com
To get the list of all the virtual machines, type:
# virsh list --all
36
Q

Start, stop, and check the status of network services.

A
To start a network service (here httpd), type:
# systemctl start httpd
To stop a network service (here httpd), type:
# systemctl stop httpd
To check if a network service (here httpd) is running, type:
# systemctl is-active httpd
To check the status of a network service (here httpd), type:
# systemctl status httpd
37
Q

Securely transfer files between systems.

A
To transfer the local file to a remote host 
# scp file root@centos:file

Note: By default, the file is put into the user’s home directory but it is possible to give a complete path.

To copy all the files from a specified directory, type:
# scp /etc/ssh/* root@centos:/tmp

Note: If directories appear in the list created by the *, there are not transferred: you get a “not a regular file” error (use the tar command to transfer directories).

38
Q

Transfer of a remote file

A
Locally, to transfer the file, type:
# scp root@centos:/tmp/rem rem
39
Q

init

A
  • init is the first process (PID 1)
  • All other processes are child process from init
  • /sbin/init
  • configuration files for init|upstart are in /etc/init
40
Q

/etc/rc.d/rcx.d

A

check which scripts are run in different run level. Replace x for 0 - 6

41
Q

Cancel schedule shutdown

A

shutdown -c

42
Q

top command options

A

use the h key while in top to see all the commands that you can use with it. The q key will quit top. To change the nice value while in top, press the r key, to renice a process, then enter the pid of a process, then the renice value we want the process to have

43
Q

nice value

A

Nice values range from negative 20 to 19 (-20,19) with negative 20 being the highest nice value and 19 being the lowest nice value. The nigher the number the less cpu time a process gets. The default value that a process get when it starts is zero

44
Q

XML configured files for KVM are stored in

A

/etc/libvirt/qemu/name-of-guest.xml

45
Q

hard disk files for KVM are stored in

A

/var/lib/libvirt/images

46
Q

view virtual guests processes

A

ps -aux | grep qemu

47
Q

/var/log/audit/audit.log

A
  • messages from selinux subsystems

- contains AVC(Access Vector Cache) messages

48
Q

Boot Process

A
  1. Bios initializes
  2. Bootloader is then called by the Bios
  3. Bootloader loads the first kernel image
  4. Kernel then mounts file systems and starts the appropriate system services.
  5. The system services finish starting up, and a login screen is presented