Courseiva

LPIC-1 · topic practice

GNU and Unix Commands practice questions

This domain covers working at the Linux command line: running commands, managing files and directories, redirecting input/output, using pipes and filters, editing text, and controlling permissions. LPIC-1 tests it through scenario questions, exhibits of terminal output, and ordering tasks such as configuring a static IP or setting exact file modes.

Courseiva uses original exam-style practice questions designed for learning and revision. The goal is to understand the concepts, recognise exam patterns, and improve through explanations — not memorise copied exam dumps.

Editorial oversight:Johnson Ajibi· MSc IT Security, IEEE Senior Member
20 questionsDomain: GNU and Unix Commands

What the exam tests

What to know about GNU and Unix Commands

Be able to run and locate commands, manage files and permissions, and redirect streams confidently. The single most important skill is reading a scenario and choosing the exact command and arguments, especially correct chmod mode syntax and redirection operators.

Running commands and locating executables with which, type, and PATH manipulation

File and directory operations using cp, mv, rm, mkdir, find, and tar

Stream redirection and pipes with >, >>, <, |, tee, and xargs

Permission and ownership control via chmod symbolic/octal modes, chown, and umask

Watch out for

Common GNU and Unix Commands exam traps

  • ▸Confusing chmod symbolic syntax: u, g, o, a with +, -, = and r, w, x; mixing commas and spaces incorrectly.
  • ▸Assuming python or python3 always points to a specific version instead of checking with which, type, or --version.
  • ▸Mixing up > (overwrite) and >> (append), or forgetting that 2> redirects stderr while 2>&1 merges it.

Practice set

GNU and Unix Commands questions

20 questions · select your answer, then reveal the explanation

Refer to the exhibit. An administrator needs to edit /etc/example.conf to change setting1 to 'production' and add a new line 'setting2=value' after the include line. The file must be edited in place without creating a backup. Which command sequence achieves this?

Network Topology
-rw-rrRefer to the exhibit.# ls -l# cat /etc/example.conf# Configuration filesetting1=default# Include other configinclude /etc/example.d/*.conf

You are a Linux administrator for a company that runs a web server on a system with limited disk space. The web server logs are stored in /var/log/httpd/access_log and grow quickly. The operations team requires that the most recent logs be available for troubleshooting, but logs older than 7 days must be compressed to save space. You decide to implement log rotation using logrotate. The logrotate configuration file for httpd currently contains:

/var/log/httpd/*.log { daily rotate 7 compress delaycompress missingok notifempty sharedscripts postrotate /bin/systemctl reload httpd 2>/dev/null || true endscript

}

After applying this configuration, you notice that log files are being compressed immediately instead of after one rotation. What is the most likely cause and the correct step to fix this?

Order the steps to recover a forgotten root password on a Linux system.

Drag or tap steps into the slots.

Steps
Order
1Step 1
2Step 2
3Step 3
4Step 4
5Step 5

Match each device file naming pattern to its device type.

Drag a concept onto its matching description — or click a concept then click the description.

Concepts
Matches

First SCSI/SATA disk

First NVMe SSD

First serial port (COM1)

First loopback device

First software RAID device

A systems administrator needs to find all files in /var/log that were modified in the last 24 hours and contain the word 'error'. Which command accomplishes this?

An administrator wants to change the ownership of a file to user 'jane' and group 'staff'. Which command should be used?

A developer is troubleshooting a shell script that uses the variable $HOME but it outputs nothing when the script runs. The script is executed with ./script.sh from an interactive shell. What is the most likely cause?

An administrator runs the command 'find / -name "*.conf" 2>/dev/null | head -n 10' and notices that the command returns very quickly. Which statement best describes what happened?

A script uses 'set -e' and then executes 'grep pattern file'. If the pattern is not found, the script exits. Which of the following modifications would prevent the script from exiting while still allowing detection of the pattern's absence?

Refer to the exhibit. Which file has a special permission that allows a user to execute the file with the privileges of the file owner?

Exhibit

-rwxr-xr-x 1 root root 12345 Jan 1 12:00 /usr/bin/myapp
-rwsr-xr-x 1 root root 23456 Jan 1 12:00 /usr/bin/su
-rw-rw-rw- 1 user1 user1 0 Jan 1 12:00 /tmp/shared

Refer to the exhibit. Which file system is full and what is the likely consequence if the administrator does not take action?

Exhibit

Filesystem     1K-blocks    Used Available Use% Mounted on
/dev/sda1       10485760 9437184   1048576  90% /
/dev/sdb1       20971520 20971520       0 100% /var

Which TWO of the following are valid methods to run a shell script named 'script.sh' using the bash shell, assuming the script has execute permission? (Choose two.)

A system administrator wants to list all files in a directory that have been modified in the last 24 hours. Which command would be most appropriate?

A developer wants to change the ownership of all files in a directory tree to the user 'www-data' and group 'www-data', but only files that are currently owned by user 'nobody'. Which command accomplishes this?

Which TWO commands can be used to display the contents of a compressed text file (e.g., .gz, .bz2) directly to standard output without decompressing to disk?

Refer to the exhibit. The system fails to boot with an error 'UUID=e5f6g7h8 not found'. Which is the most likely cause?

Exhibit

$ ls -l /dev/disk/by-uuid/
total 0
lrwxrwxrwx 1 root root 10 Dec 17 10:00 a1b2c3d4 -> ../../sda1
lrwxrwxrwx 1 root root 10 Dec 17 10:00 e5f6g7h8 -> ../../sda2
$ blkid /dev/sda1
/dev/sda1: UUID="a1b2c3d4" TYPE="ext4"
$ blkid /dev/sda2
/dev/sda2: UUID="e5f6g7h8" TYPE="ext4"
$ cat /etc/fstab
UUID=a1b2c3d4 /boot ext4 defaults 0 2
UUID=e5f6g7h8 / ext4 defaults 0 1

Refer to the exhibit. Which of the following is true about SSH access to this server?

Exhibit

# /etc/ssh/sshd_config snippet
PermitRootLogin no
PasswordAuthentication yes
ChallengeResponseAuthentication no
UsePAM yes
AllowUsers alice bob
DenyUsers charlie
Match User alice
    PasswordAuthentication no
Match User bob
    PasswordAuthentication yes

Refer to the exhibit. What is the expected outcome of the kill command?

Exhibit

$ ps aux | grep httpd
root     12345  0.0  0.2 123456 1234 ?        Ss   10:00   0:00 /usr/sbin/httpd -k start
apache   12346  0.0  0.3 123456 2345 ?        S    10:00   0:00 /usr/sbin/httpd -k start
apache   12347  0.0  0.3 123456 2345 ?        S    10:00   0:00 /usr/sbin/httpd -k start
apache   12348  0.0  0.3 123456 2345 ?        S    10:00   0:00 /usr/sbin/httpd -k start
apache   12349  0.0  0.3 123456 2345 ?        S    10:00   0:00 /usr/sbin/httpd -k start
$ kill -HUP 12345

Refer to the exhibit. What type of traffic is being captured?

Exhibit

$ sudo tcpdump -i eth0 -c 5 -n
listening on eth0, link-type EN10MB (Ethernet), capture size 262144 bytes
10:00:00.123456 IP 192.168.1.100.12345 > 10.0.0.1.80: Flags [S], seq 123, win 65535, options [mss 1460], length 0
10:00:00.123789 IP 10.0.0.1.80 > 192.168.1.100.12345: Flags [S.], seq 456, ack 124, win 65535, options [mss 1460], length 0
10:00:00.124000 IP 192.168.1.100.12345 > 10.0.0.1.80: Flags [.], ack 457, win 65535, length 0
10:00:00.124500 IP 192.168.1.100.12345 > 10.0.0.1.80: Flags [P.], seq 124:200, ack 457, win 65535, length 76
10:00:00.125000 IP 10.0.0.1.80 > 192.168.1.100.12345: Flags [.], ack 201, win 65535, length 0

A junior administrator is asked to create a compressed archive of the /home/projects directory. The archive must preserve file permissions and ownership, and must be named projects.tar.bz2. Which command should the administrator use?

Free account

Track your progress over time

Create a free account to save your results and see which topics improve across sessions.

Focused GNU and Unix Commands sessions

Start a GNU and Unix Commands only practice session

Every question in these sessions is drawn from the GNU and Unix Commands domain — nothing else.

Related practice questions

Related LPIC-1 topic practice pages

Move into related areas when this topic feels solid.

Frequently asked questions

What does the LPIC-1 exam test about GNU and Unix Commands?
Be able to run and locate commands, manage files and permissions, and redirect streams confidently. The single most important skill is reading a scenario and choosing the exact command and arguments, especially correct chmod mode syntax and redirection operators.
How should I use these practice questions?
Select your answer before revealing the explanation. Then read why each option is right or wrong — this active recall approach builds retention far faster than re-reading notes.
Can I practise just GNU and Unix Commands questions in a focused session?
Yes — the session launcher on this page draws every question from the GNU and Unix Commands domain. Use a 10-question session first to gauge your baseline, then move to 20 or 30 once the weak spots are clear.
Where can I practise other LPIC-1 topics?
Use the topic links above to move to related areas, or go back to the LPIC-1 question bank to see all topics.
Are these real exam questions or dumps?
These are original practice questions written to test the same concepts the LPIC-1 exam covers. They are not copied from any real exam or dump site.