Unit 2: System Utilities and Basic Commands - Practice Quiz

CSE105 — Creative Engineering Workshop 60 Questions
0 Correct 0 Wrong 60 Left
0/60

1 In a typical Linux command, which part specifies additional information that modifies the command's behavior?

Command Structure Easy
A. Options (flags)
B. Terminal name
C. Shell prompt
D. Directory path

2 What is the general syntax of a Linux command?

Command Structure Easy
A. [arguments] options command
B. command [options] [arguments]
C. arguments [command] options
D. options command [arguments]

3 What does the cal command display?

cal Easy
A. A calendar
B. System calculator
C. Cache memory
D. Call logs

4 Which command is used to display the current system date and time?

date Easy
A. time
B. now
C. clock
D. date

5 What is the primary purpose of the echo command?

echo Easy
A. Play a sound
B. Copy files
C. Repeat the last command
D. Display a line of text or variable values

6 How does printf differ from echo in the shell?

printf Easy
A. It reads user input
B. It clears the screen
C. It allows formatted output using format specifiers
D. It only prints numbers

7 What is the bc command mainly used for?

bc Easy
A. Building C programs
B. Browsing the network
C. Backing up configuration
D. Performing arbitrary-precision calculations

8 Which feature makes bc more capable than expr for arithmetic?

bc Easy
A. It only handles integers
B. It runs faster
C. It supports floating-point numbers
D. It requires no input

9 What type of arithmetic does the expr command primarily evaluate?

expr Easy
A. Floating-point arithmetic
B. Integer arithmetic
C. Binary file conversion
D. Matrix operations

10 What is the result of the command expr 5 + 3?

expr Easy
A. 15
B. 8
C. 53
D. 5 + 3

11 What does the script command do?

script Easy
A. Records a typescript of a terminal session
B. Edits a text file
C. Schedules a task
D. Runs a shell script

12 What is the passwd command used for?

passwd Easy
A. Changing a user's password
B. Creating a new file
C. Listing passwords
D. Displaying the current path

13 What does the who command display?

who Easy
A. Installed software
B. System uptime only
C. The hostname only
D. Users currently logged into the system

14 What does the whoami command output?

whoami Easy
A. The system hostname
B. The kernel version
C. The current directory
D. The username of the current user

15 What does the uname command display by default?

uname Easy
A. The system date
B. The available memory
C. The operating system kernel name
D. The current username

16 What does the option -a do when used with uname?

uname -a Easy
A. Displays the date
B. Displays only the architecture
C. Displays active users
D. Displays all system information

17 What information does the uptime command provide?

uptime Easy
A. How long the system has been running
B. The upload speed
C. The current directory
D. The number of files open

18 What does the tty command display?

tty Easy
A. The system time
B. The total typed characters
C. The network type
D. The filename of the current terminal

19 What is the stty command used for?

stty Easy
A. Changing and printing terminal line settings
B. Setting the system time
C. Stopping running processes
D. Starting a new terminal

20 Which key is commonly used to quit a manual page opened with man?

man command and manual page navigation Easy
A. q
B. x
C. c
D. e

21 In the command ls -l -a /home, which part represents the arguments (as opposed to options)?

Command Structure Medium
A. /home
B. -l
C. -l and -a
D. ls

22 Which command displays the calendar for the entire year 2024?

cal Medium
A. cal --full 2024
B. cal 2024
C. cal -y 2024
D. cal year 2024

23 What does the command date +"%Y-%m-%d" output?

date Medium
A. The current time only in HH:MM:SS
B. The date formatted as 25/09/2026
C. The date formatted as 2026-09-25
D. The day of the week name

24 Which option allows echo to interpret escape sequences such as \n (newline)?

echo Medium
A. echo -n
B. echo -E
C. echo -s
D. echo -e

25 What is the output of printf "%.2f\n" 3.14159?

printf Medium
A. 3
B. 3.14
C. 3.14159
D. 3.142

26 Which command computes to give the result 2.50?

bc Medium
A. echo "scale=2; 5/2" | bc
B. echo "5/2" | bc
C. bc 5/2
D. echo "precision=2; 5/2" | bc

27 What is the result of expr 10 % 3?

expr Medium
A. 3
B. 3.33
C. 0
D. 1

28 Why does expr 5 * 3 often produce an error in the shell?

expr Medium
A. expr only accepts single-digit numbers
B. expr cannot perform multiplication
C. The * is interpreted by the shell as a wildcard and must be escaped
D. Spaces are not allowed around operators in expr

29 What is the primary purpose of the script command?

script Medium
A. To schedule a command to run later
B. To create a new executable shell script
C. To record a terminal session, including input and output, into a file
D. To execute a shell script file

30 When a regular (non-root) user runs passwd with no arguments, what happens?

passwd Medium
A. It displays the current password
B. It locks the user account
C. It changes the root password
D. It prompts to change that user's own password

31 Which command shows a list of all users currently logged into the system?

who Medium
A. whoami
B. users -l
C. w -a
D. who

32 How does whoami differ from who am i?

whoami Medium
A. whoami requires root privileges; who am i does not
B. whoami shows all users; who am i shows one user
C. They produce identical output in all cases
D. 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?

uname Medium
A. The kernel name (e.g., Linux)
B. The machine hardware architecture
C. The full hostname
D. The kernel version number

34 What information does uname -a provide compared to plain uname?

uname -a Medium
A. All available system info: kernel name, hostname, kernel version, and architecture
B. Only the kernel architecture
C. The list of all logged-in users
D. Only the hostname and kernel name

35 In the output of uptime, what do the three numbers after "load average" represent?

uptime Medium
A. The uptime in hours, minutes, and seconds
B. System load over the last 1, 5, and 15 minutes
C. CPU temperature at three sensors
D. The number of users logged in over three days

36 What does the tty command print?

tty Medium
A. The list of all terminals in use
B. The type of the terminal emulator
C. The total time the terminal has been open
D. The filename of the terminal connected to standard input (e.g., /dev/pts/0)

37 Which command displays the current terminal line settings, including baud rate and control characters?

stty Medium
A. tty -l
B. stty --show
C. stty list
D. stty -a

38 While viewing a man page, which key is used to search forward for a pattern?

man command and manual page navigation Medium
A. s followed by the pattern
B. / followed by the pattern
C. f followed by the pattern
D. ? followed by the pattern

39 What is the purpose of the section number in a command like man 5 passwd?

man command and manual page navigation Medium
A. It requests version 5 of the passwd command
B. It shows only the 5th page of the manual
C. It specifies which manual section to look in (here, file formats)
D. It limits the output to 5 lines

40 Given the variable assignment name=Alice, what does echo "Hello $name" output?

echo Medium
A. Hello
B. Hello $name
C. Hello Alice
D. $name Hello

41 Consider the command ls -l -a /home versus ls -la /home. Which statement about Unix command structure is most accurate?

Command Structure Hard
A. Only the first is valid because each option requires its own hyphen
B. Both are equivalent because short options can be grouped after a single hyphen
C. Both fail because /home must precede the options
D. The second is invalid because -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 Hard
A. Leap-year miscalculation for the year 1752
B. The adoption of the Gregorian calendar dropped those days
C. Those days were public holidays and are hidden
D. A bug in the cal implementation that was never fixed

43 What does date -d "next friday" +%Y-%m-%d output when run on a Friday?

date Hard
A. Yesterday's date rounded to Friday
B. An error because "next friday" is invalid
C. Today's date since it is already Friday
D. The date of the following Friday (7 days later)

44 Given echo -e "a\tb\nc", assuming -e is honored, how many lines and what layout appear?

echo Hard
A. Three lines: a, b, c
B. One line: a\tb\nc printed literally
C. Two lines: a<tab>b then c
D. One line: a b c separated by spaces

45 What does printf "%05.2f\n" 3.14159 output?

printf Hard
A. 00003.14
B. 03.142
C. 03.14
D. 3.142

46 Why does echo "10/3" | bc return 3 while echo "scale=4; 10/3" | bc returns 3.3333?

bc Hard
A. bc rounds by default unless overridden
B. bc requires the -l flag for any division
C. Default scale is 0, so division truncates to an integer
D. The first uses integer mode and the second floating mode

47 What is the result of expr 5 \* 3 and why is the backslash needed?

expr Hard
A. 15; the backslash prevents the shell from expanding * as a glob
B. 15; the backslash is required by expr syntax itself
C. An error; expr cannot multiply
D. 53; the backslash concatenates the operands

48 What does expr length "hello world" return, and what does it demonstrate about expr?

expr Hard
A. 10; expr ignores whitespace in length
B. 11; expr counts all characters including the space
C. 2; expr counts words not characters
D. An error; 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 Hard
A. The log keeps recording until the shell ends, then is saved
B. script automatically times out after 60 seconds
C. Nothing is written until exit is typed
D. The log file is corrupted and unusable

50 A non-root user runs passwd anotheruser. What is the most likely outcome?

passwd Hard
A. The other user's password is changed silently
B. A new account named anotheruser is created
C. The current user's own password is changed instead
D. Permission denied because only root may change another user's password

51 How does the output of who am i differ from whoami?

who Hard
A. who am i shows the login line, terminal, and login time; whoami shows only the effective username
B. whoami shows login time while who am i shows only the name
C. They are identical aliases
D. 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?

whoami Hard
A. root, because whoami reports the effective user ID
B. Both alice and root
C. An error because whoami takes no privileges
D. 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 Hard
A. The 32-bit program is silently recompiled at runtime
B. uname -m reports hardware architecture, which can run compatible 32-bit binaries
C. x86_64 means 32-bit in uname notation
D. 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?

uname -a Hard
A. Only kernel name and machine architecture
B. Kernel name, hostname, kernel release, version, machine, and OS
C. Only hostname and uptime
D. CPU temperature, memory, and disk usage

55 The uptime output ends with load average: 4.00, 2.00, 1.00 on a 4-core system. What is the correct interpretation?

uptime Hard
A. The 1-minute load fully saturates all 4 cores while longer averages show it was lighter before
B. The system is 400% overloaded across all time windows
C. The values represent memory usage in gigabytes
D. Load average measures percentage CPU, so it is 4% busy

56 Running tty inside a script whose input is redirected from a file (./script < input.txt) is likely to print what?

tty Hard
A. not a tty and return a non-zero exit status
B. The controlling terminal path such as /dev/pts/0
C. The contents of input.txt
D. An empty line with exit status 0

57 A terminal displays typed characters twice or behaves oddly after a program crash. Which command best restores sane settings?

stty Hard
A. stty raw
B. stty sane
C. stty 0
D. stty -echo

58 What is the effect of stty -echo followed by reading input, and why is it commonly used?

stty Hard
A. The terminal width is set to zero columns
B. Typed characters are not displayed, useful for password entry
C. All input is converted to uppercase
D. Input is echoed twice for confirmation

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 command and manual page navigation Hard
A. man printf.h
B. man 3 printf
C. man --shell printf
D. man -k printf

60 Inside man's pager, you type /socket then press n twice. What happens?

man command and manual page navigation Hard
A. It opens the manual for the socket command
B. It exits the pager after two matches
C. It deletes the second occurrence of socket
D. It searches forward for socket and jumps to the third match