Practice LPIC-1 GNU and Unix Commands questions with full explanations on every answer.
Start practicing
GNU and Unix Commands — choose a session length
Free · No account required
Click any question to see the full explanation and answer options, or start a focused practice session above.
A systems administrator needs to change the permissions of the file /home/user/script.sh so that the owner can read, write, and execute; the group can read and execute; and others have no access. Which command accomplishes this?
2Which TWO commands can be used to view the contents of a compressed file named archive.tar.gz without extracting it to disk?
3Refer 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?
4You 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?
5Arrange the steps to configure a static IP address on a Linux system using the command line.
6Order the steps to recover a forgotten root password on a Linux system.
7Match each Linux runlevel to its typical description.
8Match each device file naming pattern to its device type.
9A 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?
10An administrator wants to change the ownership of a file to user 'jane' and group 'staff'. Which command should be used?
11A 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?
12An administrator needs to copy a directory hierarchy from one server to another over SSH, preserving permissions, ownership, and timestamps. Which command is most appropriate?
13An 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?
14A 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?
15Refer to the exhibit. Which file has a special permission that allows a user to execute the file with the privileges of the file owner?
16Refer to the exhibit. The process with PID 1234 is in state 'Z'. What is the most likely cause and appropriate action?
17Refer to the exhibit. Which file system is full and what is the likely consequence if the administrator does not take action?
18Which TWO commands can be used to display the contents of a compressed file without decompressing it to disk? (Choose two.)
19Which 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.)
20Which THREE of the following are correct features of the 'grep' command? (Choose three.)
21A 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?
22After receiving a compressed tarball archive.tar.gz from a colleague, you want to list its contents without extracting. Which command should you use?
23A 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?
24Which command is used to compress a file with the highest compression ratio?
25Which 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?
26Which THREE of the following are valid symbolic mode expressions for the chmod command?
27Refer to the exhibit. When will the backup script run?
28A company runs a legacy application on a Linux server. The application fails to start after a reboot, claiming a 'cannot open shared object file' error. The system administrator checks the library path and finds that the required library is present in /usr/local/lib but the application cannot find it. The administrator has verified that the library file exists and is readable. Which of the following is the most likely cause and solution?
29A system administrator notices that the system's syslog messages are not being written to /var/log/messages. The rsyslog service is running. The administrator wants to check the configuration syntax of rsyslog. Which command should be used?
30A user reports that when they run 'ls -l' in their home directory, they see files but all files have permissions like '-rwxrwxrwx', which is unexpected. The system administrator checks and finds that the user's umask is set to 000. The user wants all new files to be created with default permissions of -rw-r--r-- (644) and directories that are drwxr-xr-x (755). What should the user set their umask to?
31Which TWO of the following commands output the total number of lines in a file?
32Refer to the exhibit. What will be the default permissions of a newly created file using the touch command?
33A web server runs Apache and generates extensive access logs. To conserve disk space, an administrator sets up a cron job that runs nightly at 2:00 AM. The job executes a shell script located at /usr/local/bin/rotate_logs.sh. The script is intended to find all .log files in /var/log/apache2/ that are older than 7 days, compress them with gzip, and move the compressed files to /var/log/archive/. However, after several days, the administrator notices that the /var/log partition is nearly full and the logs are not being compressed. The cron log shows the job ran at the scheduled time but produced no terminal output (stdout or stderr). The script itself contains no explicit echo statements or error handling. The administrator has root access and wants to diagnose the problem without disrupting the running web server. Which of the following is the most appropriate first step to identify the failure?
34Refer to the exhibit. A user runs 'python --version' and gets 'Python 3.9.1'. Which command would run Python 2 instead?
35Refer to the exhibit. Which statement is true about SSH root login on this server?
36Refer to the exhibit. The remount command fails. What is the most likely cause?
37Refer to the exhibit. Which users are allowed to use the 'at' command?
38Refer to the exhibit. The system fails to boot with an error 'UUID=e5f6g7h8 not found'. Which is the most likely cause?
The GNU and Unix Commands domain covers the key concepts tested in this area of the LPIC-1 exam blueprint published by LPI. Courseiva provides free domain-focused practice, mock exams, missed-question review, and readiness tracking across all LPIC-1 domains — no account required.
The Courseiva LPIC-1 question bank contains 38 questions in the GNU and Unix Commands domain. Click any question to see the full explanation and answer breakdown.
Start with a 10-question focused session to identify your baseline accuracy in this domain. Read every explanation — even for questions you answer correctly — to understand the reasoning. Once you score consistently above 80%, move to a 20–30 question session to confirm depth before moving to the next domain.
Yes — the session launcher on this page draws questions exclusively from the GNU and Unix Commands domain. Choose 10, 20, 30, or 50 questions for a focused session, or click individual questions to review them one by one.
Save your results, see per-domain analytics, and get readiness scores — free, for every certification.
Sign Up FreeFree forever · Every certification included