WorksheetsUbuntu Linux- Working with Files (Text & Directory)
Total questions: 20
Worksheet time: 10mins
Which command is used to create an empty file in Ubuntu Linux?
mkdir
cat
touch
nano
What does the cat command do when used with a filename?
Deletes the file
Displays the contents of the file
Edits the file in terminal
Creates a new directory
How do you save changes and exit in the vi editor?
CTRL + X, then Y, then Enter
:wq
CTRL + S
ALT + F4
Which command can be used to create and write text to a file in one step?
cat filename
touch filename
echo "Hello World" > filename
mv filename
What does the nano command do?
Opens a file in a simple text editor
Copies a file to another directory
Creates a new directory
Compiles a program
How do you create a new directory in Ubuntu Linux?
mkdir <directory_name>
touch <directory_name>
nano <directory_name>
cd <directory_name>
Which of the following commands appends text to an existing file without overwriting its content?
echo "Hello" > file.txt
echo "Hello" >> file.txt
cat file.txt
touch file.txt
What is the purpose of the pwd command?
Prints the current working directory
Changes the current directory
Removes a file
Lists all files in a directory
How can you exit the nano text editor?
CTRL + X, then Y, then Enter
:q!
ALT + F4
ESC, then EXIT
Which command is used to move between directories?
mv
cd
pwd
ls
What happens when you use the touch command on an existing file?
It deletes the file
It updates the file’s timestamp
It opens the file in a text editor
It copies the file to another location
Which command lists all files, including hidden ones, in a directory?
ls
ls -l
ls -a
dir
What does the command rm -r directory_name do?
Removes a file
Removes a directory and its contents recursively
Moves a directory to another location
Renames a directory
How can you display the first 10 lines of a file?
cat filename
head filename
tail filename
nano filename
Which key is used to switch from insert mode to command mode in the vi editor?
CTRL + C
ESC
CTRL + X
ALT + Q
What is the correct way to rename a file in Ubuntu Linux?
rename oldname newname
mv oldname newname
cp oldname newname
edit oldname newname
What does the command echo "Hello" > file.txt do?
Appends "Hello" to the file
Overwrites the file with "Hello"
Displays "Hello" on the screen
Deletes the file
What does cat file1.txt file2.txt > combined.txt do?
Creates a copy of file1.txt
Merges file1.txt and file2.txt into combined.txt
Deletes file1.txt and file2.txt
Moves both files into a new directory
How do you exit the vi editor without saving changes?
CTRL + X
:q!
ESC, then :wq
ALT + F4
What happens when you run cd .. in a directory?
Moves into a subdirectory
Deletes the current directory
Moves up one directory level
Lists all files in the current directory
