wayground logo

Free Printable Worksheets

NEW

Font size

S
M
L
XL
Worksheets

Linux Editing Files

Total questions: 27

Worksheet time: 20mins

Name
Class
Date
1.
You need to modify a configuration file on a Linux server, but you don't have root access. What's the safest way to edit the file?
a)
Open the file directly in a text editor.
b)
Request root access from the administrator.
c)
Use the sudo command with the appropriate editor.
d)
Use a graphical file manager with root privileges.
2.
You're working on a critical system configuration file. What's the BEST practice before making changes?
a)
Edit the file directly and save your work.
b)
Make the changes and reboot the system immediately.
c)
Create a backup copy of the original file before editing.
d)
Use the touch command to modify the file's timestamp.
3.
You're editing a long log file and need to find a specific error message. Which command-line tool would be most helpful?
a)
cp
b)
mv
c)
grep
d)
rm
4.
You accidentally delete a line of text while editing a file. How can you recover the lost line if you haven't saved the file yet?
a)
The changes are permanently lost.
b)
Use the history command to view past edits.
c)
Most text editors have an undo function (often Ctrl+Z).
d)
Restart the system and hope for the best.
5.
You're collaborating with a teammate on a shell script. Which editor is known for its ease of use and clear visual interface?
a)
nano
b)
vi
c)
emacs
d)
All of the above
6.
You need to edit a file that requires root privileges. What command would you use to open the file for editing with nano while using sudo?
a)
sudo nano filename.txt
b)
su nano filename.txt
c)
nano sudo filename.txt
d)
root nano filename.txt
7.
You're working on a configuration file with sensitive information. How can you ensure the contents aren't displayed on your screen while editing?
a)
There's no way to hide the content.
b)
Use a graphical editor with a password prompt.
c)
Use the /dev/null trick with your editor.
d)
None of the above
8.
You're editing a file containing website configuration data. How can you efficiently add comments to explain specific sections?
a)
Use the # symbol at the beginning of the line.
b)
Use quotation marks around the commented text.
c)
Bold or italicize the commented text.
d)
Add the comments at the end of the file.
9.
You want to insert a line of text in the middle of a file. How can you achieve this using a text editor?
a)
Open the file in read-only mode.
b)
Use the arrow keys to navigate to the desired location.
c)
Search for a specific keyword and insert the line after.
d)
None of the above
10.
You're working on a script and realize you need to copy a block of code from another file. Which command-line tool can help you achieve this?
a)
find
b)
cat
c)
cp
d)
mv
11.
You accidentally save a file with the wrong name. How can you rename the file in the terminal?
a)
Use the mv command with the old and new filenames.
b)
Edit the file content to change the name.
c)
There's no way to rename a saved file in the terminal.
d)
Use a graphical file manager.
12.
You're editing a configuration file with multiple sections. How can you quickly jump between these sections
a)
Use the arrow keys and scroll.
b)
Search for specific keywords within each section.
c)
Use the editor's built-in navigation features (e.g., bookmarks, search).
d)
None of the above
13.
You need to compare two versions of a file to see the differences. Which command-line tool would be most helpful?
a)
diff
b)
cp
c)
mv
d)
cat
14.
You're working on a large file and want to see only the last few lines. How can you achieve this using the tail command?
a)
tail filename.txt
b)
tail -n 5 filename.txt
c)
tail -l 5 filename.txt
d)
tail all filename.txt
15.
You want to create a new file and add some initial content. Which command-line tool can help you achieve this?
a)
nano filename.txt
b)
touch filename.txt
c)
cat filename.txt
d)
cp filename.txt
16.
You're editing a file and accidentally type the wrong character. How can you correct it?
a)
Use the backspace key to delete the character.
b)
Use the arrow keys to move the cursor and retype.
c)
There's no way to correct typos in text editors.
d)
Use the undo function (often Ctrl+Z).
17.
You're finished editing a file and want to save your changes. What key combination would you typically use in nano?
a)
Ctrl+S
b)
Ctrl+X
c)
Ctrl+Z
d)
Alt+F4
18.
You're collaborating on a script with a team and want to ensure everyone is working on the latest version. Which version control system is commonly used for this purpose?
a)
nano
b)
grep
c)
git
d)
cp
19.
You can edit any file on a Linux system as long as you know its location.
a)
True
b)
False
20.
Using the cat command is the safest way to edit a critical system file.
a)
True
b)
False
21.
The grep command allows you to search for text patterns within a file.
a)
True
b)
False
22.
There's no way to recover accidentally deleted text while editing a file if you haven't saved it yet.
a)
True
b)
False
23.
Text editors like nano offer a command-line interface that can be difficult to learn for beginners.
a)
True
b)
False
24.
Granting root access to a teammate is the most secure way to allow them to edit a file with sensitive information.
a)
True
b)
False
25.
Adding comments to configuration files is unnecessary and can clutter the file.
a)
True
b)
False
26.
The # symbol at the beginning of a line designates the following text as a command to be executed by the system.
a)
True
b)
False
27.
You can only insert new lines of text at the end of a file while using a text editor.
a)
True
b)
False