Skip to content

Commit

Permalink
Linux cleanup (#3992)
Browse files Browse the repository at this point in the history
* linux: move similar questions Q17 and Q45 next to each other + fix Q45

Q45 is similar to Q17.
Moved Q45 next to Q17, adding notes
 so that it's easier to grasp the questions are similar.

Also, fixed Q45,
 by providing the correct answer,
 and adding a side note about potential compatibility problems.

* linux: answer Q52 correctly

Re-answered Q52 correctly:
 with "no-hang-up",
 the script will run in the background,
 even after the end of the session.

Added a link to the reference, with a quote.

* linux: fix a typo in Q84

In Q84, the word "extended" had a typo.

* linux: fix text and formatting in Q89

There were strange copy/paste bombs in Q89, fixed.

Also, fixed the Markdown for the reference provided.

* linux: fix text in Q90

There were strange copy/paste bombs in Q90, fixed.

* linux: renumbered questions after last changes

Automatically renumbered questions because of last moves.
  • Loading branch information
jpleboeuf authored Jul 12, 2022
1 parent 399f943 commit e59e66a
Showing 1 changed file with 59 additions and 49 deletions.
108 changes: 59 additions & 49 deletions linux/linux-assessment.md
Original file line number Diff line number Diff line change
Expand Up @@ -135,14 +135,31 @@ echo \$myNumber | sed -e 's/^[[:digit:]][[:digit:]][[:digit:]]/(&)/g'
- [ ] It will output the entire 10-digit number inside parentheses.
- [x] It will output the same 10-digit number, but the first 3 digits will be inside parentheses.

#### Q18. Packages can be downloaded but not installed with yum or dnf by specifying which option?
Note: check the question below for a variant of this sed expression.

#### Q18. What would this sed command do?

```bash
sed -E 's/[a-Z]{4}/(&)/' textfile.txt
```

- [ ] It would substitute the letter with an ampersand (&).
- [ ] It would replace all letters in the textfile.txt file with ampersand (&).
- [ ] It would replace the first four letters with an ampersand (&).
- [x] It would place parentheses around the first four letters of each line of textfile.txt.

Note: check the question above for a variant of this sed expression.

Side note: this sed expression may fail with "sed: -e expression #1, char 15: Invalid range end" (for example on MINGW64 / Git Bash); if this is the case, you can try the alternative range `[A-z]`.

#### Q19. Packages can be downloaded but not installed with yum or dnf by specifying which option?

- [ ] None of these answers. yum does not support downloading packages without installing them.
- [ ] --downloaddir
- [ ] -d
- [x] --downloadonly

#### Q19. What character class is equal to this set?
#### Q20. What character class is equal to this set?

`[0-9]`

Expand All @@ -151,28 +168,28 @@ echo \$myNumber | sed -e 's/^[[:digit:]][[:digit:]][[:digit:]]/(&)/g'
- [ ] `[[:alpha:]]`
- [ ] `[[:num:]]`

#### Q20. When archiving files, which command will preserve all file attributes including ACLs and SELinux security context?
#### Q21. When archiving files, which command will preserve all file attributes including ACLs and SELinux security context?

- [ ] zip
- [x] tar
- [ ] archive
- [ ] gzip

#### Q21. In a systemd-based OS, you can change the system hostname by editing /etc/hostname manually and then doing what?
#### Q22. In a systemd-based OS, you can change the system hostname by editing /etc/hostname manually and then doing what?

- [ ] Restart dhcpd.
- [ ] Run /etc/hostname.
- [x] Nothing, the system notices automatically.
- [ ] Notify systemd to update it by restarting the systemd-hostnamed service.

#### Q22. What command would you use to resize an LVM volume group to include an additional physical volume?
#### Q23. What command would you use to resize an LVM volume group to include an additional physical volume?

- [ ] vgadd
- [ ] vgresize
- [ ] vgappend
- [x] vgextend

#### Q23. When would this system cron job run its task?
#### Q24. When would this system cron job run its task?

`0 1 \* \* \*`

Expand All @@ -181,70 +198,70 @@ echo \$myNumber | sed -e 's/^[[:digit:]][[:digit:]][[:digit:]]/(&)/g'
- [x] every day at 1:00 AM
- [ ] only on Mondays

#### Q24. ifconfig has been deprecated. What command is now recommended for changing IP addresses in the live config?
#### Q25. ifconfig has been deprecated. What command is now recommended for changing IP addresses in the live config?

- [ ] netconf
- [ ] ipconfig
- [ ] ipman
- [x] ip

#### Q25. You are managing an Apache web server on a system using SELinux. By default it cannot read personal webpages in users' home directories. What SELinux boolean would you set to allow this?
#### Q26. You are managing an Apache web server on a system using SELinux. By default it cannot read personal webpages in users' home directories. What SELinux boolean would you set to allow this?

- [ ] apache_enable_homedirs
- [ ] httpd_enable_userdirs
- [x] httpd_enable_homedirs
- [ ] httpd_enable_userhome_dirs

#### Q26. Why doesn't passwd -l keep a user from logging in via other methods?
#### Q27. Why doesn't passwd -l keep a user from logging in via other methods?

- [ ] The passwd command is not used for locking passwords.
- [ ] There is no password -l option.
- [x] It locks only the password, not the account, so users can still authenticate with keys or other methods.
- [ ] It does lock the account, keeping users from logging in even if they are using other authentication methods.

#### Q27. In the Bash shell, what is the difference between piping into | and piping into |&?
#### Q28. In the Bash shell, what is the difference between piping into | and piping into |&?

- [ ] Piping into | pipes both stdout and stderr. Piping into |& pipes only stderr.
- [x] Piping into | pipes stdout. Piping into |& pipes stdout and stderr.
- [ ] Piping into | pipes both stdout and stderr. Piping into |& pipes only stdout.
- [ ] Piping into | pipes stdout. Piping into |& pipes all open file descriptors.

#### Q28. Why is the passwd command able to modify the /etc/passwd file?
#### Q29. Why is the passwd command able to modify the /etc/passwd file?

- [ ] The kernel identifies it as one of the names of extended commands.
- [ ] It has the same name as the file it modifies.
- [x] It has the SUID permission mode and is owned by root.
- [ ] It is a system administration command.

#### Q29. When a user deletes a file using the rm command, Linux will \_.
#### Q30. When a user deletes a file using the rm command, Linux will \_.

- [ ] always ask for confirmation
- [ ] back up the file before it deletes the file
- [x] ask for confirmation if configured to do so
- [ ] never ask for confirmation

#### Q30. What is a major advantage of using Logical Volume Management (LVM)?
#### Q31. What is a major advantage of using Logical Volume Management (LVM)?

- [ ] Access to a drive is faster than with standard partitions.
- [ ] Volumes can be resized smaller without unmounting them.
- [ ] Repairing filesystem errors is easier than with standard partitions.
- [x] Volumes can be resized even if the free space is not contiguous.

#### Q31. What is one major difference between brace expansion and globs?
#### Q32. What is one major difference between brace expansion and globs?

- [ ] Globs create a list; brace expansion matches pattern.
- [ ] Brace expansion requires files to exist; globs do not.
- [x] Brace expansion creates a list; globs match the list of pathnames.
- [ ] Globs get processes first and brace expansion later.

#### Q32. To remove all ACLs from a directory , use setfacl with which options?
#### Q33. To remove all ACLs from a directory , use setfacl with which options?

- [ ] -d
- [ ] -k
- [x] -b
- [ ] -x

#### Q33. Which choice will _not_ print "Hello World" in the terminal?
#### Q34. Which choice will _not_ print "Hello World" in the terminal?

- [ ] A

Expand Down Expand Up @@ -274,21 +291,21 @@ myVar = 5
[[ $myVar -gt 10 ]] || echo " Hello World"
```

#### Q34. What is not inherited by child process?
#### Q35. What is not inherited by child process?

- [x] shell aliases
- [ ] userid
- [ ] environmental variables
- [ ] scheduling priority

#### Q35. What NFS option allows the root user to access NFS shares as the root user?
#### Q36. What NFS option allows the root user to access NFS shares as the root user?

- [ ] no_admin_squash
- [x] no_root_squash
- [ ] allow_root_access
- [ ] all_squash

#### Q36. You send an email to a remote client using the following syntax. What will be in the body of the email?
#### Q37. You send an email to a remote client using the following syntax. What will be in the body of the email?

```bash
date | mail -s "This is a remote test" user1@rhhost1.localnet.com
Expand All @@ -299,73 +316,62 @@ date | mail -s "This is a remote test" user1@rhhost1.localnet.com
- [ ] The email subject shows "This is a remote test" but the body of the email will be empty.
- [x] the current date and time

#### Q37. What is the /etc/hosts file used for?
#### Q38. What is the /etc/hosts file used for?

- [ ] resolving the local name
- [ ] blocking sites using iptables
- [ ] setting the hostname
- [x] configuring DNS name servers

#### Q38. In an extended regular expression, you would use (pattern){3} to match three instances of the pattern. How would you match the same thing with an extended glob?
#### Q39. In an extended regular expression, you would use (pattern){3} to match three instances of the pattern. How would you match the same thing with an extended glob?

- [ ] 3(pattern)
- [ ] {0,3}(pattern}
- [x] Occurrence quantifiers are not supported in Bash's version of extended globs, so this is not possible.
- [ ] {3}(pattern})

#### Q39. When configuring a Samba share, how would the engineering group be specified in the smb.conf?
#### Q40. When configuring a Samba share, how would the engineering group be specified in the smb.conf?

- [ ] Samba uses Linux operating system groups from the /etc/group file; just specify the group name.
- [ ] It would be preceded by a percent sign (%), such as %engineers.
- [ ] Use the group name by itself; Samba checks for its existence.
- [x] It would be preceded by an @ symbol, such as @engineering.

#### Q40. To configure the Kerberos client, which command should you use to import the keytab file?
#### Q41. To configure the Kerberos client, which command should you use to import the keytab file?

- [ ] krb5-workstation
- [x] ktutil
- [ ] pam_krb5
- [ ] kdb5_util

#### Q41. To search from the current cursor position up to the beginning of the file using VIM, type \_ and then the search criteria.
#### Q42. To search from the current cursor position up to the beginning of the file using VIM, type \_ and then the search criteria.

- [x] `?`
- [ ] `\`
- [ ] `/`
- [ ] `/search`

#### Q42. What is the job of the NetworkManager daemon?
#### Q43. What is the job of the NetworkManager daemon?

- [ ] It is a graphical tool that manages network connections, including bonding and wireless networks.
- [ ] It is a security service that manages user access control of local network-aware services.
- [ ] It attempts to keep an active network connection available at all times.
- [x] It is a command-line tool that manages network connections.

#### Q43. Why might would you use the usermod command ?
#### Q44. Why might would you use the usermod command ?

- [ ] to log out a user
- [ ] to lock a user's account
- [x] to change global user account settings
- [ ] to set a user's password

#### Q44. Extending an LVM volume group does what to the formatted filesystem?
#### Q45. Extending an LVM volume group does what to the formatted filesystem?

- [ ] It prepares the filesystem for use by defragmenting it.
- [ ] It resizes the filesystem to match the volume group size.
- [x] It does nothing.
- [ ] It remounts the filesystem with the new size.

#### Q45. What would this sed command do?

```bash
sed -E 's/[a-Z]{4}/(&)/' textfile.txt
```

- [ ] It would substitute the letter with an ampersand (&).
- [ ] It would replace all letters in the textfile.txt file with ampersand (&).
- [x] It would replace the first four letters with an ampersand (&).
- [ ] It would place parentheses around the first four letters of each line of textfile.txt.

#### Q46. Which kernel module do you need to load to use interface bonding?

- [x] bonding.
Expand Down Expand Up @@ -416,8 +422,12 @@ find / -size -10K -exec ls -l {} \;

- [ ] The script will remain running in the background even if you reboot the system.
- [ ] The script will run in your terminal and you will not be able to do anything until it completes.
- [x] The script will run in the background until you end the session.
- [ ] The script will run in the background and will continue running even if you end the session.
- [ ] The script will run in the background until you end the session.
- [x] The script will run in the background and will continue running even if you end the session.

Reference: [Wikipedia](https://en.wikipedia.org/wiki/Nohup)

> nohup is a POSIX command which means "no hang up". Its purpose is to execute a command such that it ignores the HUP (hangup) signal and therefore does not stop when the user logs out.
#### Q53. To elevate privileges using the `sudo` command, a user must **\_**.

Expand Down Expand Up @@ -699,7 +709,7 @@ if [[ $FILE == $GLOB ]] ;then
#### Q84. Which of these features is missing from the Bash Language?

- [ ] associative arrays.
- [ ] extened regular expressions.
- [ ] extended regular expressions.
- [ ] debug traps.
- [x] object orientation.

Expand Down Expand Up @@ -733,20 +743,20 @@ if [[ $FILE == $GLOB ]] ;then
- [ ] tartar
- [ ] lvcopy

#### Q89. What is the difference between the apt remove and apt autoremove commands?What is the difference between the apt remove and apt autoremove commands?
#### Q89. What is the difference between the apt remove and apt autoremove commands?

- [ ] The apt remove command is a link to apt autoremove, so there are no differences. The apt remove command is a link to apt autoremove, so there are no differences.
- [x] Both uninstall software. The apt autoremove command also uninstalls the dependencies.Both uninstall software. The apt autoremove command also uninstalls the dependencies.
- [ ] Both uninstall software. The apt remove command also uninstalls the dependencies.Both uninstall software. The apt remove command also uninstalls the dependencies.
- [ ] The apt remove command is a link to apt autoremove, so there are no differences.
- [x] Both uninstall software. The apt autoremove command also uninstalls the dependencies.
- [ ] Both uninstall software. The apt remove command also uninstalls the dependencies.
- [ ] The apt autoremove command is a system service that routinely removes unused software packages.

[reference:] https://dannyda.com/2021/08/19/whats-the-difference-between-apt-remove-and-apt-autoremove-what-is-apt-purge-when-to-use-debian-ubuntu-kali-linux-etc/
[reference](https://dannyda.com/2021/08/19/whats-the-difference-between-apt-remove-and-apt-autoremove-what-is-apt-purge-when-to-use-debian-ubuntu-kali-linux-etc/)

#### Q90. You want to extract the contents from an rpm package. Which command do you use?

- [ ] rpm --updaterpm --update
- [ ] rpm -ivh --forcerpm -ivh --force
- [ ] rpm --reinstallrpm --reinstall
- [ ] rpm --update
- [ ] rpm -ivh --force
- [ ] rpm --reinstall
- [x] rpm2cpio

1. [reference:](https://stackoverflow.com/questions/18787375/how-do-i-extract-the-contents-of-an-rpm)
Expand Down

0 comments on commit e59e66a

Please sign in to comment.