nerdexam
CompTIA

XK0-004 · Question #494

A Linux administrator needs to copy the log files and all the subdirectories in /var/log/archive to the /log/backups/ directory on a remote server at backup.example.com. The administrator will use…

The correct answer is A. scp -r /var/log/archive [email protected]:/log/backups. Copying files recursively to a remote server with a specific user account requires scp with the -r flag and the user@host:/path syntax. Only option A satisfies all three requirements.

Scripting, Containers and Automation

Question

A Linux administrator needs to copy the log files and all the subdirectories in /var/log/archive to the /log/backups/ directory on a remote server at backup.example.com. The administrator will use the archive user account to access the remote server. Which of the following commands will do this?

Options

  • Ascp -r /var/log/archive [email protected]:/log/backups
  • Bscp -r /var/log/archive backup.example.com:/log/backups
  • Cscp /var/log/archive/* [email protected]:/log/backups
  • Dscp -r backup.example.com:/log/backups /var/log/archive

How the community answered

(46 responses)
  • A
    87% (40)
  • B
    2% (1)
  • C
    2% (1)
  • D
    9% (4)

Why each option

Copying files recursively to a remote server with a specific user account requires scp with the -r flag and the user@host:/path syntax. Only option A satisfies all three requirements.

Ascp -r /var/log/archive [email protected]:/log/backupsCorrect

The scp -r flag enables recursive copying of directories and their subdirectories. Specifying [email protected]:/log/backups correctly identifies the remote user as 'archive' and the destination path as /log/backups/ on the target server. This command copies /var/log/archive and all its contents to the remote server using the correct user account.

Bscp -r /var/log/archive backup.example.com:/log/backups

This command omits the required 'archive@' username prefix, so scp would attempt to authenticate as the local user rather than the archive account.

Cscp /var/log/archive/* [email protected]:/log/backups

Using a glob without -r copies only the immediate files inside the directory and not subdirectories, failing to replicate the full archive tree.

Dscp -r backup.example.com:/log/backups /var/log/archive

This command reverses the source and destination, copying from the remote server to the local machine rather than the other way around.

Concept tested: scp recursive remote copy with user authentication

Source: https://man.openbsd.org/scp

Topics

#scp#remote copy#SSH#file transfer

Community Discussion

No community discussion yet for this question.

Full XK0-004 Practice