Desert Copying with Saladin

LinuxLinuxBeginner
Practice Now

Introduction

In this challenge, you find yourself in the vast expanse of the Arabian Desert, where you encounter Saladin, the legendary Sultan of Egypt and Syria. Saladin presents you with a task: to demonstrate your proficiency in using the cp command in the Linux environment. The goal is to impress Saladin with your file copying skills to secure a safe passage through the desert.


Skills Graph

%%%%{init: {'theme':'neutral'}}%%%% flowchart RL linux(("Linux")) -.-> linux/BasicFileOperationsGroup(["Basic File Operations"]) linux/BasicFileOperationsGroup -.-> linux/cp("File Copying") subgraph Lab Skills linux/cp -.-> lab-271252{{"Desert Copying with Saladin"}} end

Basic File Copying

There is a file named source.txt in the /home/labex/project directory. Your task is to copy the contents of source.txt to a new file named destination.txt.

Tasks

  • Copy a file named source.txt to a new file named destination.txt.

Requirements

  • Navigate to the directory containing the file source.txt using the terminal.
  • Use the cp command to create destination.txt with the contents of source.txt.

Example

Once completed, the contents of source.txt should be successfully duplicated into destination.txt.

โœจ Check Solution and Practice

Recursive Directory Copy

Saladin is impressed with your file copying skills and presents you with a more challenging task. You must now copy the entire content of the current directory, including all files and subdirectories, to a new directory named backup.

Tasks

  • Create a directory named backup in the /home/labex/project directory.
  • Copy all the /tmp directory's content, including files and subdirectories, to the newly created backup directory.

Requirements

  • The terminal's default working directory should be the location of the content to be copied.
  • Use the cp command with appropriate flags to copy the directory content recursively.
  • Use sudo if necessary to copy files that require elevated permissions.

Example

After completion, the backup directory should contain a replica of the original directory's content and structure.

โœจ Check Solution and Practice

Summary

In this challenge, we ventured into the arid landscape of the Arabian Desert and encountered Saladin, who tasked us with demonstrating our skills in Linux file copying using the cp command. The challenge covered fundamental file copying and recursive directory copying, allowing for a practical understanding of these essential Linux skills. This journey not only honed our abilities but also provided a valuable opportunity to impress the legendary Saladin.