Lpic 2 Linux Engineer · Free Practice Question Medium
Question 14
- A tar -xvf /backup/system.tar.gz /etc/hosts
- B cp /backup/system.tar.gz /etc/hosts
- C restore -x /backup/system.tar.gz -file /etc/hosts
- D rsync -r /backup/system.tar.gz /etc/hosts
Reveal correct answer
Correct answer: A
A. The correct command to restore just the /etc/hosts file from the system backup is "tar -xvf /backup/system.tar.gz /etc/hosts". The "-x" flag is used to extract files from the archive, the "-v" flag provides verbose output, and the "-f" flag specifies the archive file to extract from. By specifying the path to the specific file (/etc/hosts) after the archive file, only that file will be restored from the backup.
B. The command "cp /backup/system.tar.gz /etc/hosts" will not restore just the /etc/hosts file from the system backup. This command will simply copy the entire system.tar.gz file to the /etc/hosts location, overwriting the file and not extracting the specific file from the archive.
C. The command "restore -x /backup/system.tar.gz -file /etc/hosts" is not a valid command for restoring a specific file from a tar archive. The "restore" command is not typically used for extracting files from tar archives, and the syntax provided is incorrect for this operation.
D. The command "rsync -r /backup/system.tar.gz /etc/hosts" will not restore just the /etc/hosts file from the system backup. The rsync command is typically used for syncing files and directories between two locations, and the provided command does not specify the extraction of a specific file from the archive.
Discussion
Think the marked answer is wrong, or have a better explanation? Share it below — comments appear after review.
