Compare commits

...

5 Commits

6 changed files with 213 additions and 19 deletions

2
.gitignore vendored
View File

@ -1,5 +1,5 @@
bin/ bin/
data/
include/ include/
lib/ lib/
__pycache__ __pycache__
*.swp

View File

@ -1,8 +1,10 @@
import pathlib import pathlib
import time import time
import uuid
import os import os
import csv import csv
import random import random
import json
from rich.console import Console from rich.console import Console
from rich.markdown import Markdown from rich.markdown import Markdown
@ -12,9 +14,14 @@ ANSWER = "ANSWER"
class Question(object): class Question(object):
"""class to hold the question data and methods""" """
class to hold the question data and methods
TODO: needs to json methods for the REST API
"""
def __init__(self, data): def __init__(self, data):
self._data = data self._data = data
self._uuid = uuid.uuid1()
self._clean_data() self._clean_data()
def _clean_data(self): def _clean_data(self):
@ -24,21 +31,51 @@ class Question(object):
self._level = self._data[LEVEL].strip() self._level = self._data[LEVEL].strip()
self._question = self._data[QUESTION].strip() self._question = self._data[QUESTION].strip()
self._answers = self._data[ANSWER].strip().split(" ") self._answers = self._data[ANSWER].strip().split(" ")
self._answers = [x for x in self._answers if x]
self._create_list_of_possibilities()
def dump_json(self):
"""
dumps all data to JSON for the REST API
"""
data = {
"UUID": self.get_uuid(),
QUESTION: self.get_question(),
ANSWER: self.get_right_answers(),
"POSSIBILITIES": self.get_possibilities(),
}
return json.dumps(data)
def get_uuid(self):
return str(self._uuid)
def get_question(self): def get_question(self):
return self._question return self._question
def get_possibilities(self): def _create_list_of_possibilities(self):
"""returns a list of all the possible answers""" """creates and cleans a list of all the possible answers"""
possibilities = [] possibilities = []
for key in self._data.keys(): for key in self._data.keys():
if key.isnumeric(): if key.isnumeric():
possibilities.append(self._data[key]) possibilities.append(self._data[key])
return possibilities possibilities = [x for x in possibilities if x] # hack to remove empty objects
self._possibilities = possibilities
def verify(self, answer): def get_possibilities(self):
return self._possibilities
def verify(self, answers):
"""needs quite some work""" """needs quite some work"""
if answer in self._data[ANSWER]: if not isinstance(answers, list):
raise TypeError
right_answers = list(self._answers) # need a copy so we don't change for future questions
for answer in answers:
try:
test = right_answers.index(answer)
right_answers.pop(test)
except:
return False
if len(right_answers) == 0:
return True return True
else: else:
return False return False
@ -55,6 +92,7 @@ class Question(object):
class Database(object): class Database(object):
"""holds all the Question objects and methods to get new questions""" """holds all the Question objects and methods to get new questions"""
def __init__(self, filepath): def __init__(self, filepath):
self.filepath = filepath self.filepath = filepath
self._db = [] self._db = []
@ -68,6 +106,15 @@ class Database(object):
def get_question(self): def get_question(self):
return random.choice(self._db) return random.choice(self._db)
def get_question_by_uuid(self, uuid):
question = [question for question in self._db if question.get_uuid() == uuid]
if len(question) == 1:
return question[0]
elif len(question) > 1:
raise Exception
else:
return None
class Game(object): class Game(object):
def __init__(self): def __init__(self):
@ -83,6 +130,18 @@ class Game(object):
return (right, wrong, total) return (right, wrong, total)
if __name__ == "__main__": class Player(object):
"""TODO placeholder for the player class"""
pass pass
if __name__ == "__main__":
filepath = pathlib.Path("../data/list_book1.csv")
db = Database(filepath)
for i in range(0, 10):
q = db.get_question()
uid = q.get_uuid()
print(uid)
t = db.get_question_by_uuid(uid)
print(t.get_uuid())

View File

@ -71,7 +71,7 @@
"010-160",1,"What is the purpose of the system account with a UID of 0?","It's the system administration account.","It's the account for the first ordinary user.","Nothing. UID 0 is left intentionally undefined.","It varies from one distribution to another.","It's a low-privilege account that's used as a default by some servers." "010-160",1,"What is the purpose of the system account with a UID of 0?","It's the system administration account.","It's the account for the first ordinary user.","Nothing. UID 0 is left intentionally undefined.","It varies from one distribution to another.","It's a low-privilege account that's used as a default by some servers."
"010-160",,"What type of information will you find in `/etc/passwd` for ordinary user accounts? (Select all that apply.)","A user ID (UID) number","A complete listing of every group to which the user belongs","The path to the account's home directory","The path to the account's default GUI desktop environment","The path to the account's default text-mode shell" "010-160",,"What type of information will you find in `/etc/passwd` for ordinary user accounts? (Select all that apply.)","A user ID (UID) number","A complete listing of every group to which the user belongs","The path to the account's home directory","The path to the account's default GUI desktop environment","The path to the account's default text-mode shell"
"010-160",1,"You want to run the command `iptables -L` as `root` but you're logged in as an ordinary user. Which of the following commands will do the job assuming the system is configured to give you `root` access via the appropriate command?","`sudo iptables -L`","`root iptables -L`","`passwd iptables -L`","`su iptables -L`","`admin iptables -L`" "010-160",1,"You want to run the command `iptables -L` as `root` but you're logged in as an ordinary user. Which of the following commands will do the job assuming the system is configured to give you `root` access via the appropriate command?","`sudo iptables -L`","`root iptables -L`","`passwd iptables -L`","`su iptables -L`","`admin iptables -L`"
"010-160",,"True or false: `whoami` provides more information than `id`.","True","False",,, "010-160",2,"True or false: `whoami` provides more information than `id`.","True","False",,,
"010-160",,"True or false: Linux stores information on its groups in the `/etc/groups` file.","True","False",,, "010-160",,"True or false: Linux stores information on its groups in the `/etc/groups` file.","True","False",,,
"010-160",2,"True or false: As a general rule you should employ extra care when running programs as `root`.","True","False",,, "010-160",2,"True or false: As a general rule you should employ extra care when running programs as `root`.","True","False",,,
"010-160",,"What would a Linux system administrator type to remove the `nemo` account and its home directory","`userdel nemo`","`userdel -f nemo`","`userdel -r nemo`","`rm /home/nemo`","`rm -r /home/nemo`" "010-160",,"What would a Linux system administrator type to remove the `nemo` account and its home directory","`userdel nemo`","`userdel -f nemo`","`userdel -r nemo`","`rm /home/nemo`","`rm -r /home/nemo`"

1 LEVEL ANSWER QUESTION 1 2 3 4 5
71 010-160 1 What is the purpose of the system account with a UID of 0? It's the system administration account. It's the account for the first ordinary user. Nothing. UID 0 is left intentionally undefined. It varies from one distribution to another. It's a low-privilege account that's used as a default by some servers.
72 010-160 What type of information will you find in `/etc/passwd` for ordinary user accounts? (Select all that apply.) A user ID (UID) number A complete listing of every group to which the user belongs The path to the account's home directory The path to the account's default GUI desktop environment The path to the account's default text-mode shell
73 010-160 1 You want to run the command `iptables -L` as `root` but you're logged in as an ordinary user. Which of the following commands will do the job assuming the system is configured to give you `root` access via the appropriate command? `sudo iptables -L` `root iptables -L` `passwd iptables -L` `su iptables -L` `admin iptables -L`
74 010-160 2 True or false: `whoami` provides more information than `id`. True False
75 010-160 True or false: Linux stores information on its groups in the `/etc/groups` file. True False
76 010-160 2 True or false: As a general rule you should employ extra care when running programs as `root`. True False
77 010-160 What would a Linux system administrator type to remove the `nemo` account and its home directory `userdel nemo` `userdel -f nemo` `userdel -r nemo` `rm /home/nemo` `rm -r /home/nemo`

89
data/lpic1_chap1.csv Normal file
View File

@ -0,0 +1,89 @@
"LEVEL","ANSWER","QUESTION",1,2,3,4,5
"101-500",,"Which of the following commands is used to view kernel-related udev events in real time?","udevis all","lsudev -f","udevmon -a","udevadm monitor",
"101-500",,"Which command enables you to view the current interrupt request (IRQ) assignments?","view /proc/irq","cat /proc/interrupts","cat /dev/irg","less /dev/irg",
"101-500",,"Configuration of udev devices is done by working with files in which directory?","/udev/devices","/devices/","/udev/config","/etc/udev",
"101-500",,"Which command is used to automatically load a module and its dependencies?","modprobe","lsmod","insmod","rmmod",
"101-500",,"Which command is used to obtain a list of USB devices?","usb-list","lsusb","1s -usb","1s --usb",
"101-500",,"When working with hotplug devices, you need to gather more information about them through udevadm. Which udevadm command enables you to query the udev database for information on a device?","query","info","getinfo","devinfo",
"101-500",,"Which command can be used to view the kernel ring buffer in order to troubleshoot the boot process?","lsboot","boot-log","krblog","dmesg",
"101-500",,"During the initialization process for a Linux system using SysV init, which runlevel corresponds to single-user mode?","Runlevel 5","Runlevel SU","Runlevel 1","Runlevel 6",
"101-500",,"On a system using SysV init, in which directory are the startup and shutdown scripts for services stored?","/etc/init-d","/etc/init","/etc/sysV","/etc/init.d",
"101-500",,"Which command can be used to reboot a system?","init 6","shutdown -h -t now","init 1","refresh-system",
"101-500",,"When using an SysV init-based system, which command would you use if you make changes to the /etc/inittab file and want those changes to be reloaded without a reboot?","init-refresh","init 6","telinit","reload-inittab",
"101-500",,"Which command displays the current runlevel for a system?","show-level","init --level","sudo init","runlevel",
"101-500",,"Within which folder are systemd unit configuration files stored?","/etc/system.conf.d","/lib/system.conf.d","/lib/systemd/system","/etc/sysconfd",
"101-500",,"Which command is used with systemd in order to list the available service units?","systemd List-units","systemctl list-units","systemd unit-list","systemctl show-units",
"101-500",,"Which option to lspci is used to display both numeric codes and device names?","-numdev","-n","-nn","-devnum",
"101-500",,"Which command can be used to obtain a list of currently loaded kernel modules?","insmod","modlist","1s --modules","1smod",
"101-500",,"Which option to the modprobe command shows the dependencies for a given module?","--show-options","--list-deps","--show-depends","--list-all",
"101-500",,"Which command can you use to send a message to all users who are currently logged into a system?","cat","wall","tee","ssh",
"101-500",,"Which of the following is a good first troubleshooting step when a hard disk is not detected by the Linux kernel?","Unplug the disk.","Check the system BIOS.","Restart the web server service.","Run the disk-detect command.",
"101-500",,"Within which directory is information about USB devices stored?","/etc/usbdevices","/var/usb","/lib/sys/usb","/sys/bus/usb/devices",
"101-500",,"If the kernel ring buffer has been overwritten, within which file can you look to find boot messages?","/var/log/bootmessages","/var/log/mail.info","/var/adm/log/boot. info","/var/log/dmesg",
"101-500",,"Which command and option can be used to determine whether a given service is currently loaded?","systemctl --1s","telinit","systemctl status","sysctl -a",
"101-500",,"Which command on a systemd-controlled system would place the system into single-user mode?","systemctl one","systemctl isolate rescue. target","systemctl single-user","systemctl runlevel one",
"101-500",,"Which command on a system controlled by Upstart will reload the configuration files?","initctl reload","systemd reload","upstart --reload","ups -reload",
"101-500",,"When working with a SysV system, which option to chkconfig will display all services and their runlevels?","--reload","--list","--all","--ls",
"101-500",,"A drive connected to USB is considered which type of device?","Medium","Coldplug","Hotplug","Sideplug",
"101-500",,"The system is using a temporary flash USB disk for data mounted at /dev/sdal. You need to remove the disk. Which of the following commands will enable the disk to be safely removed from the system?","usbstop /dev/sda","umount /dev/sdal","unmount /dev/sdal","dev-eject /dev/sdal",
"101-500",,"You have connected a USB disk to the system and need to find out its connection point within the system. Which of the following is the best method for accomplishing this task?","Rebooting the system","Viewing the contents of /var/log/usb. log","Connecting the drive to a USB port that you know the number of","Running dmesg and looking for the disk",
"101-500",,"Which of the following commands will initiate an immediate shutdown of the system?","shutdown -c","halt","systemd stop","stop-system",
"101-500",,"Which option within a systemd service file indicates the program to execute?","StartProgram","ShortCut","ExecStart","Startup",
"101-500",,"Which command will display the default target on a computer running systemd?","systemctl defaults","update-rc.d defaults","systemctl runlevel","systemctl get-default",
"101-500",,"Which option to the systemctl command will change a service so that it runs on the next boot of the system?","enable","startonboot","loadonboot","start",
"101-500",,"Which of the following best describes the /proc filesystem?","/proc contains information about files to be processed.","/proc contains configuration files for processes.","/proc contains information on currently running processes, including the kernel.","/proc contains variable data such as mail and web files.",
"101-500",,"Which command will retrieve information about the USB connections on a computer in a tree-like format?","lsusb -tree","lsusb --tree","lsusb -t","usblist --tree",
"101-500",,"What is one reason why a device driver does not appear in the output of lsmod, even though the device is loaded and working properly?","The use of systemd means that drivers are not required for most devices.","The use of initramfs means that support is enabled by default.","The system does not need a driver for the device.","Support for the device has been compiled directly into the kernel.",
"101-500",,"Which option to rmmod will cause the module to wait until its no longer in use to unload the module?","-test","-f","-w","-unload",
"101-500",,"You are using a storage area network (SAN) that keeps causing errors on your Linux system due to an improper kernel module created by the SAN vendor. When the SAN sends updates, it causes the filesystem to be mounted as read-only. Which command and option can you use to change the behavior of the filesystem to account for the SAN bug?","mount --continue","tune2fs -e continue","mkfs --no-remount","mount -o remount",
"101-500",,"Within which directory are rules related to udev stored?","/etc/udev.conf","/etc/udev.conf.d","/etc/udev/rules.d","/etc/udev.d",
"101-500",,"Which option to Lspci displays the kernel driver in use for the given Peripheral Component Interconnect (PCI) device?","-t","-k","-n","-a",
"101-500",,"Within which of the following directories will you find blacklist information for modules loaded with modprobe?","/etc/blacklist","/etc/modprobe.d","/etc/blacklist.mod","/etc/modprobe",
"101-500",,"When working with a CentOS 6 system, which command is used to create the initial RAM disk?","mkinit","dracut","mkraminit","mkinitfs",
"101-500",,"Within which file will you find a list of the currently available kernel symbols?","/proc/kernelsyms","/etc/kernel.conf","/etc/syms","/proc/kallsyms",
"101-500",,"Which of the following commands can be used to show the various information related to a currently loaded module, including core size and settings for options?","systool -v -m <module>","modinfo -r <module>","lsmod <module>","infmod <module>",
"101-500",,"Which directory contains various elements and configuration information about the kernel such as the release number, domain name, location of modprobe, and other settings?","/proc/sys/kmod","/proc/sys/kernel","/proc/kernel","/proc/kernel/sys",
"101-500",,"Within which directory should systemd unit files that you create be stored?","/etc/system","/etc/systemd/system","/usr/share/systemd","/usr/share/system",
"101-500",,"Which of the following commands should you execute after making changes to systemd service configurations in order for those changes to take effect?","systemd reload","reboot","systemctl daemon-reload","systemctl reboot",
"101-500",,"Which of the following files contains the runlevels for the system along with a reference to the corresponding rc file?","/etc/runlevels","/etc/inittab","/etc/re","/etc/runlevel",
"101-500",,"Which boot loader can be used for File Allocation Table (FAT) filesystems and might be used for a rescue disk?","SYSBOOT","SYSLINUX","TIELINUX","FATLINUX",
"101-500",,"Which of the following is used to provide an early filesystem-based loading process for key drivers needed to continue the boot process?","bootrd","driverload","initrd","initdrv",
"101-500",,"When booting a system you receive an error similar to ""No init found"" and are then placed at an initramfs prompt. You need to check the hard drive for errors. Which of the following commands performs an error check on a hard drive partition in Linux?","defrag","fsck","checkfs","chkfs",
"101-500",,"Which of the following commands places the system in single-user mode?","tellinit 1","chginit 1","telinet 1","telinit 1",
"101-500",,"Which of the following commands changes the boot order for the next boot?","efibootmgr -c","efibootmgr -b -B","efibootmgr -o","efibootmgr -n",
"101-500",,"Which boot loader can be used with IS09660 CD-ROMS?","ISOLINUX","EFIBOOT","ISOFS","BOOTISO",
"101-500",,"Within which directory are systemd user unit files placed by installed packages?","/usr/lib/systemd/user","/usr/lib/systemd/system","/usr/systemd","/usr/system",
"101-500",,"When using Unified Extensible Firmware Interface (UEFI), which of the following files can be used as a boot loader?","shim.uefi","shim.efi","shim. fx","efi.shim",
"101-500",,"Which directory on a SysV init-based system contains scripts that are used for starting and stopping services?","/etc/rc.int","/etc/boot","/etc/bootscripts","/etc/init.d",
"101-500",,"Which of the following commands is used to find overriding configuration files on a systemd-based system?","diff","systemctl -diff","systemd-delta","systemctl configoverride",
"101-500",,"Which of the following commands on a Red Hat system lists all of the SysV services set to be executed on boot along with their setting for each runlevel?","rlevel","chkconfig --list","bootldr --list","init --bootlist",
"101-500",,"Which of the following commands, executed from within the UEFI shell, controls the boot configuration?","bootcfg","befg","grub-install","ercfg",
"101-500",,"Which file must exist within /tftpboot on the Trivial File Transfer Protocol (TFTP) server for a system that will use PXELINUX for its boot loader?","pxelinux.tftp","pxelinux.boot","pxelinux.conf","pxelinux.0",
"101-500",,"Which utility can you use on a Debian or Ubuntu system to manage SysV init scripts, such as setting them to run on boot?","bootorder","bootloader","configchk","update-rc.d",
"101-500",,"Which key, pressed during the operating system selection menu, is used to enable editing of the parameters related to boot with GRUB?","v","e","r","y",
"101-500",,"Which systemct1 subcommand is used to switch runlevels?","switch","move","runlevel","isolate",
"101-500",,"When examining the /etc/inittab file, which option signifies the default runlevel to which the system will boot?","default","defaultboot","initdefault","defaultlvl",
"101-500",,"Which of the following is used instead of initrd to provide an early filesystem for essential drivers?","initnext","initramfs","initialize","initfs",
"101-500",,"Which of the following commands sets the default systemd target to multi-user?","systemctl set-default multi-user.target","systemd set-default multi-user. target","systemctl set-def muser.target","systemd set-def muser.target",
"101-500",,"When using a shim for booting a UEFI-based system, which of the following files is loaded after shim.efi?","grubx64.cfg","grub.conf","grubx64.efi","efi.boot",
"101-500",,"Within which hierarchy are files from /etc/init.d linked so that the files are executed during the various runlevels of a SysV system?","/etc/rc.S","/etc/rc","/etc/boot/re","/etc/rc.d",
"101-500",,"What is the name of the unit to which a systemd system is booted in order to start other levels?","default.target","init.target","initial.target","load.target",
"101-500",,"When viewing information in /dev/disk/by-path using the command Ls -1, which of the following filenames represents a logical unit number (LUN) from Fibre Channel?","/dev/fco","pci-0000:1a:00.0-fc-0x500601653ee0025F : 0x0000000000000000","pci-0000:1a:00.0-scsi-0x500601653ee0025f : 0x0000000000000000","/dev/fibreo",
"101-500",,"You have purchased new solid-state drive (SSD) hardware that uses the NVMe (Non-Volatile Memory Express) protocol but cannot find the disks in the normal /dev/sd* location in which you have traditionally found such storage. In which location should you look for these drives?","/dev/nd*","/dev/nvme*","/dev/nv*","/dev/nvme/*",
"101-500",,"Which file contains information about the current md Redundant Array of Inexpensive Disks (RAID) configuration such as the personalities?","/proc/raidinfo","/proc/rhyinfo","/proc/mdraid","/proc/mdstat",
"101-500",,"Which of the following directory hierarchies contains information such as the World Wide Name (WWN) for Fibre Channel?","/sys/class/wwn","/sys/class/fc_host","/sys/class/fclist","/sys/class/fc/wwn",
"101-500",,"Information about logical volumes can be found in which of the following directories?","/dev/lvinfo","/dev/map","/dev/mapper","/dev/lvmap",
"101-500",,"Which of the following commands will examine the PCI subsystem for NVMe-based devices?","psnvme","lsnvme","lspci | grep scsi","lspci | grep -i nvme",
"101-500",,"Which of the following devices is the location of the first Small Computer System Interface (SCSI) tape device detected at boot?","/dev/st1","/dev/sdo","/dev/sdi","/dev/sto",
"101-500",,"Which of the following files should be used to display a message to users prior to logging in locally?","/etc/loginmesg","/etc/logmessage.txt","/etc/issue","/etc/banner",
"101-500",,"Which file contains a message that is displayed after a successful login?","/etc/loginbanner","/etc/issue","/etc/motd","/etc/message",
"101-500",,"Which of the following files can be used to provide a message to users logging in remotely with a protocol such as telnet?","/etc/telnet.msg","/etc/issue.net","/etc/login.msg","/etc/telnet. login",
"101-500",,"Which of the following commands turns off the computer, including removing power, if possible?","systemctl halt","systemctl reboot","systemctl stop","systemctl poweroff",
"101-500",,"Which of the following shutdown commands reboots the system in 15 minutes?","shutdown -r +15","shutdown +15","shutdown -15","shutdown -r 00:15",
"101-500",,"When terminating a process on a SysV init-based system, which command can be used to stop the process?","service","sysv","syscl","servc",
"101-500",,"Which of the following commands show the boot messages captured by systemd?","journalctl -b","systemctl -b","journatctl -bm","journatctl -1",
"101-500",,"Which option to the shutdown command halts or stops the system?","-h","-s","-f","-t",
"101-500",,"Which signal number is used as SIGKILL when used with the kill command?",1,4,9,11,
"101-500",,"Which directory contains rc-related startup scripts on a legacy Debian system?","/etc/init","/etc/inittab","/etc/init.d","/etc/rc.init",
"101-500",,"When attempting to enable an integrated peripheral on a basic input/output system (BIOS) system, what should be done to determine whether the peripheral has been enabled within the BIOS?","Examine boot messages to determine if the kernel has detected the peripheral.","Examine /var/log/auth. Log for detection of the peripheral.","Reboot the system to determine if the device works.","Enable the peripheral by removing it from the blacklisted modules.",
"101-500",,"Which option to the wall command suppresses the ""Broadcast message"" banner that normally displays?","-b","-a","-n","-d",
1 LEVEL ANSWER QUESTION 1 2 3 4 5
2 101-500 Which of the following commands is used to view kernel-related udev events in real time? udevis all lsudev -f udevmon -a udevadm monitor
3 101-500 Which command enables you to view the current interrupt request (IRQ) assignments? view /proc/irq cat /proc/interrupts cat /dev/irg less /dev/irg
4 101-500 Configuration of udev devices is done by working with files in which directory? /udev/devices /devices/ /udev/config /etc/udev
5 101-500 Which command is used to automatically load a module and its dependencies? modprobe lsmod insmod rmmod
6 101-500 Which command is used to obtain a list of USB devices? usb-list lsusb 1s -usb 1s --usb
7 101-500 When working with hotplug devices, you need to gather more information about them through udevadm. Which udevadm command enables you to query the udev database for information on a device? query info getinfo devinfo
8 101-500 Which command can be used to view the kernel ring buffer in order to troubleshoot the boot process? lsboot boot-log krblog dmesg
9 101-500 During the initialization process for a Linux system using SysV init, which runlevel corresponds to single-user mode? Runlevel 5 Runlevel SU Runlevel 1 Runlevel 6
10 101-500 On a system using SysV init, in which directory are the startup and shutdown scripts for services stored? /etc/init-d /etc/init /etc/sysV /etc/init.d
11 101-500 Which command can be used to reboot a system? init 6 shutdown -h -t now init 1 refresh-system
12 101-500 When using an SysV init-based system, which command would you use if you make changes to the /etc/inittab file and want those changes to be reloaded without a reboot? init-refresh init 6 telinit reload-inittab
13 101-500 Which command displays the current runlevel for a system? show-level init --level sudo init runlevel
14 101-500 Within which folder are systemd unit configuration files stored? /etc/system.conf.d /lib/system.conf.d /lib/systemd/system /etc/sysconfd
15 101-500 Which command is used with systemd in order to list the available service units? systemd List-units systemctl list-units systemd unit-list systemctl show-units
16 101-500 Which option to lspci is used to display both numeric codes and device names? -numdev -n -nn -devnum
17 101-500 Which command can be used to obtain a list of currently loaded kernel modules? insmod modlist 1s --modules 1smod
18 101-500 Which option to the modprobe command shows the dependencies for a given module? --show-options --list-deps --show-depends --list-all
19 101-500 Which command can you use to send a message to all users who are currently logged into a system? cat wall tee ssh
20 101-500 Which of the following is a good first troubleshooting step when a hard disk is not detected by the Linux kernel? Unplug the disk. Check the system BIOS. Restart the web server service. Run the disk-detect command.
21 101-500 Within which directory is information about USB devices stored? /etc/usbdevices /var/usb /lib/sys/usb /sys/bus/usb/devices
22 101-500 If the kernel ring buffer has been overwritten, within which file can you look to find boot messages? /var/log/bootmessages /var/log/mail.info /var/adm/log/boot. info /var/log/dmesg
23 101-500 Which command and option can be used to determine whether a given service is currently loaded? systemctl --1s telinit systemctl status sysctl -a
24 101-500 Which command on a systemd-controlled system would place the system into single-user mode? systemctl one systemctl isolate rescue. target systemctl single-user systemctl runlevel one
25 101-500 Which command on a system controlled by Upstart will reload the configuration files? initctl reload systemd reload upstart --reload ups -reload
26 101-500 When working with a SysV system, which option to chkconfig will display all services and their runlevels? --reload --list --all --ls
27 101-500 A drive connected to USB is considered which type of device? Medium Coldplug Hotplug Sideplug
28 101-500 The system is using a temporary flash USB disk for data mounted at /dev/sdal. You need to remove the disk. Which of the following commands will enable the disk to be safely removed from the system? usbstop /dev/sda umount /dev/sdal unmount /dev/sdal dev-eject /dev/sdal
29 101-500 You have connected a USB disk to the system and need to find out its connection point within the system. Which of the following is the best method for accomplishing this task? Rebooting the system Viewing the contents of /var/log/usb. log Connecting the drive to a USB port that you know the number of Running dmesg and looking for the disk
30 101-500 Which of the following commands will initiate an immediate shutdown of the system? shutdown -c halt systemd stop stop-system
31 101-500 Which option within a systemd service file indicates the program to execute? StartProgram ShortCut ExecStart Startup
32 101-500 Which command will display the default target on a computer running systemd? systemctl defaults update-rc.d defaults systemctl runlevel systemctl get-default
33 101-500 Which option to the systemctl command will change a service so that it runs on the next boot of the system? enable startonboot loadonboot start
34 101-500 Which of the following best describes the /proc filesystem? /proc contains information about files to be processed. /proc contains configuration files for processes. /proc contains information on currently running processes, including the kernel. /proc contains variable data such as mail and web files.
35 101-500 Which command will retrieve information about the USB connections on a computer in a tree-like format? lsusb -tree lsusb --tree lsusb -t usblist --tree
36 101-500 What is one reason why a device driver does not appear in the output of lsmod, even though the device is loaded and working properly? The use of systemd means that drivers are not required for most devices. The use of initramfs means that support is enabled by default. The system does not need a driver for the device. Support for the device has been compiled directly into the kernel.
37 101-500 Which option to rmmod will cause the module to wait until it’s no longer in use to unload the module? -test -f -w -unload
38 101-500 You are using a storage area network (SAN) that keeps causing errors on your Linux system due to an improper kernel module created by the SAN vendor. When the SAN sends updates, it causes the filesystem to be mounted as read-only. Which command and option can you use to change the behavior of the filesystem to account for the SAN bug? mount --continue tune2fs -e continue mkfs --no-remount mount -o remount
39 101-500 Within which directory are rules related to udev stored? /etc/udev.conf /etc/udev.conf.d /etc/udev/rules.d /etc/udev.d
40 101-500 Which option to Lspci displays the kernel driver in use for the given Peripheral Component Interconnect (PCI) device? -t -k -n -a
41 101-500 Within which of the following directories will you find blacklist information for modules loaded with modprobe? /etc/blacklist /etc/modprobe.d /etc/blacklist.mod /etc/modprobe
42 101-500 When working with a CentOS 6 system, which command is used to create the initial RAM disk? mkinit dracut mkraminit mkinitfs
43 101-500 Within which file will you find a list of the currently available kernel symbols? /proc/kernelsyms /etc/kernel.conf /etc/syms /proc/kallsyms
44 101-500 Which of the following commands can be used to show the various information related to a currently loaded module, including core size and settings for options? systool -v -m <module> modinfo -r <module> lsmod <module> infmod <module>
45 101-500 Which directory contains various elements and configuration information about the kernel such as the release number, domain name, location of modprobe, and other settings? /proc/sys/kmod /proc/sys/kernel /proc/kernel /proc/kernel/sys
46 101-500 Within which directory should systemd unit files that you create be stored? /etc/system /etc/systemd/system /usr/share/systemd /usr/share/system
47 101-500 Which of the following commands should you execute after making changes to systemd service configurations in order for those changes to take effect? systemd reload reboot systemctl daemon-reload systemctl reboot
48 101-500 Which of the following files contains the runlevels for the system along with a reference to the corresponding rc file? /etc/runlevels /etc/inittab /etc/re /etc/runlevel
49 101-500 Which boot loader can be used for File Allocation Table (FAT) filesystems and might be used for a rescue disk? SYSBOOT SYSLINUX TIELINUX FATLINUX
50 101-500 Which of the following is used to provide an early filesystem-based loading process for key drivers needed to continue the boot process? bootrd driverload initrd initdrv
51 101-500 When booting a system you receive an error similar to "No init found" and are then placed at an initramfs prompt. You need to check the hard drive for errors. Which of the following commands performs an error check on a hard drive partition in Linux? defrag fsck checkfs chkfs
52 101-500 Which of the following commands places the system in single-user mode? tellinit 1 chginit 1 telinet 1 telinit 1
53 101-500 Which of the following commands changes the boot order for the next boot? efibootmgr -c efibootmgr -b -B efibootmgr -o efibootmgr -n
54 101-500 Which boot loader can be used with IS09660 CD-ROMS? ISOLINUX EFIBOOT ISOFS BOOTISO
55 101-500 Within which directory are systemd user unit files placed by installed packages? /usr/lib/systemd/user /usr/lib/systemd/system /usr/systemd /usr/system
56 101-500 When using Unified Extensible Firmware Interface (UEFI), which of the following files can be used as a boot loader? shim.uefi shim.efi shim. fx efi.shim
57 101-500 Which directory on a SysV init-based system contains scripts that are used for starting and stopping services? /etc/rc.int /etc/boot /etc/bootscripts /etc/init.d
58 101-500 Which of the following commands is used to find overriding configuration files on a systemd-based system? diff systemctl -diff systemd-delta systemctl configoverride
59 101-500 Which of the following commands on a Red Hat system lists all of the SysV services set to be executed on boot along with their setting for each runlevel? rlevel chkconfig --list bootldr --list init --bootlist
60 101-500 Which of the following commands, executed from within the UEFI shell, controls the boot configuration? bootcfg befg grub-install ercfg
61 101-500 Which file must exist within /tftpboot on the Trivial File Transfer Protocol (TFTP) server for a system that will use PXELINUX for its boot loader? pxelinux.tftp pxelinux.boot pxelinux.conf pxelinux.0
62 101-500 Which utility can you use on a Debian or Ubuntu system to manage SysV init scripts, such as setting them to run on boot? bootorder bootloader configchk update-rc.d
63 101-500 Which key, pressed during the operating system selection menu, is used to enable editing of the parameters related to boot with GRUB? v e r y
64 101-500 Which systemct1 subcommand is used to switch runlevels? switch move runlevel isolate
65 101-500 When examining the /etc/inittab file, which option signifies the default runlevel to which the system will boot? default defaultboot initdefault defaultlvl
66 101-500 Which of the following is used instead of initrd to provide an early filesystem for essential drivers? initnext initramfs initialize initfs
67 101-500 Which of the following commands sets the default systemd target to multi-user? systemctl set-default multi-user.target systemd set-default multi-user. target systemctl set-def muser.target systemd set-def muser.target
68 101-500 When using a shim for booting a UEFI-based system, which of the following files is loaded after shim.efi? grubx64.cfg grub.conf grubx64.efi efi.boot
69 101-500 Within which hierarchy are files from /etc/init.d linked so that the files are executed during the various runlevels of a SysV system? /etc/rc.S /etc/rc /etc/boot/re /etc/rc.d
70 101-500 What is the name of the unit to which a systemd system is booted in order to start other levels? default.target init.target initial.target load.target
71 101-500 When viewing information in /dev/disk/by-path using the command Ls -1, which of the following filenames represents a logical unit number (LUN) from Fibre Channel? /dev/fco pci-0000:1a:00.0-fc-0x500601653ee0025F : 0x0000000000000000 pci-0000:1a:00.0-scsi-0x500601653ee0025f : 0x0000000000000000 /dev/fibreo
72 101-500 You have purchased new solid-state drive (SSD) hardware that uses the NVMe (Non-Volatile Memory Express) protocol but cannot find the disks in the normal /dev/sd* location in which you have traditionally found such storage. In which location should you look for these drives? /dev/nd* /dev/nvme* /dev/nv* /dev/nvme/*
73 101-500 Which file contains information about the current md Redundant Array of Inexpensive Disks (RAID) configuration such as the personalities? /proc/raidinfo /proc/rhyinfo /proc/mdraid /proc/mdstat
74 101-500 Which of the following directory hierarchies contains information such as the World Wide Name (WWN) for Fibre Channel? /sys/class/wwn /sys/class/fc_host /sys/class/fclist /sys/class/fc/wwn
75 101-500 Information about logical volumes can be found in which of the following directories? /dev/lvinfo /dev/map /dev/mapper /dev/lvmap
76 101-500 Which of the following commands will examine the PCI subsystem for NVMe-based devices? psnvme lsnvme lspci | grep scsi lspci | grep -i nvme
77 101-500 Which of the following devices is the location of the first Small Computer System Interface (SCSI) tape device detected at boot? /dev/st1 /dev/sdo /dev/sdi /dev/sto
78 101-500 Which of the following files should be used to display a message to users prior to logging in locally? /etc/loginmesg /etc/logmessage.txt /etc/issue /etc/banner
79 101-500 Which file contains a message that is displayed after a successful login? /etc/loginbanner /etc/issue /etc/motd /etc/message
80 101-500 Which of the following files can be used to provide a message to users logging in remotely with a protocol such as telnet? /etc/telnet.msg /etc/issue.net /etc/login.msg /etc/telnet. login
81 101-500 Which of the following commands turns off the computer, including removing power, if possible? systemctl halt systemctl reboot systemctl stop systemctl poweroff
82 101-500 Which of the following shutdown commands reboots the system in 15 minutes? shutdown -r +15 shutdown +15 shutdown -15 shutdown -r 00:15
83 101-500 When terminating a process on a SysV init-based system, which command can be used to stop the process? service sysv syscl servc
84 101-500 Which of the following commands show the boot messages captured by systemd? journalctl -b systemctl -b journatctl -bm journatctl -1
85 101-500 Which option to the shutdown command halts or stops the system? -h -s -f -t
86 101-500 Which signal number is used as SIGKILL when used with the kill command? 1 4 9 11
87 101-500 Which directory contains rc-related startup scripts on a legacy Debian system? /etc/init /etc/inittab /etc/init.d /etc/rc.init
88 101-500 When attempting to enable an integrated peripheral on a basic input/output system (BIOS) system, what should be done to determine whether the peripheral has been enabled within the BIOS? Examine boot messages to determine if the kernel has detected the peripheral. Examine /var/log/auth. Log for detection of the peripheral. Reboot the system to determine if the device works. Enable the peripheral by removing it from the blacklisted modules.
89 101-500 Which option to the wall command suppresses the "Broadcast message" banner that normally displays? -b -a -n -d

View File

@ -3,3 +3,25 @@
""" """
Placeholder for the server program Placeholder for the server program
""" """
import bottle
import pathlib
from ccpq.lib_ccpq import Question, Game, Database
class Server(bottle.Bottle):
"""WIP this could be the start of our REST API server"""
def __init__(self, filepath):
bottle.Bottle.__init__(self)
self._db = Database(filepath)
self.route("/question", callback=self._get_question)
def _get_question(self):
question = self._db.get_question()
return str(question)
if __name__ == "__main__":
filepath = pathlib.Path("./data/list_book1.csv")
server = Server(filepath)
server.run()

View File

@ -10,12 +10,28 @@ from rich.markdown import Markdown
from ccpq.lib_ccpq import Question, Database, Game from ccpq.lib_ccpq import Question, Database, Game
MSG = {
True: [
"Yes!",
"Good one!",
"Super!",
"Excellent job!"
],
False: [
"Sorry, that's wrong",
"No, that's not right",
"Damn it! That's not the right answer",
]
}
class Tui(object): class Tui(object):
def __init__(self): def __init__(self):
self._console = Console() self._console = Console()
self._stats = [] self._stats = []
def ask_question(self, question): def ask_question(self, question):
os.system("clear")
md = Markdown("# {}".format(question.get_question())) md = Markdown("# {}".format(question.get_question()))
self._console.print(md) self._console.print(md)
md = "" md = ""
@ -25,8 +41,8 @@ class Tui(object):
self._console.print(md) self._console.print(md)
def prompt_for_answer(self): def prompt_for_answer(self):
md = Markdown("What's your answer?") #md = Markdown("What's your answer?")
self._console.print(md) #self._console.print(md)
answer = self._parse_input() answer = self._parse_input()
return answer return answer
@ -35,12 +51,16 @@ class Tui(object):
TODO make it adapt to questions with multiple choices and fill the TODO make it adapt to questions with multiple choices and fill the
blank blank
""" """
while True: answers = []
result = input() results = input("What's your answer? (only numbers, separated by a SPACE) ")
results = results.split()
for result in results:
if result.isdigit(): if result.isdigit():
return result answers.append(result)
else:
md = Markdown("**only digits please**") md = Markdown("**only digits please**")
self._console.print(md) self._console.print(md)
return answers
def show_response(self, question): def show_response(self, question):
answers = question.get_right_answers() answers = question.get_right_answers()
@ -54,6 +74,11 @@ class Tui(object):
md = Markdown(md) md = Markdown(md)
self._console.print(md) self._console.print(md)
def show_success(self, success):
md = "# {}".format(random.choice(MSG[success]))
md = Markdown(md)
self._console.print(md)
def show_stats(self, stats): def show_stats(self, stats):
md = "### you have {} out of {} right!".format(stats[0], stats[2]) md = "### you have {} out of {} right!".format(stats[0], stats[2])
md = Markdown(md) md = Markdown(md)
@ -62,8 +87,6 @@ class Tui(object):
md = Markdown(md) md = Markdown(md)
self._console.print(md) self._console.print(md)
input() input()
os.system("clear")
def goodbye(self): def goodbye(self):
md = Markdown("# Goodbye!") md = Markdown("# Goodbye!")
@ -83,6 +106,7 @@ class Application(object):
answer = self._interface.prompt_for_answer() answer = self._interface.prompt_for_answer()
stat = question.verify(answer) stat = question.verify(answer)
self._session.update_stats(stat) self._session.update_stats(stat)
self._interface.show_success(stat)
self._interface.show_response(question) self._interface.show_response(question)
self._interface.show_stats(self._session.get_stats()) self._interface.show_stats(self._session.get_stats())
@ -91,7 +115,7 @@ class Application(object):
if __name__ == "__main__": if __name__ == "__main__":
filepath = pathlib.Path("./data/list_book1.csv") filepath = pathlib.Path("./data/multiple.csv")
interface = Tui() interface = Tui()
app = Application(filepath, interface) app = Application(filepath, interface)
try: try: