WorksheetsMastering Basic Linux Commands
Total questions: 15
Worksheet time: 8mins
Which command is used to list all files and directories in the current directory, including hidden ones?
ls -l
ls -a
ls -h
ls -d
What is the command to create a new directory called "assignments"?
mkdir assignments
newdir assignments
createdir assignments
makedir assignments
Which command will display the contents of a file named "notes.txt" one page at a time?
cat notes.txt
less notes.txt
open notes.txt
show notes.txt
How do you search for the word "science" in a file called "report.txt" using grep?
grep science report.txt
grep report.txt science
find science report.txt
search science report.txt
Which command is used to display your current working directory?
pwd
cwd
dir
whereami
What does the command "ls -lh" do?
Lists files in long format with human-readable file sizes
Lists only hidden files
Lists files in reverse order
Lists files with their permissions only
Which command will move a file named "essay.doc" to a directory called "Documents"?
mv essay.doc Documents/
cp essay.doc Documents/
move essay.doc Documents/
transfer essay.doc Documents/
What is the purpose of the "awk" command in Linux?
To search for patterns in files
To process and analyse text files, especially columns and fields
To list files and directories
To create new directories
Which command will show the IP address of your computer?
ifconfig
ipconfig
netstat
ping
How do you copy a file named "data.csv" to a USB drive mounted at "/media/usb"?
cp data.csv /media/usb/
mv data.csv /media/usb/
copy data.csv /media/usb/
send data.csv /media/usb/
Which command will recursively list all files and directories under the current directory?
ls -R
ls -a
ls -l
ls -d
What does the following command do? `grep -i "maths" results.txt`
Searches for "maths" in results.txt, case-sensitive
Searches for "maths" in results.txt, ignoring case
Searches for "maths" in all files
Deletes lines containing "maths" from results.txt
Which command will display the first 10 lines of a file called "summary.txt"?
head summary.txt
tail summary.txt
top summary.txt
start summary.txt
How do you use awk to print the second column from a file called "marks.txt"?
awk '{print $2}' marks.txt
awk '{print $1}' marks.txt
awk '{print $3}' marks.txt
awk '{print $0}' marks.txt
Which command will test the network connection to www.google.com?
ping www.google.com
netstat www.google.com
connect www.google.com
testnet www.google.com
