NEW
Font size
WorksheetsLinux Editors and Shell Scripting
Total questions: 20
Worksheet time: 2mins
Which command opens a file in nano editor?
vi filename
gedit filename
nano filename
open filename
Which command opens a file in vi editor?
vi filename
nano filename
gedit filename
open filename
Which mode in vi allows inserting text?
Command mode
Insert mode
Visual mode
Last-line mode
In vi, which key returns from insert mode to command mode?
Esc
i
:wq
Ctrl+C
Which command saves and exits in vi?
:w
:q!
:wq
:x!
Which command opens a file in gedit editor?
gedit filename
vi filename
nano filename
open filename
grep -i "linux" story.txt will:
Match only lowercase "linux"
Match "Linux" and "linux" (case-insensitive)
Replace "linux" with uppercase
Count number of lines
Which grep command counts lines containing 'The'?
grep "The" story.txt
grep -c "The" story.txt
grep -n "The" story.txt
grep -i "The" story.txt
sed 's/fox/cat/' story.txt will:
Replace all 'fox' with 'cat' globally
Replace only the first 'fox' per line
Replace 'cat' with 'fox'
Do nothing
To replace all 'The' with 'A' in a file:
sed 's/The/A/' story.txt
sed 's/The/A/g' story.txt
sed -i 's/A/The/g' story.txt
sed -g 's/A/The/' story.txt
Which sed command permanently modifies the file?
sed 's/lazy/active/g' story.txt
sed -i 's/lazy/active/g' story.txt
sed 's/lazy/active/' story.txt
sed --save 's/lazy/active/g' story.txt
Which command displays first 10 lines of file.txt?
head file.txt
tail file.txt
cat file.txt
less file.txt
Which command counts words in a file?
count file.txt
wc file.txt
grep file.txt
awk file.txt
Which command shows unique sorted lines in a file?
sort file.txt
uniq file.txt
sort file.txt | uniq
grep uniq file.txt
cut -d',' -f2 data.csv will:
Cut second character
Extract second field separated by comma
Remove commas
Show first two lines
Which command finds files named notes.txt in /home?
find /home -name notes.txt
grep notes.txt /home
locate notes.txt /home
search notes.txt /home
Which command prints 2nd column of data.txt separated by space?
cut -d' ' -f2 data.txt
awk '{print $2}' data.txt
grep 2 data.txt
wc -w data.txt
Which line starts a bash shell script?
#!/bin/bash
/bin/bash
bash
sh
Which syntax prints 'Hello World' in shell?
echo Hello World
print Hello World
cout << Hello World
Console.WriteLine(Hello World)
In leap_year.sh, which condition checks if a year is divisible by 4?
[ $((year % 2)) -eq 0 ]
[ $((year / 4)) -eq 1 ]
[ $((year % 4)) -eq 0 ]
[ $((year - 4)) -eq 0 ]
