1.8 Files Flashcards

2
Q

How can you display only the first few lines of a file?

A

You can display only the first few lines of a file using the head command.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Why is it more common to use the tail command than the head command?

A

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 well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

How can you use the tail command to monitor a specified file when troubleshooting the system?

A

The tail -f command continuously monitors a file and will display new lines that get appended to the end of the file.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What is different about file extensions in Linux compared to file extensions in a DOS environment?

A

File extensions in Linux are optional and therefore cannot be reliably used to determine the type of a file.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What are some common commands you can use to view the contents of text files?

A
  • cat
  • more
  • less
  • head
  • tail
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What does the touch command do?

A

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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

What does the cat command do?

A

cat displays the contents of the file in the shell. This can include displaying multiple files at once.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

What does the less command do?

A
  • *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.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

What does the head command do?

A

head lists the first 10 lines of a specified file, by default.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

What does the head -n command do?

A

head -n lists the first n lines of a specified file, where n is the argument to the -n option.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

What does the tail command do?

A

tail lists the last 10 lines of a specified file, by default.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

What does the tail -n command do?

A

tail -n lists the last n lines of a specified file, where n is the argument to the -n option.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

What does the tail -f command do?

A

tail -f monitors a file continuously.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

What does the file command do?

A

file shows the file type. The file command might often be necessary because Linux does not require file extensions.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

Where are the signatures used by the file command kept?

A
  • /usr/share/misc/magic
  • /usr/share/misc/magic.mgc
  • /etc/magic
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
17
Q

What does the cp command do?

A

cp copies files, leaving the source file intact.

18
Q

What does the cp -f command do?

A

cp -f copies files, overwriting files that already exist in the destination directory.

19
Q

What does the cp -i command do?

A

cp -i copies files, prompting before overwriting files that already exist in the destination directory.

20
Q

What does the mv command do?

A

mv moves or renames files and directories. Moving files erases the source file and places it in the destination.

21
Q

What does the mv -f command do?

A

mv -f moves or renames files and directories, overwriting files that already exist in the destination directory.

22
Q

What does the mv -i command do?

A

mv -i moves or renames files and directories, prompting before overwriting files that already exist in the destination directory.

23
Q

What does the mv -n command do?

A

mv -n moves or renames files and directories, never overwriting files in the destination directory.

24
Q

What does the rm command do?

A

rm removes file and directory inodes, but does not actually delete the data.

25
Q

What does the rm -f command do?

A

rm removes file and directory inodes without prompting, but does not actually delete the data.

26
Q

What does the shred command do?

A

shred deletes files and overwrites the file information. It is useful when deleting files that contain proprietary company information or other sensitive data.

27
Q

What does the shred -n command do?

A

shred deletes files and overwrites the file information. The -n option specifies the times to overwrite. The default is 25 times.

28
Q

What does the shred -u command do?

A

shred deletes files and overwrites the file information. The -u option deletes the inode.

29
Q

What does the shred -v command do?

A

shred deletes files and overwrites the file information. The -v option displays the progress of the file deletion.

30
Q

What does the shred -z command do?

A

shred deletes files and overwrites the file information. The -z option overwrites the filename with zeros.

31
Q

What does the lsattr command do?

A

lsattr lists file attributes on a Linux ext2 (or later) filesystem.

32
Q

What does the lsattr -R command do?

A

lsattr -R recursively lists file attributes of directories and their contents.

33
Q

What does the lsattr -V command do?

A

lsattr -V displays the program version.

34
Q

What does the lsattr -a command do?

A

lsattr -a lists file attributes of all files, including hidden files.

35
Q

What does the lsattr -d command do?

A

lsattr -d lists file attributes of directories in the same fashion as regular files rather than listing their contents.

36
Q

What does the lsattr -v command do?

A

lsattr -v lists the file’s version/generation number.

37
Q

Which file contains a list of shells that are available on the system?

A

The /etc/shells file contains a list of shells that are available on the system.