# LFCS Mock Exam 2

##### Generated by ChatGPT

This is a second mock exam for LFCS covering all major topics: Operations, Networking, Storage, Essential Commands, and Users & Groups.

---

## Instructions

* Complete the exercises without looking at the answers.
* Answers are provided at the end of the document.

---

## Part 1: Operations & Deployment

1. Temporarily disable a kernel module `usb_storage` and verify it is no longer in use.
2. List all currently loaded kernel modules and identify one used by the system audio.
3. Schedule a one-time job to run `/usr/local/bin/update_logs.sh` in 15 minutes.
4. Check system boot messages for any hardware errors.

---

## Part 2: Networking

1. Configure interface `eth1` to use DHCP.
2. Verify DNS resolution for `example.com`.
3. Open port 8080 for TCP connections and make the change persistent.
4. Create a bonding device `bond0` using interfaces `eth0` and `eth1`.

---

## Part 3: Storage

1. Create a new 5 GB logical volume `lv_backup` in volume group `vg01`.
2. Format it with XFS and mount it at `/mnt/backup`.
3. Add a new swap partition on `/dev/sdc1` and activate it.
4. Mount a CIFS share `//server/share` on `/mnt/cifs` with credentials stored securely.

---

## Part 4: Essential Commands

1. Monitor memory usage in real-time and identify the process using the most memory.
2. Find all `.log` files larger than 50 MB in `/var/log`.
3. Generate a private key and CSR for a certificate signing request.
4. Clone a Git repository, create a new branch `feature1`, and push it to the remote.

---

## Part 5: Users & Groups

1. Create a system user `service1` without login permissions.
2. Set a hard limit of 10 processes for user `developer1`.
3. Set ACL so that group `developers` has read/write access to `/opt/project/config.yml`.
4. Configure the system to authenticate users against an LDAP server and verify an LDAP user.

---

# Answers (Do not read until done!)

## Part 1: Operations & Deployment

1. `sudo modprobe -r usb_storage`
   `lsmod | grep usb_storage` (should show nothing)
2. `lsmod | grep snd` (example: `snd_hda_intel`)
3. `echo "/usr/local/bin/update_logs.sh" | at now + 15 minutes`
4. `dmesg | less` or `journalctl -b`

## Part 2: Networking

1. `sudo nmcli con mod eth1 ipv4.method auto`
   `sudo nmcli con up eth1`
2. `dig example.com` or `nslookup example.com`
3. `sudo firewall-cmd --permanent --add-port=8080/tcp`
   `sudo firewall-cmd --reload`
4. `sudo nmcli con add type bond con-name bond0 ifname eth0,eth1 mode active-backup`

## Part 3: Storage

1. `sudo lvcreate -L 5G -n lv_backup vg01`
2. `sudo mkfs.xfs /dev/vg01/lv_backup`
   `sudo mkdir -p /mnt/backup`
   `sudo mount /dev/vg01/lv_backup /mnt/backup`
3. `sudo mkswap /dev/sdc1`
   `sudo swapon /dev/sdc1`
4. `sudo mount -t cifs -o credentials=/root/.cifs_credentials //server/share /mnt/cifs`

## Part 4: Essential Commands

1. `htop` or `top` and sort by memory usage
2. `find /var/log -type f -name "*.log" -size +50M`
3. `openssl req -new -newkey rsa:2048 -nodes -keyout server.key -out server.csr`
4. `git clone <url>`
   `cd <repo>`
   `git checkout -b feature1`
   `git push -u origin feature1`

## Part 5: Users & Groups

1. `sudo useradd -r -s /usr/sbin/nologin service1`
2. Add to `/etc/security/limits.conf`: `developer1 hard nproc 10`
3. `setfacl -m g:developers:rw /opt/project/config.yml`
4. Install and configure LDAP client (`libnss-ldap`, `libpam-ldap`)
   Verify: `getent passwd ldapuser`