wayground logo

Free Printable Worksheets

NEW

Font size

S
M
L
XL
Worksheets

Linux Editors and Shell Scripting

Total questions: 20

Worksheet time: 2mins

Name
Class
Date
1.

Which command opens a file in nano editor?

a)

vi filename

b)

gedit filename

c)

nano filename

d)

open filename

2.

Which command opens a file in vi editor?

a)

vi filename

b)

nano filename

c)

gedit filename

d)

open filename

3.

Which mode in vi allows inserting text?

a)

Command mode

b)

Insert mode

c)

Visual mode

d)

Last-line mode

4.

In vi, which key returns from insert mode to command mode?

a)

Esc

b)

i

c)

:wq

d)

Ctrl+C

5.

Which command saves and exits in vi?

a)

:w

b)

:q!

c)

:wq

d)

:x!

6.

Which command opens a file in gedit editor?

a)

gedit filename

b)

vi filename

c)

nano filename

d)

open filename

7.

grep -i "linux" story.txt will:

a)

Match only lowercase "linux"

b)

Match "Linux" and "linux" (case-insensitive)

c)

Replace "linux" with uppercase

d)

Count number of lines

8.

Which grep command counts lines containing 'The'?

a)

grep "The" story.txt

b)

grep -c "The" story.txt

c)

grep -n "The" story.txt

d)

grep -i "The" story.txt

9.

sed 's/fox/cat/' story.txt will:

a)

Replace all 'fox' with 'cat' globally

b)

Replace only the first 'fox' per line

c)

Replace 'cat' with 'fox'

d)

Do nothing

10.

To replace all 'The' with 'A' in a file:

a)

sed 's/The/A/' story.txt

b)

sed 's/The/A/g' story.txt

c)

sed -i 's/A/The/g' story.txt

d)

sed -g 's/A/The/' story.txt

11.

Which sed command permanently modifies the file?

a)

sed 's/lazy/active/g' story.txt

b)

sed -i 's/lazy/active/g' story.txt

c)

sed 's/lazy/active/' story.txt

d)

sed --save 's/lazy/active/g' story.txt

12.

Which command displays first 10 lines of file.txt?

a)

head file.txt

b)

tail file.txt

c)

cat file.txt

d)

less file.txt

13.

Which command counts words in a file?

a)

count file.txt

b)

wc file.txt

c)

grep file.txt

d)

awk file.txt

14.

Which command shows unique sorted lines in a file?

a)

sort file.txt

b)

uniq file.txt

c)

sort file.txt | uniq

d)

grep uniq file.txt

15.

cut -d',' -f2 data.csv will:

a)

Cut second character

b)

Extract second field separated by comma

c)

Remove commas

d)

Show first two lines

16.

Which command finds files named notes.txt in /home?

a)

find /home -name notes.txt

b)

grep notes.txt /home

c)

locate notes.txt /home

d)

search notes.txt /home

17.

Which command prints 2nd column of data.txt separated by space?

a)

cut -d' ' -f2 data.txt

b)

awk '{print $2}' data.txt

c)

grep 2 data.txt

d)

wc -w data.txt

18.

Which line starts a bash shell script?

a)

#!/bin/bash

b)

/bin/bash

c)

bash

d)

sh

19.

Which syntax prints 'Hello World' in shell?

a)

echo Hello World

b)

print Hello World

c)

cout << Hello World

d)

Console.WriteLine(Hello World)

20.

In leap_year.sh, which condition checks if a year is divisible by 4?

a)

[ $((year % 2)) -eq 0 ]

b)

[ $((year / 4)) -eq 1 ]

c)

[ $((year % 4)) -eq 0 ]

d)

[ $((year - 4)) -eq 0 ]