Wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

Ubuntu Linux- Working with Files (Text & Directory)

Total questions: 20

Worksheet time: 10mins

Name
Class
Date
1.

Which command is used to create an empty file in Ubuntu Linux?

a)

mkdir

b)

cat

c)

touch

d)

nano

2.

What does the cat command do when used with a filename?

a)

Deletes the file

b)

Displays the contents of the file

c)

Edits the file in terminal

d)

Creates a new directory

3.

How do you save changes and exit in the vi editor?

a)

CTRL + X, then Y, then Enter

b)

:wq

c)

CTRL + S

d)

ALT + F4

4.

Which command can be used to create and write text to a file in one step?

a)

cat filename

b)

touch filename

c)

echo "Hello World" > filename

d)

mv filename

5.

What does the nano command do?

a)

Opens a file in a simple text editor

b)

Copies a file to another directory

c)

Creates a new directory

d)

Compiles a program

6.

How do you create a new directory in Ubuntu Linux?

a)

mkdir <directory_name>

b)

touch <directory_name>

c)

nano <directory_name>

d)

cd <directory_name>

7.

Which of the following commands appends text to an existing file without overwriting its content?

a)

echo "Hello" > file.txt

b)

echo "Hello" >> file.txt

c)

cat file.txt

d)

touch file.txt

8.

What is the purpose of the pwd command?

a)

Prints the current working directory

b)

Changes the current directory

c)

Removes a file

d)

Lists all files in a directory

9.

How can you exit the nano text editor?

a)

CTRL + X, then Y, then Enter

b)

:q!

c)

ALT + F4

d)

ESC, then EXIT

10.

Which command is used to move between directories?

a)

mv

b)

cd

c)

pwd

d)

ls

11.

What happens when you use the touch command on an existing file?

a)

It deletes the file

b)

It updates the file’s timestamp

c)

It opens the file in a text editor

d)

It copies the file to another location

12.

Which command lists all files, including hidden ones, in a directory?

a)

ls

b)

ls -l

c)

ls -a

d)

dir

13.

What does the command rm -r directory_name do?

a)

Removes a file

b)

Removes a directory and its contents recursively

c)

Moves a directory to another location

d)

Renames a directory

14.

How can you display the first 10 lines of a file?

a)

cat filename

b)

head filename

c)

tail filename

d)

nano filename

15.

Which key is used to switch from insert mode to command mode in the vi editor?

a)

CTRL + C

b)

ESC

c)

CTRL + X

d)

ALT + Q

16.

What is the correct way to rename a file in Ubuntu Linux?

a)

rename oldname newname

b)

mv oldname newname

c)

cp oldname newname

d)

edit oldname newname

17.

What does the command echo "Hello" > file.txt do?

a)

Appends "Hello" to the file

b)

Overwrites the file with "Hello"

c)

Displays "Hello" on the screen

d)

Deletes the file

18.

What does cat file1.txt file2.txt > combined.txt do?

a)

Creates a copy of file1.txt

b)

Merges file1.txt and file2.txt into combined.txt

c)

Deletes file1.txt and file2.txt

d)

Moves both files into a new directory

19.

How do you exit the vi editor without saving changes?

a)

CTRL + X

b)

:q!

c)

ESC, then :wq

d)

ALT + F4

20.

What happens when you run cd .. in a directory?

a)

Moves into a subdirectory

b)

Deletes the current directory

c)

Moves up one directory level

d)

Lists all files in the current directory