0
0
Linux CLIscripting~10 mins

scp and rsync for file transfer in Linux CLI - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete 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'
Auser@remote_host
B-r
Cfile.txt
D/home/user/
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.
2fill in blank
medium

Complete 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'
A/home/user/myfolder
B-r
Cmyfolder/
Dmyfolder
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.
3fill in blank
hard

Fix 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'
A-r
B-v
C-a
D-z
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.
4fill in blank
hard

Fill 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'
Afile
Bfiles[file]
Csize
Dfiles[size]
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.
5fill in blank
hard

Fill 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'
Afilename
Bfiles[filename]
C>
D<
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.