Unit 2: System Utilities and Basic Commands - Practice Quiz
1 In a typical Linux command, which part specifies additional information that modifies the command's behavior?
2 What is the general syntax of a Linux command?
[arguments] options command
command [options] [arguments]
arguments [command] options
options command [arguments]
3
What does the cal command display?
4 Which command is used to display the current system date and time?
time
now
clock
date
5
What is the primary purpose of the echo command?
6
How does printf differ from echo in the shell?
7
What is the bc command mainly used for?
8
Which feature makes bc more capable than expr for arithmetic?
9
What type of arithmetic does the expr command primarily evaluate?
10
What is the result of the command expr 5 + 3?
15
8
53
5 + 3
11
What does the script command do?
12
What is the passwd command used for?
13
What does the who command display?
14
What does the whoami command output?
15
What does the uname command display by default?
16
What does the option -a do when used with uname?
17
What information does the uptime command provide?
18
What does the tty command display?
19
What is the stty command used for?
20
Which key is commonly used to quit a manual page opened with man?
q
x
c
e
21
In the command ls -l -a /home, which part represents the arguments (as opposed to options)?
/home
-l
-l and -a
ls
22 Which command displays the calendar for the entire year 2024?
cal --full 2024
cal 2024
cal -y 2024
cal year 2024
23
What does the command date +"%Y-%m-%d" output?
HH:MM:SS
25/09/2026
2026-09-25
24
Which option allows echo to interpret escape sequences such as \n (newline)?
echo -n
echo -E
echo -s
echo -e
25
What is the output of printf "%.2f\n" 3.14159?
3
3.14
3.14159
3.142
26
Which command computes to give the result 2.50?
echo "scale=2; 5/2" | bc
echo "5/2" | bc
bc 5/2
echo "precision=2; 5/2" | bc
27
What is the result of expr 10 % 3?
3
3.33
0
1
28
Why does expr 5 * 3 often produce an error in the shell?
expr only accepts single-digit numbers
expr cannot perform multiplication
* is interpreted by the shell as a wildcard and must be escaped
expr
29
What is the primary purpose of the script command?
30
When a regular (non-root) user runs passwd with no arguments, what happens?
31 Which command shows a list of all users currently logged into the system?
whoami
users -l
w -a
who
32
How does whoami differ from who am i?
whoami requires root privileges; who am i does not
whoami shows all users; who am i shows one user
whoami prints the effective user ID name; who am i prints login session details of the current terminal
33
What does the bare command uname typically print?
Linux)
34
What information does uname -a provide compared to plain uname?
35
In the output of uptime, what do the three numbers after "load average" represent?
36
What does the tty command print?
/dev/pts/0)
37 Which command displays the current terminal line settings, including baud rate and control characters?
tty -l
stty --show
stty list
stty -a
38 While viewing a man page, which key is used to search forward for a pattern?
s followed by the pattern
/ followed by the pattern
f followed by the pattern
? followed by the pattern
39
What is the purpose of the section number in a command like man 5 passwd?
40
Given the variable assignment name=Alice, what does echo "Hello $name" output?
Hello
Hello $name
Hello Alice
$name Hello
41
Consider the command ls -l -a /home versus ls -la /home. Which statement about Unix command structure is most accurate?
/home must precede the options
-la is interpreted as a long option
42
The command cal 9 1752 on many Unix systems shows September 1752 missing 11 days (3rd to 13th). What is the reason?
cal implementation that was never fixed
43
What does date -d "next friday" +%Y-%m-%d output when run on a Friday?
44
Given echo -e "a\tb\nc", assuming -e is honored, how many lines and what layout appear?
a, b, c
a\tb\nc printed literally
a<tab>b then c
a b c separated by spaces
45
What does printf "%05.2f\n" 3.14159 output?
00003.14
03.142
03.14
3.142
46
Why does echo "10/3" | bc return 3 while echo "scale=4; 10/3" | bc returns 3.3333?
bc rounds by default unless overridden
bc requires the -l flag for any division
scale is 0, so division truncates to an integer
47
What is the result of expr 5 \* 3 and why is the backslash needed?
15; the backslash prevents the shell from expanding * as a glob
15; the backslash is required by expr syntax itself
expr cannot multiply
53; the backslash concatenates the operands
48
What does expr length "hello world" return, and what does it demonstrate about expr?
10; expr ignores whitespace in length
11; expr counts all characters including the space
2; expr counts words not characters
length is not an expr operator
49
A user runs script session.log, executes commands, then forgets to type exit. What is the consequence?
script automatically times out after 60 seconds
exit is typed
50
A non-root user runs passwd anotheruser. What is the most likely outcome?
anotheruser is created
51
How does the output of who am i differ from whoami?
who am i shows the login line, terminal, and login time; whoami shows only the effective username
whoami shows login time while who am i shows only the name
who am i shows all logged-in users; whoami shows only one
52
After running sudo whoami in a terminal logged in as user alice, what is printed?
root, because whoami reports the effective user ID
alice and root
whoami takes no privileges
alice, because the real user is unchanged
53
Why might uname -m return x86_64 while a 32-bit program still runs fine on the same machine?
uname -m reports hardware architecture, which can run compatible 32-bit binaries
x86_64 means 32-bit in uname notation
uname -m reports the kernel version, unrelated to binaries
54
Which fields does uname -a combine that individual uname flags would otherwise require multiple invocations to obtain?
55
The uptime output ends with load average: 4.00, 2.00, 1.00 on a 4-core system. What is the correct interpretation?
56
Running tty inside a script whose input is redirected from a file (./script < input.txt) is likely to print what?
not a tty and return a non-zero exit status
/dev/pts/0
input.txt
57 A terminal displays typed characters twice or behaves oddly after a program crash. Which command best restores sane settings?
stty raw
stty sane
stty 0
stty -echo
58
What is the effect of stty -echo followed by reading input, and why is it commonly used?
59
You want the manual entry for the printf C library function, but man printf shows the shell command. Which command targets the C function?
man printf.h
man 3 printf
man --shell printf
man -k printf
60
Inside man's pager, you type /socket then press n twice. What happens?
socket command
socket
socket and jumps to the third match
Did this save you a night before the exam?
LPU Notes is free, and it stays free. Ads cover part of the server bill. The rest comes out of a student's own pocket: the domain, the storage, and keeping the site up through the weeks everyone needs it at once.
The payment button didn't load. An ad blocker or a filtered network is the usual reason. to try again.
Nothing here is ever locked, and nothing unlocks. Chip in only if it was worth it. What it pays for →