Linux Command Line & Shell Scripting Flashcards
7 cards from real 010-160 practice questions. Tap to flip, then mark Knew It or Still Learning โ missed cards come back until you master them.
Read the first 7 Linux Command Line & Shell Scripting flashcards as text
Which command substitution syntax stores the output of date into a variable TODAY?
Answer: TODAY=$(date)
$() performs command substitution, executing date and assigning its output to TODAY.
What is the purpose of the shebang line #!/bin/bash at the top of a script?
Answer: It specifies the interpreter that should execute the script
The shebang tells the OS which interpreter to use when the script is executed directly.
Which command displays the first 5 lines of a file named data.csv?
Answer: head -5 data.csv
head -n N (or the shorthand head -N) prints the first N lines of a file.
In bash, what does the double bracket [[ ... ]] provide compared to single bracket [ ... ]?
Answer: Double brackets support pattern matching and avoid word-splitting issues
[[ ]] is a bash keyword offering regex matching, no word-splitting, and safer quoting than POSIX [ ].
Which command would you use to find all files modified in the last 24 hours under /home?
Answer: find /home -mtime -1
find with -mtime -1 matches files whose modification time is less than 1 day (24 hours) ago.
What does the cut -d: -f1 /etc/passwd command output?
Answer: The first field (usernames) from each line of /etc/passwd
cut -d: sets colon as the delimiter, and -f1 extracts the first field, which is the username.
Which bash conditional correctly checks if a file named config.txt exists?
Answer: if [ -f config.txt ]; then
The -f test operator inside [ ] returns true if the specified path exists and is a regular file.