0
0
Linux CLIscripting~10 mins

Backup strategies 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 code to create a compressed backup of the /home directory using tar.

Linux CLI
tar [1] -czf backup.tar.gz /home
Drag options to blanks, or click blank then click option'
A-c
B-x
C-v
D-r
Attempts:
3 left
💡 Hint
Common Mistakes
Using -x instead of -c will try to extract files instead of creating an archive.
Using -r appends files to an existing archive, not creating a new one.
2fill in blank
medium

Complete the command to synchronize the /data directory to /backup using rsync.

Linux CLI
rsync -a [1] /backup
Drag options to blanks, or click blank then click option'
A/backup
B/backup/
C/data
D/data/
Attempts:
3 left
💡 Hint
Common Mistakes
Using /data without trailing slash copies the directory itself inside /backup.
Confusing source and destination paths.
3fill in blank
hard

Fix the error in the command to create an incremental backup with tar using the snapshot file.

Linux CLI
tar -czf backup.tar.gz --listed-incremental=[1] /var/log
Drag options to blanks, or click blank then click option'
Asnapshot-file
Bsnapshotfile
Csnapshot.file
Dsnapshot/file
Attempts:
3 left
💡 Hint
Common Mistakes
Using slashes in the snapshot file name causes path errors.
Using names without dots may be confusing but not wrong; however, the standard is to use a dot.
4fill in blank
hard

Fill both blanks to create a backup script that archives /etc and excludes *.tmp files.

Linux CLI
tar [1] -czf etc_backup.tar.gz /etc --exclude=[2]
Drag options to blanks, or click blank then click option'
A-c
B-x
C*.tmp
D*.log
Attempts:
3 left
💡 Hint
Common Mistakes
Using -x extracts files instead of creating an archive.
Excluding the wrong file pattern like *.log.
5fill in blank
hard

Fill all three blanks to create a dictionary comprehension that maps filenames to their sizes for files larger than 1MB.

Linux CLI
sizes = [1]: os.path.getsize([2]) for [3] in files if os.path.getsize([3]) > 1048576
Drag options to blanks, or click blank then click option'
Afilename
Bfile
Attempts:
3 left
💡 Hint
Common Mistakes
Using inconsistent variable names for keys and iteration.
Not filtering files by size correctly.