LPIC-1
141 flashcards · Computer Science · by JMaurelli
Topic: 103.5.1 Create, Monitor, Kill Processes Define jobs. When we run the jobs command at the CLI, what is the expected output?
jobs are processes/tasks that we start from the CLI. When we run the jobs command, we expect to see jobs status. Maybe the job is running, maybe it is stopped or maybe it is not running. If the job is not running we would get an empty output from jobs command.
Topic: 103.5.1 Create, Monitor, Kill Processes Define the watch command. What is the default frequency of the watch command? What is the argument to change the frequency?
The watch command allows us to launch a process from the CLI and it's output is directed to the terminal. It's default output frequency is 2s. watch -n proccess-command ## Where "n" is a real number, 3, 5, 7, 8.
Topic: 103.5.1 Create, Monitor, Kill Processes Define process signals as they are used in Linux.
So far in my studies, I have only learned about how signals can send stop, resume, or a terminate signal. Signals are a method for processes to send stop(pause), interrupt abruptly(kill), interrupt gracefully(terminate) signals to other processes.
Topic: 103.5.1 Create, Monitor, Kill Processes What is the default argument sent from the kill command?
By default signal 15 is sent. 15 asks the process to terminate gracefully. 15=SIGTERM
Topic: 103.5.1 Create, Monitor, Kill Processes What are the 2 signals that can be used to pause and resume a process? What are their name and numerical values?
18=SIGCONT - to resume 19=SIGSTOP - to pause
Topic: 103.5.1 Create, Monitor, Kill Processes What is the kill command argument to list all the available signals?
kill -l
Topic: 103.5.1 Create, Monitor, Kill Processes Describe the most commonly used keys to sort the columns in top utility.
## Notice the case in the answers. M = sort my memory P = sort by percent of CPU T = sort by cumulative time. N = sort by numerical pid.
Topic: 103.5.1 Create, Monitor, Kill Processes Of the top utility, what is the shortcut to sort ascending/descending?
## Notice the case in the answer. R = sort by ascending/descending
Topic: 103.5.1 Create, Monitor, Kill Processes Of the top utility and the load average values. What are the increments of the values?
The load avg values are 1min, 5mins, 15mins.
Topic: 103.5.1 Create, Monitor, Kill Processes Define these values found in the top utility, 3rd row which are %CPU. us, sy, ni, id, wa, hi, si, st
us - %CPU time spent on user processes sy - %CPU time spent on system/kernel processes ni - %CPU time spent on processed that have a non-default nice value. id - %CPU time spent on being idle wa - %CPU time spent on waiting for i/o operations hi - %CPU time spent on responding to hardware interrupts. si - %CPU time spent on responding to software interrupts. st - %CPU time spent serving other VM tasks in a virtual environment.
Topic: 103.5.1 Create, Monitor, Kill Processes Define the labels of the Mem and Swap summary sections.
Of the MiB Mem row, Total = 3661.7 MiB of total memory available Free = 3206.7 MiB of unused, free RAM Used = 386.3 MiB of RAM in actual use Buff/cache = 301.6 MiB of RAM that has been cached to prevent usage of swap memory. Of the MiB Swap row, Total = 2048.0 MiB of total swap memory available Free = 2048.0 MiB free and unused Used = 0.0 MiB swap memory in use Avail Mem = 3275.4 ## Pretty sure this is referencing RAM. Maybe this is what is available before swap is used?
Topic: 103.5.1 Create, Monitor, Kill Processes Explain and describe the column headers.
PID = process ID USER = user account that started the process PR = priority of process according to the kernel NI = nice value of the process. lower equals higher priority, higher number equals lower priority VIRT = total memory used by process, includes swap and ram. RES = total ram used by process SHR = amount of memory shared with other processes. S = status of process. Idle, Running, Sleeping... %CPU = percentage of CPU usage %MEM = value of RES expressed as a percent. TIME+ = accumulated t…
Topic: 103.5.1 Create, Monitor, Kill Processes Define the following Status values from the S column in the top utility output. R, S, D, Z, T, W, X
R = Running or executing S = Sleeping, maybe waiting for a specific condition or event to occur. D = Uninterruptible sleep. Process is waiting for a specific I/O operation to complete. Maybe read a file or waiting for network reply. Z = Zombied. This is usually momentary as the parent process may need time to clean up the zombie. T = Stopped. Usually this is stopped by a signal. W = Paging state, waiting for paged(swapped) memory content to be loaded into RAM. X = Dead state. Has been terminate…
Archiving and Compressing files What are the two switches that allow us to utilize either gzip or bzip2 compressing with tar?
-z is for gzip -j is for bzip2. tar -czf archivename.tgz /path/to/files/ tar -cjf archivename.tbz /path/to/files/
Using the find command. Produce a command to find all files that are larger than 500MB from the /etc/ directory.
find /etc -size +500M
Using rpm on a Red Hat Enterprise Linux system, how would you install the package file- roller-3.28.1-2.el7.x86_64.rpm showing a progress bar during the installation?
rpm -ih i = install h = hash, will show progress bar as hash marks.
Define the hierarchy of LVM.
Block devices comprise Physical Volumes (PV) Physical volumes comprise Volume Groups (VG) Volume Groups comprise Logical Volumes (LV)
Define command substitution.
Allows us to capture the output of a command by placing the command in back qoutes. mkdir `date +%Y-%m-%d` ## this will create a directory with a name in the y-m-d format
Installing, Upgrading and Removing Packages using RPM and YUM What is the command to install a package using RPM?
rpm -i packagename
Using the find command. Produce a command to find all files that are larger than 500MB but less than 1G from the /etc/ directory.
find /etc -size +500M -size -1000M
Consider a repository with Debian source packages for the xenial distribution, hosted at http://us.archive.ubuntu.com/ubuntu/ and with packages for the universe component. What would be the corresponding line to be added to /etc/apt/sources.list?
deb-src http://us.archive.ubuntu.com/ubuntu/ xenial universe This line could also be added inside a .list file in /etc/apt/sources.list.d/. The name is up to you but should be descriptive, something like xenial_sources.list.
Listing Installed Packages using RPM What command options will generate a list of installed packages?
rpm -qa
How would you use yum to check for updates for all packages in the system?
yum update
Where is the program file responsible for handling run levels and system resource management on SysVinit systems?
In legacy systems it is here: /sbin/init But if we do a ls -lah on that directory we get the following. [jmaurelli@localhost-live ~]$ ls -lah /sbin/init lrwxrwxrwx. 1 root root 22 Mar 13 16:00 /sbin/init -> ../lib/systemd/systemd
Briefly describe Run level 0
Run level 0 = Shutdown
What are two alternatives to the "which" command?
type and whereis commands type shows the location and if there is an alias whereis command displays the location of the command and location of any man pages Examples: admin-1@pop-os:~$ whereis bash bash: /usr/bin/bash /usr/share/man/man1/bash.1.gz admin-1@pop-os:~$ type bash bash is /usr/bin/bash admin-1@pop-os:~$ which bash /usr/bin/bash
The Linux kernel keeps symbolic links in /proc/PID/fd/ to every file opened by a process, where PID is the identification number of the corresponding process. How could the system administrator use that directory to verify the location of log files opened by nginx, supposing its PID is 1234?
By issuing the command ls -l /proc/1234/fd, which will display the targets of every symbolic link in the directory.
Imagine you have a disk identified as /dev/sda with multiple partitions. Which command can be used to find out which is the boot partition on a system?
Use fdisk -l /dev/sda. The boot partition will be marked with an asterisk (*) in the listing. The answer may be a bit outdated. When I run this command, it takes me into the fdisk utility. From there I need to use the "p" option to print a list of disks. Then I can see the (*) boot partition. ## On subsequent attempts, I was able to run the command correctly.
Define or describe the exam objectives related to booting the system.
- Provide common commands to boot loader and options to kernel at boot time - Demonstrate knowledge of boot sequence from BIOS/UEFI to boot completion - Understanding of SysVinit and systemd - Check boot events in log files - journalctl and dmesg - Awareness of Upstart
YelloDog Updater Modified - YUM Installing, Upgrading and Removing Packages What command can be used to update a package using yum?
yum update packagename
What is the command to display the environment variables?
env
What is the preferred command to interact with loaded kernel modules?
kmod $ kmod --help kmod - Manage kernel modules: list, load, unload, etc Usage: kmod [options] command [command_options] Options: -V, --version show version -h, --help show this help Commands: help Show help message list list currently loaded modules static-nodes outputs the static-node information installed with the currently running kernel kmod also handles gracefully if called from following symlinks: lsmod compat lsmod command rmmod compat rmmod command insmod compat insmod command modinfo…
Hard links need to reside on the same filesystem as the target, whereas symbolic links need not be on the same filesystem as the target. True or False?
True
How can you use zypper to check if the package unzip is installed?
zypper search -i
In 2018, the hardware vulnerability known as Meltdown was discovered. It affects almost all processors of many architectures. Recent versions of the Linux kernel can inform if the current system is vulnerable. How can this information be obtained?
cat /proc/cpuinfo has a line showing the known bugs for the corresponding CPU, like bugs: cpu_meltdown. Or we can see the same info with lscpu.
What are a couple of commands to see, partitions, filesystem types and mountpoints?
Using lsblk, we can see devices, partitions, and mountpoints. Using df -hT we can see filesystem types, mountpoints.
What is the command to display PATH.
echo $PATH
Using zypper, how would you disable a repository called repo-extras?
zypper modifyrepo -d repo-extras
What is the dpkg command that can be used to determine which app own a particular file? Which dpkg command can be used to reconfigure or reset the configuration of an installed app?
dpkg-query -S /path/to/package/file dpkg-reconfigure packagename
You noticed a file in your home directory that has a + symbol appended to the mode. What does this indicate? a. Special permissions have been set on the file. b. The file has one or more files on the filesystem that are hard-linked to it. c. The sticky bit directory permission has been set on the file and will remain inactive as a result. d. Additional entries exist within the ACL of the file that can be viewed using the getfacl command.
d. Additional entries exist within the ACL of the file that can be viewed using the getfacl command.
What is the command to create a temporary variable and what is the command to delete(unset) that variable?
Command to create is: mynewvar=goodbye Command to unset is: unset mynewvar
Managing software repositories with yum. What is the recommended command to enable or disable repos that are in the repo list?
yum-config-manager --disable | --enable "repo name"
How can you get a list of all installed packages in the system using dnf?
dnf list --installed
When using dpkg, what is the file path to edit default source list? What is the file path to create new files that contain manually added sources list?
default sources list: /etc/apt/source.list manually added list: /etc/apt/source.list.d/
While working under a Debian Linux system, and you are compiling a program, you come across an error message complaining that the header file zzip-io.h is not present on your system. How can you find out which package provides that file?
Use apt-file search to find which package contains a file not present in the system: apt-file search zzip-io.h
Describe the general steps of the Linux boot process from power on.
1. Power on 2. UEFI/BIOS checks the first 512bytes for boot loader. This is called boot strapping 3. Bootloader(GRUB) will load Kernel into RAM 4. Kernel will take control of CPU and detect and configure hardware such as MEM addressing. 5. Kernel will load initramfs. initramfs is an archive that contains modules(drivers) and is a temporary filesystem used until the Kernel can access the root filesystem on disk. 6. After accessing root filesystem, the kernel will mount filesystems listed in fsta…
What are the 4 steps to change the filesystem on a USB device.
Identify device, partition and existing filessytem type: lsblk and df -hT Unmount device: umount /dev/sdf1 Change filesystem: mkfs -t ext3 /dev/sdf1 Mount device: mount /dev/sdf1 /media/jmaurelli/usb
Which device type can transfer data faster? Block or character?
Block can transfer faster. Character transfer data character by character. Block transfers data by descreet blocks(chunks)
Using dpkg-query, find which package contains a file named 7zr.1.gz.
dpkg-query -S 7zr.1.gz -S = search ## Don't have to provide the file path for this command.
Using the find command. Define the find command syntax/format structure.
find STARTING_PATH options EXPRESSSION
YelloDog Updater Modified - YUM Getting Information About a Package What yum command parameter will generate detailed info about an installed package?
yum info packagename
Can you list the 7 systemd unit types?
service - most common type. resources that can be initiated, interrupted and reloaded. socket - filesystem or network socket. have a corresponding service unit. device - hardware device identified by the kernel. mount - mount point definition in the filesystem. automount - mount point that is mounted automatically target - grouping of other units, managed as a single unit snapshot - save state of systemd. not available on every distro
Installing, Upgrading and Removing Packages using RPM and YUM While performing an install or package removal, what are the command options to get verbose output and a progress bar made of hash symbols?
rpm -ivh packagename i = install v = verbose h = hash progress bar
On Linux systems, where are the files for the GRUB bootloader stored?
Generally they are stored in /boot/grub/ or /boot/grub2/ There are some differences I found between distributions. Fedora and Debian, organized directories and files differently.
Where should the boot partition end to ensure that a PC will always be able to load the kernel?
For legacy reasons and maximum compatibility, the boot partition is usually located at the start of the disk and ends before cylinder 1024 (528MB). The boot partition only stores files needed by the bootloader, initramfs, kernel images and so can be very small....standard boot partition size is 300MB. The maximum compatibilty is for running modern Linux on really old BIOS based PCs.
What command and flag can be used to verify the syntax of /etc/inittab sysvinit config file?
telinit q This will reload the /etc/inittab file and will error if their are syntax errors.
The boot process of a Linux machine ends up with the following message: ALERT! /dev/sda3 does not exist. Dropping to a shell! What is the likely cause of this problem?
The disk was not detected. Maybe disconnected due to hardware failure. Ultimately the kernel was unable to find the device /dev/sda3.
Using yum, find out which package provides the file /bin/wget.
yum whatprovides /bin/wget
The following line is part of the output generated by command lspci: 03:00.0 RAID bus controller: LSI Logic / Symbios Logic MegaRAID SAS 2208 [Thunderbolt] (rev 05) What command should you execute to identify the kernel module in use for this specific device?
The command lspci -s 03:00.0 -v or lspci -s 03:00.0 -k
What are the steps to determine what kernel module is being used for a particular USB device.
1. Use the lsusb command root@pop-os:/home/jmaurelli# lsusb Bus 001 Device 002: ID 8087:8002 Intel Corp. 8 channel internal hub Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub Bus 002 Device 002: ID 8087:800a Intel Corp. Hub 2. Take note of the interesting device and it's Bus/Device IDs. Bus 001 Device 002: ID 8087:8002 Intel Corp. 8 channel internal hub 3. Use lsusb -t command root@pop-os:/home/jmaurelli# lsusb -t /: Bus 02.Port 1: Dev 1, Class=root_hub, Driver=ehci-pci/2p, 480M…
How could the output of command date +%Y-%m-%d be used as a Here string to command sed s/-/./g?
sed s/-/./g <<< `date +%Y-%m-%d` or sed s/-/./g <<< $(date +%Y-%m-%d)
Command "convert image.jpeg -resize 25% small/image.jpeg" creates a smaller version of image.jpeg and places the resulting image in a named file inside subdirectory small. Using xargs, how is it possible to perform the same command for every image listed in file filelist.txt?
xargs -I IMG convert IMG -resize 25% small/IMG < filelist.txt or cat filelist.txt | xargs -I IMG convert IMG -resize 25% small/IMG
Using command echo, how can the contents of variable TODAY be sent to the standard input of command sed s/-/./g?
echo $TODAY | sed s/-/./g
It’s convenient to save the execution date of actions performed by automated scripts. Command date +%Y-%m-%d shows the current date in year-month-day format. How can the output of such a command can be stored in a shell variable called TODAY using command substitution?
TODAY=`date +%Y-%m-%d` or TODAY=$(date +%Y-%m-%d)
103.5 Create, monitor and kill processes Although initially static, the output of ps can be turned dynamic by combining ps and watch . We will monitor the Apache HTTPD web server for new connections. Build the commands that will allow us to monitor the httpd process using ps, grep and watch
watch `ps fauxc | grep httpd` watch 'ps fauxc | grep httpd' watch "ps fauxc | grep httpd" watch $(ps fauxc | grep httpd)
103.5 Create, monitor and kill processes The SIGHUP signal can be used as a way to restart certain daemons. With the Apache HTTPD web server — for example — sending SIGHUP to the parent process (the one started by init ) kills off its children. The parent, however, re-reads its configuration files, re-opens log files and spawns a new set of children. Build and list the commands used to identify the httpd PID, send the -SIGHUP and verify that new child processed have been spawned.
Any of these commands: ps fauxc | grep httpd; pgrep httpd; pidof httpd kill -SIGHUP <PID> Any of these commands: ps fauxc | grep httpd; pgrep httpd; pidof httpd
103.5 Create, monitor and kill processes Working with screen command. Build the command to start screen and name it.
screen -S "SessionName"
103.5 Create, monitor and kill processes Working with screen command. What are the key bindings to start a new screen inside an existing screen?
ctrl-a + c
103.5 Create, monitor and kill processes Working with screen command. While we have multiple screens running, what are the key bindings to navigate forwards and backwards through them? One by one in a "straight" line.
ctrl-a + n ctrl-a + p
103.5 Create, monitor and kill processes Working with screen command. From within a screen session, how do we display a list of running screens?
With a four key binding combination. ctrl+a and shift+" (ctrl+a and shift key with double qoute key)
103.5 Create, monitor and kill processes Working with screen command. What is the command to exit and close a screen window?
With the "exit" command.
103.5 Create, monitor and kill processes Working with screen command. What key bindings allow us to detach from a session?
ctrl+a+d
103.5 Create, monitor and kill processes Working with screen command. What command will allow us to view running sessions and then what command will allow us to reattach to the running session?
screen -list | ls ## Will display running session PID and session name. screen -r <PID> | <SessName>
103.5 Create, monitor and kill processes Working with screen command. What is the command to list a running session and then kill the running session? Killing the running session, kills all the screens inside.
screen -S <PID> | <SessName> -X quit
Before installing or updating packages with apt-get, which command should be used to ensure that the package index is up-to-date?
apt-get update This will download the latest package indexes from the repositories described in the /etc/apt/sources.list file or in the /etc/apt/sources.list.d/ directory.
Installing, Upgrading and Removing Packages using RPM. What is the command to remove (erase) a package using RPM?
rpm -e packagename
When manually mounting a filesystem, under which directory should it usually be mounted?
/mnt/ When filesystems are mounted automatically by the system, they are usually mounted to /media/username/
Although file /sbin/init can be found in systemd based systems, it is only a symbolic link to another executable file. In such systems where does the symbolic link point?
The main systemd binary: /lib/systemd/systemd.
What is the difference between SU and SUDO?
SU requires the password of the target account. SUDO requires the password of the current account.
A file has the following permissions: r----x-w-. The command chmod 143 would have the same effect as the command _________. (Choose all that apply.) a. chmod u+x-r,g+r-x,o+w file1 b. chmod u=w,g=rw,o=rx file1 c. chmod u-r-w,g+r-w,o+r-x file1 d. chmod u=x,g=r,o=wx file1 e. chmod u+w,g+r-w,o+r-x file1 f. chmod u=rw,g=r,o=r file1
d. chmod u=x,g=r,o=wx file1
UEFI firmware supports extended features provided by external programs, called EFI applications. These applications, however, have their own special location. Where on the system would the EFI applications be located?
EFI applications are located in the ESP. EUFI System Partition. 100MB sector that is formatted in FAT32.
What is the configuration file and the configuration parameter needed to set GRUB 2 to wait for 10 seconds before booting the default menu entry? What command needs to be run to apply this new config value?
Add the parameter GRUB_TIMEOUT=10 to /etc/default/grub. Run the command: mkconfig -o /boot/grub2/grub.cfg
What are the steps needed to change the settings for GRUB 2?
The default configuration file for GRUB2 is /boot/grub2/grub.cfg. This file is automatically generated and manual editing is not recommended. To make changes to the GRUB configuration, you need to edit the file /etc/default/grub and then run the update-grub utility to generate a compliant file. The update-grub utility is usually a shortcut to "grub-mkconfig -o /boot/grub2/grub.cfg"
How can you ignore a dependency warning and remove a package using dpkg, even if there are packages that depend on it in the system?
The parameter --force can be used, but this should never be done unless you know exactly what you are doing, since there is a great risk that your system will be left in an inconsistent or “broken” state.
Getting Package Information using RPM What command options will generate a detailed list of files used by an installed package?
rpm -ql packagename q = query l = list
What will be the result of command cat <<.>/dev/stdout?
Bash will enter Heredoc input mode, then exit when a period appears in a line by itself. The typed text will be redirected to stdout (printed on screen).
Only the root user can modify a file that has the immutable attribute set. True or False?
False. Even the root user cannot modify a file that has the immutable attribute set. Root user would need to remove the attribute.
How can you specify a text pattern that must be at the beginning of a line of text using a regular expression? a. Precede the string with a /. b. Follow the string with a \. c. Precede the string with a $. d. Precede the string with a ^.
d. Precede the string with a ^.
Imagine a user configuring GRUB Legacy to boot from the second partition of the first disk. He writes the following custom menu entry: title My Linux Distro root (hd0,2) kernel /vmlinuz root=/dev/hda1 initrd /initrd.img However, the system will not boot. What is wrong?
The boot partition is wrong. Remember that, unlike GRUB 2, GRUB Legacy counts the partitions from zero. So, the correct command for the second partition of the first disk should be root (hd0,1). ## I believe the guide states not to specify the partition for "kernel /vmlinuz root=/dev/hda1" <-- here. ## I am incorrect. My statement is actually about installing GRUB2. For grub legacy, we do specify the partition. # GRUB2: grub-install --boot-directory=/mnt/tmp /dev/sda
What is the apt command to install, remove or update packages on a Debian Linux system?
apt-get install packagename apt-get remove packagename apt-get update ## To update index list apt-get upgrade ## To upgrade all packages apt-get upgrade packagename ## To upgrade a specific package.
How could the telinit command be used to reboot the system?
telinit 6 will change the runlevel to level 6, which equals reboot
The command cat /proc/cpu_info displays an error message because /proc/cpu_info is nonexistent. The command cat /proc/cpu_info 2>1 redirects the error message to where?
To a file named 1 in the current directory. A file descriptor target is represented by an ampersand followed by the file descriptor’s numerical value. For example, 1>&2 redirects stdout to stderr. To do the opposite, stderr to stdout, 2>&1 should be used instead. ## In the above example, the ampersand is key as it's kind of a special character that is used to "direct" data stream to the integer value. Otherwise if ampersand wasn't used, then the redirect would look for a file of the numerical v…
What command can be used to discover if a device requires block or character type data transfer?
Two main options that are most efficient. We can cat the /proc/devices file and output to less command for paging This will display both character and block devices cat /proc/devices | less We can ls the directory contents of the /dev directory and pipe it's output to less for paging. This will display whether device is block or character, it will also display it's major and minor numbers. ls -lah /dev | less
Managing software repositories with yum. What is the recommended method of updating repos with yum?
Using the yum-config-manager utility. To add a repo yum-config-manager --add-repo https://url.path.to.repo
Using rpm, find out which package contains the file /etc/redhat-release.
rpm -qf /path/to/filename
A symbolic link is also known as a soft link and is depicted by an @ symbol appearing at the beginning of the filename when viewed using the ls –l command. True or False?
False - we get the symbol using ls -F and the symbol is at the end of the file name.
Managing software repositories with yum. What is the command to generate a list of repos?
yum repolist all
What is the apt command variant to search or run other operations within the package index?
apt-cache
Using apt-cache, what is the command to show information for the package gimp?
apt-cache show gimp
What are a couple of other filesystem check utility commands and for which filesystem are they designed for?
fschk is a general utility. e2fsck is designed for the ext2, ext3, ext4 family of filesystems. xfs_db is designed for the xfs filesystem.