Browse all practice questions for the OSCP Linux Practice Exam. Search by topic, open any question and review its full explanation, then test yourself in the practice quiz.

OSCP Linux Practice Exam course image
More practice questions

These questions are part of the practice quiz. Start practicing

  • How would you stop a service from starting at startup on SysV-style systems?
  • Which sequence best describes typical steps to compile software from a tarball?
  • Which directory is traditionally used for optional software packages?
  • Which command shows all UDP sockets and the programs that are using them?
  • Which directory is typically used for user-specific personal workspaces and data?
  • What does the command 'echo $?' display?
  • In the following sed command what is the g used for? sed 's/bob/jake/g'
  • What is the effect of sourcing a file in Bash?
  • Which command decrypts an encrypted archive to produce the original tar.gz file?
  • Which command can show the target of a symbolic link in a detailed listing?
  • Which option do you add to netstat to resolve hostnames to IP addresses in the output?
  • Which directory is described as the location for user installed binaries (programs)?
  • In Bash arithmetic, what does echo $((a++)) print?
  • Which directory is least associated with system configuration or device files?
  • Which command shows the manual page describing the file format for /etc/fstab?
  • Which command should you run to view the file format information for /etc/fstab?
  • If you're trying to throw a long command that's been piped multiple times into the background, how should you run it?
  • Where are user directories stored?
  • Which display filter shows only TCP traffic on port 80?
  • When renaming a file, what permissions are required?
  • If you wanted to edit /etc/passwd, /etc/shadow, /etc/group, and /etc/gshadow safely, which sequence of commands would you run respectively?
  • In a Bash case statement, what is the effect of the ;;& operator?
  • How would you add write permission for the owner and read/write permissions for the group to bob.txt using symbolic notation?
  • Where is the Linux kernel stored?
  • What does the arithmetic expression ((i<1?++i:--i)) do?
  • Which sequence sends only standard error to a file while leaving standard output untouched?
  • What does ESTABLISHED state indicate in netstat?
  • What does the shell do when you use > file.txt before a command?
  • How do you reference a positional parameter after $9?
  • If you can't remember the name of the variable that lets you run commands from any location, what would you type to find out?
  • In the permission string drwxrwxr-x, which permission is granted to others?
  • Given the Bash array animals defined as ("a dog" "a cat" "a fish"), what does echo ${animals[1]} print?
  • What are the symbols for boolean AND, OR, NOT in Bash and what is notable about their behavior?
  • Which of the following represents a valid set of SysV init commands to control the 'apache2' service?
  • What is the effect of echo test > file.txt 2>&1?
  • In a diff output, what does the change '2a3' mean?
  • What is the purpose of the plus sign in the date command's format specifier '+%F %T.%N %Z'?
  • What is the purpose of a here document in shell scripting?
  • What does the <<- redirection do in Bash here documents?
  • In a Bash loop, what does 'continue' do?
  • Which command demonstrates starting a process with the default niceness value?
  • What is a more efficient way to perform: if grep searchTerm; then echo hi; fi?
  • What are the basic regular expression characters?
  • After appending 'a cow' and 'a duck' to the animals array, how many elements does the array contain?
  • What happens if you try to use chown on a symbolic link without special options?
  • What's special about -eq compared to = and == ?
  • Which statement about hard links and symbolic links is true?
  • If you're trying to redirect stdout or stderr AND throw a long command that's been piped multiple times and includes multiple commands into the background, how do you need to do it?
  • How do you create a grep that matches a word that starts with any random character, followed by a lower case b, an upper case C or the numbers 1 through 3, then followed by anything that isn't the number 7 or the number 9, followed by any number of characters and ending with the letter j or any number. OR that matches at least one letter (capital or lower case) followed by exactly 17 numbers
  • Which directory typically contains system-wide configuration files in Linux?
  • What is the purpose of the /etc/fstab file?
  • What does the following loop do: while read i; echo $i; done < file.txt?
  • What is the new location for /var/log/messages?
  • What exit value does the command 'true' align with and what does that mean?
  • Which account has UID and GID of 0?
  • What does the loop for ((i=0;i<5;++i)); do echo $i; done print?
  • If a diff shows '2,4c2,4', what does this indicate about the change?
  • Which command unarchives a tar.gz file?
  • What is the standard alternative syntax to 'source filename' that achieves the same result?
  • In a diff output, what does a line starting with '<' denote?
  • In the command 'll &> file.txt', which streams are redirected to file.txt?
  • Which expression sets a default value for a variable if it is unset or empty?
  • Which redirection is represented by &> file.txt in Bash?
  • What does the redirection '2> /dev/null' accomplish in a shell command?
  • Which netstat state indicates the socket is listening for incoming connections?
  • How would you make a SysV-compatible service run at startup?
  • What is the effect of pressing Ctrl+Z while a process runs in the foreground?
  • If a script prints an error message to standard error using redirection, what is the conventional exit code to indicate failure?
  • What is the effect of > file.txt 2>&1?
  • When would you not want to use the nice command?
  • Which statement exits the current loop before its normal ending?
  • Where is the typical location for source code on a Linux system?
  • Which sequence correctly describes the typical steps to compile software from source?
  • What is the typical purpose of the /tmp directory in Unix-like systems?
  • Which command shows all TCP sockets and the programs that are using them, including listening services?
  • In a here document, what does the delimiter mark?
  • Which characters, if used, indicate you should use single quotes to prevent shell expansion?
  • Which command can verify a program's installation and locate its path (for example under /usr/local/bin)?
  • Which directory provides kernel information via a virtual filesystem?
  • What does the diff notation '4d3' indicate?
  • What type of content does /etc primarily store?
  • If you wish to list the contents of a directory, what permissions must you have for that directory?
  • Which command outputs the target path of a symbolic link?
  • If you encounter an unfamiliar parameter expansion in a Bash script, which manual page should you consult for more information?
  • Which statement best describes [[ expression ]] compared to [ expression ]?
  • Which directory stores shared libraries (.so)?
  • In a shell, using 'command || exit 1' ensures what behavior?
  • Which filter matches packets where IP is 1.1.1.1 and the TCP port is 80?
  • In the permission string rwx rwx rwx, what does this indicate for user, group, and others?
  • What prefix is used to run a script located in the current directory when it is not in PATH?
  • What is the output of echo ${hi:-bye} if hi is unset?
  • If a command produces no standard error, what will file.txt contain after using 2> file.txt?
  • Which command brings job 1 to the foreground?
  • Which directory is used for variable data such as database files and log files?
  • What does a /= 5 do to the variable a?
  • What directory is the root user's home directory?
  • If you wanted to pass arguments to a function that you made, how would you do it?
  • If you want to create a file in a directory, which permissions must you have?
  • Which command lowers the niceness of process 100 by 10?
  • Which command sends a job with ID 1 to the foreground?
  • Which command encrypts a tar.gz archive using the public key associated with Evan?
  • How do you sort by the 10th character in the 3rd column?
  • Where are log files stored?
  • Which directory is commonly used as the mount point for removable media such as USB drives on many Linux systems?
  • Which command creates a local variable inside a Bash function?
  • Which directory contains device files on a Linux system?
  • Which display filter shows only packets with IP address 1.1.1.1?
  • Which command shows the users currently logged in?
  • Which command lists the current user’s crontab entries?
  • What are the extended regular expression characters?
  • What is the default exit value of a command and what does it signify?
  • In the command 'll &> file.txt', what does the '&>' redirection do?
  • Can you use regex as the identifier in a Bash case statement?
  • What happens if you make a for loop without 'in blahblah'?
  • Which command shows what currently logged-in users are doing?
  • Which two commands disable and then re-enable shell history recording?
  • Which directory is a virtualized Linux file system that allows you to peek into how the kernel sees things?
  • What is another name for a tar.gz file?
  • In Bash arithmetic, what does echo $((++a)) print?
  • If you're looking for a man page for a command and nothing shows up (for example read), which resource should you use?
  • In a Bash case statement, which value will trigger dothisthing given the pattern 'case matchWord in 1) dothisthing ;; esac'?
  • Which command lists the public keys stored in your GPG keyring?
  • Which directory is the primary location for log files in a Linux system?
  • Which of the following is a valid use of the 'declare' command when locating PATH?
  • Which command enables a service to run at startup on systemd-based systems?
  • In the command 'll asdfkjsdfhk > file.txt 2>&1', which streams are written to file.txt?
  • Why is the permission string 'lrwxrwxrwx' not meaningful for a symbolic link?
  • Which command creates a tar.gz archive from a file named file.txt?
  • Which command sequence would recursively locate all .txt files from the root directory, print each path, then display the first 10 lines of that file, separated by a blank line, while discarding errors?
  • In Bash, how do you append text immediately after a variable's value without creating a second variable?
  • Which command starts the process of creating a new GPG key pair?
  • Which of the following is a valid alternative method to locate PATH without using printenv?
  • What is special about a negative nice value?
  • What is the difference between redirecting stdout with > file and redirecting stderr with 2> file?
  • What does 2> file.txt accomplish?
  • Which control flow statement leaves the current function when executed?
  • Which file is used to define system-wide cron jobs in many Linux distributions?
  • Process substitution in shells allows feeding the output of multiple commands into another command. Which command demonstrates this technique?
  • Which command interrupts a program that is in the foreground?
  • How would you set the same permissions in binary mode?
  • Which statement correctly describes the shell parameters $@, $$, and $!?
  • Which directory stores system binaries (programs)?
  • What exit value does the command 'false' align with and what does that mean?
  • Which command writes stdout to stdout.txt and stderr to stderr.txt?
  • What is the effect of quoting the end marker in a here-document?
  • You can sort by multiple columns using the sort command by doing what argument?
  • What does the shell parameter $0 store?
  • What does the code 'while :; do echo hi; done' do?
  • What does a %= 5 do to the variable a?
  • Which command edits the crontab for the current user?
  • In a find command using -exec, what placeholder represents the current file?
  • Which key combination stops a foreground process so it can be sent to the background?
  • Which statement best describes the /usr directory in this material?
  • Which line is used at the start of a Bash script to specify the interpreter?
  • In a long directory listing, what does the number 3495253 typically represent?
  • What is special about using the -p option with netstat?
  • Interpret the crontab line: 3 */1 * 3 6 wall hi. Which statement is true?
  • To use a library of functions in a Bash script, which command imports the functions into your script?
  • When using the ln command to create a link, which argument specifies the name of the link?
  • Which directory represents a virtualized filesystem that lets you inspect kernel information from user space?
  • What is the purpose of local variables in Bash, and how are they created?
  • To delete a file, what permissions do you need?
  • In crontab notation, which day of the week does 6 represent?
  • What is the difference between ${hi:-bye} and ${hi:=bye}?
  • Where are system binaries (programs) stored?
  • Which command would you use to view PATH directly?
  • What does the operation a += 5 do to the variable a?
  • Which command prints the contents of a file named file.txt to standard output?
  • Where do you store source code that is intended to be used by multiple users?
  • In Bash, what does the loop for i in "${animals[@]}"; do echo $i; done print?
  • With the command > file.txt 2> file2.txt, where do stdout and stderr go?
  • Which directory contains files that are variable, meaning they change constantly, such as database files and log files?
  • What is the effect of using >&2 in a command?
  • Which command changes only the group of bob.txt to 'baby'?
  • What is the effect of using prefix ++var versus postfix var++ in Bash arithmetic expansion?
  • Which command changes the owner to 'spankme' and the group to 'baby' for bob.txt?
  • How can you use extended regular expressions with grep or sed without using -E or -r?
  • Which command reveals how the shell will interpret a command, including if it is a built-in, alias, function, or path?
  • Which filter shows all TCP and ICMP packets?
  • Which command is used to determine which users have logged into the system?
  • What does the command awk '{print $1}' <(ll) <(cat /etc/passwd) do?
  • In shell scripting, which of the following is a zero exit code typically indicating success?
  • When following a symbolic link, whose permissions determine access?
  • Which command reveals how the shell will interpret a given command, including whether it's a built-in, alias, or function?
  • In Bash, which redirection sends both stdout and stderr to the same file?
  • Which command sends the job with job id 2 to the background?
  • In the permission string drwxrwxr-x, what does the first character 'd' indicate?
  • Which form supports regex matching within a conditional expression, enabling patterns like a string matching a regex?
  • What is the fastest way to create a test file with some sample text?
  • In crontab notation, which month does 3 represent?
  • In Bash, what does the shift command do?
Subscribe

Get the latest from Passetra

You can unsubscribe at any time. Read our privacy policy