What is the primary objective of Practice lab 3
To master essential commands for displaying, navigating, and modifying file content in linux.
Which command ensures you are in your home directory before starting the lab exercises?
cd -
What command creates a new file named lab_notess.txt and writes “Line 1: important config” into it, overwriting any existing content?
echo “Line 1: Important config” > lab_notes.txt
What operator is used with echo to add new lines of text to an existing file without deleting its current content?
The append operator»_space;
example: echo “New Log Entry”»_space; lab_notes.txt
Which command is described as best for small files because it dumps the entire content to the screen at once?
The cat command
example cat lab_notes.txt
What is the expected result of running cat lab_notes.txt after it has been fully populated in the lab preparation?
It shows all 6 lines of the file immediately.
Which command is recommended for viewing large system files because it allows for scrolling and searching?
The less command.
example
When viewing a file with less what key is used to scroll through the content?
The spacebar
What key do you press to exit the less file viewer?
The q key
The __ command is used to view the first few lines of a file which are useful for checking headers.
head command, useful for viewing only the first few lines of a file.
What is the function of the -n [number] flag when used with the head or tail commands
It specifies the number of the lines to display. example: tail -n 2 lab_notes.txt
What specific command would you use to show only the first 3 lines of the /etc/fstab file?
head -n 3 /etc/fstab
The __ command is used to view only the last few lines of a file, making it extremely useful for checking recent log entries.
tail
example: tail -n 2 lab_notes.txt
What command displays only the last 2 lines of the file lab_notes.txt.
tail -n 2 lab_notes.txt
Which user-friendly, terminal based text editor is introduced in Practice Lab3?
The nano editor
What command opens lab_notes.txt for editing using the Nano editor?
nano lab_notes.txt
In the nano editor. What is the keyboard shortcut to Write Out or save the file?
Ctrl + o
After pressing Ctrl + o in nano to save. What must you typically do next to confirm the filename?
Press enter
What is the keyboard shortcut to exit the nano editor?
Ctrl + x
After editing a file in nano. What command can be used to quickly verify the changes by displaying the entire file
cat lab_notes.txt
The command
echo “new log entry”»_space; lab_notes.txt is an example of what operation?
Appending data to the end of a file
Why is the append operator»_space; considered critical for logging scripts?
It allows adding new data to the end of a log file without opening an editor or overwriting existing entries
What command can be used to verify the new log entry was successfully added as the very last line of the lab_notes.txt
tail -n 1 lab_notes.txt
What is the final cleanup step in Practie Lab 3?
Removing the practice file using the rm lab_notes.txt command