Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the command to copy a file named file.txt from your local machine to a remote server using scp.
Linux CLI
scp file.txt user@remote_host:[1] Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Putting the filename again after the colon instead of the destination directory.
Using
-r when copying a single file.Repeating the user and host after the colon.
✗ Incorrect
The destination path on the remote server must be specified after the colon. Here,
/home/user/ is the target directory.2fill in blank
mediumComplete the rsync command to copy the directory myfolder from the remote server to your local machine.
Linux CLI
rsync -avz user@remote_host:[1] ./ Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using relative paths without full remote path.
Adding
-r inside the source path.Omitting the user and host before the colon.
✗ Incorrect
You need to specify the full path of the directory on the remote server.
/home/user/myfolder is the correct full path.3fill in blank
hardFix the error in the scp command to copy a directory project recursively to the remote server.
Linux CLI
scp [1] project user@remote_host:/home/user/ Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using
-a which is not valid for scp.Omitting the recursive option causes an error.
Using compression option
-z which scp does not support.✗ Incorrect
The
-r option tells scp to copy directories recursively.4fill in blank
hardFill both blanks to create a dictionary comprehension that maps filenames to their sizes using rsync output stored in files.
Linux CLI
sizes = { [1]: [2] for [1] in files } Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using
size as the loop variable instead of file.Accessing dictionary with wrong key variable.
Swapping keys and values in the comprehension.
✗ Incorrect
The variable
file iterates over files. The size is accessed by files[file].5fill in blank
hardFill all three blanks to filter files larger than 1000 bytes from files dictionary using comprehension.
Linux CLI
large_files = { [1]: [2] for [1] in files if [2] [3] 1000 } Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using different variable names for key in comprehension.
Using
< instead of > for filtering.Comparing the key instead of the value.
✗ Incorrect
We iterate over
filename in files. The size is files[filename]. We filter sizes greater than 1000 with >.