Q: Which command is used to determine the type of a file (e.g., ASCII text,
directory)?
ANSWER file
Q: How do you list all files, including hidden files (those starting with .)?
ANSWER ls -a
Q: What command displays the full path of the current working directory?
ANSWER pwd
Q: How do you change the shell to the Zsh shell temporarily?
ANSWER zsh (or just typing the shell name)
Q: Which command prints the command history of the current user?
ANSWER history
Q: How do you execute command number 45 from your history?
ANSWER !45
Q: Which variable stores the path to the home directory of the current user?
ANSWER $HOME
Q: What is the difference between ~ and $HOME?
ANSWER They are essentially the same; ~ is a shortcut for the home directory
path stored in $HOME.
Q: How do you set a temporary environment variable called MYVAR to "hello"?
ANSWER export MYVAR="hello"
,Q: How do you unset an environment variable?
ANSWER unset MYVAR
Q: Which command displays all currently defined environment variables?
ANSWER env or printenv
Q: What does the echo $$ command display?
ANSWER The Process ID (PID) of the current shell.
Q: How do you quote a variable to prevent word splitting and globbing?
ANSWER "$VAR" (double quotes)
Q: What is the purpose of single quotes ' ' in Bash?
ANSWER They prevent all shell expansions (variables, wildcards).
Q: Which command is used to read user input into a variable in a script?
ANSWER read
Q: How do you check the exit status of the previous command?
ANSWER echo $?
Q: What exit status indicates success?
ANSWER 0
Q: How do you run a command in the background?
ANSWER Append & (e.g., sleep 10 &).
Q: How do you bring a background job to the foreground?
ANSWER fg %jobnumber
Q: How do you list stopped and background jobs?
ANSWER jobs
Standard Streams & Pipes
21. Q: What represents Standard Input (stdin)?
ANSWER File descriptor 0
22. Q: What represents Standard Output (stdout)?
, ANSWER File descriptor 1
23. Q: What represents Standard Error (stderr)?
ANSWER File descriptor 2
24. Q: How do you redirect stdout to a file, overwriting the file?
ANSWER >
25. Q: How do you redirect stdout to a file, appending to the file?
ANSWER >>
26. Q: How do you redirect stderr to a file called error.log?
ANSWER command 2> error.log
27. Q: How do you redirect both stdout and stderr to the same file?
ANSWER command > file.txt 2>&1
28. Q: What does the | (pipe) operator do?
ANSWER It passes the stdout of one command as the stdin to another.
29. Q: How do you send the output of ls to both the screen and a file?
ANSWER ls | tee file.txt
30. Q: How do you redirect input from a file called input.txt to a command?
ANSWER command < input.txt
31. Q: What is xargs used for?
ANSWER To build and execute command lines from standard input (often
used with find and pipe).
32. Q: How do you use xargs to delete files found by find?
ANSWER find . -name "*.tmp" | xargs rm
33. Q: What is a "Here Document"?
ANSWER A way to pass multiple lines of input to a command (e.g., command
<< EOF).
34. Q: What is a "Here String"?
directory)?
ANSWER file
Q: How do you list all files, including hidden files (those starting with .)?
ANSWER ls -a
Q: What command displays the full path of the current working directory?
ANSWER pwd
Q: How do you change the shell to the Zsh shell temporarily?
ANSWER zsh (or just typing the shell name)
Q: Which command prints the command history of the current user?
ANSWER history
Q: How do you execute command number 45 from your history?
ANSWER !45
Q: Which variable stores the path to the home directory of the current user?
ANSWER $HOME
Q: What is the difference between ~ and $HOME?
ANSWER They are essentially the same; ~ is a shortcut for the home directory
path stored in $HOME.
Q: How do you set a temporary environment variable called MYVAR to "hello"?
ANSWER export MYVAR="hello"
,Q: How do you unset an environment variable?
ANSWER unset MYVAR
Q: Which command displays all currently defined environment variables?
ANSWER env or printenv
Q: What does the echo $$ command display?
ANSWER The Process ID (PID) of the current shell.
Q: How do you quote a variable to prevent word splitting and globbing?
ANSWER "$VAR" (double quotes)
Q: What is the purpose of single quotes ' ' in Bash?
ANSWER They prevent all shell expansions (variables, wildcards).
Q: Which command is used to read user input into a variable in a script?
ANSWER read
Q: How do you check the exit status of the previous command?
ANSWER echo $?
Q: What exit status indicates success?
ANSWER 0
Q: How do you run a command in the background?
ANSWER Append & (e.g., sleep 10 &).
Q: How do you bring a background job to the foreground?
ANSWER fg %jobnumber
Q: How do you list stopped and background jobs?
ANSWER jobs
Standard Streams & Pipes
21. Q: What represents Standard Input (stdin)?
ANSWER File descriptor 0
22. Q: What represents Standard Output (stdout)?
, ANSWER File descriptor 1
23. Q: What represents Standard Error (stderr)?
ANSWER File descriptor 2
24. Q: How do you redirect stdout to a file, overwriting the file?
ANSWER >
25. Q: How do you redirect stdout to a file, appending to the file?
ANSWER >>
26. Q: How do you redirect stderr to a file called error.log?
ANSWER command 2> error.log
27. Q: How do you redirect both stdout and stderr to the same file?
ANSWER command > file.txt 2>&1
28. Q: What does the | (pipe) operator do?
ANSWER It passes the stdout of one command as the stdin to another.
29. Q: How do you send the output of ls to both the screen and a file?
ANSWER ls | tee file.txt
30. Q: How do you redirect input from a file called input.txt to a command?
ANSWER command < input.txt
31. Q: What is xargs used for?
ANSWER To build and execute command lines from standard input (often
used with find and pipe).
32. Q: How do you use xargs to delete files found by find?
ANSWER find . -name "*.tmp" | xargs rm
33. Q: What is a "Here Document"?
ANSWER A way to pass multiple lines of input to a command (e.g., command
<< EOF).
34. Q: What is a "Here String"?