1.8 Files Flashcards
How can you display only the first few lines of a file?
You can display only the first few lines of a file using the head command.
Why is it more common to use the tail command than the head command?
It is more common to use the tail command than the head command because the most recent and most interesting information in files (like log files) is usually at the end of the file.
How can you use the tail command to monitor a specified file when troubleshooting the system?
The tail -f command continuously monitors a file and will display new lines that get appended to the end of the file.
What is different about file extensions in Linux compared to file extensions in a DOS environment?
File extensions in Linux are optional and therefore cannot be reliably used to determine the type of a file.
What are some common commands you can use to view the contents of text files?
- cat
- more
- less
- head
- tail
What does the touch command do?
touch creates a blank file if the file does not exist, or updates the file’s modification and last accessed times if the file exists.
What does the cat command do?
cat displays the contents of the file in the shell. This can include displaying multiple files at once.
What does the less command do?
- *less** displays the file one screen at a time.
- Use the SpaceBar to scroll to the next screen.
- Use the Up arrow and Down arrow to scroll up and down.
- Type q to exit.
What does the head command do?
head lists the first 10 lines of a specified file, by default.
What does the head -n command do?
head -n lists the first n lines of a specified file, where n is the argument to the -n option.
What does the tail command do?
tail lists the last 10 lines of a specified file, by default.
What does the tail -n command do?
tail -n lists the last n lines of a specified file, where n is the argument to the -n option.
What does the tail -f command do?
tail -f monitors a file continuously.
What does the file command do?
file shows the file type. The file command might often be necessary because Linux does not require file extensions.
Where are the signatures used by the file command kept?
- /usr/share/misc/magic
- /usr/share/misc/magic.mgc
- /etc/magic