Introduction
In this project, you will learn how to create a custom rm
command that moves deleted files to a trash directory instead of permanently deleting them. This is a useful feature to have on your Linux server to prevent accidental deletion of crucial files.
👀 Preview
labex:project/ $ ll /tmp/trash
total 2.0K
-rw-r--r-- 1 labex labex 8 Oct 26 17:47 trash_file.md
🎯 Tasks
In this project, you will learn:
- How to set up the
/tmp/trash
directory to store deleted files temporarily
- How to create a custom
rm
command script that moves deleted files to the trash directory
- How to update the
PATH
environment variable to use the custom rm
command
- How to test the custom
rm -f
command to ensure it is working as expected
🏆 Achievements
After completing this project, you will be able to:
- Protect your Linux server from accidental file deletion by implementing a custom
rm
command with a trash directory
- Understand how to modify system commands to change their default behavior
- Gain experience in shell scripting and environment variable management
Skills Graph
%%%%{init: {'theme':'neutral'}}%%%%
flowchart RL
shell(("`Shell`")) -.-> shell/ControlFlowGroup(["`Control Flow`"])
linux(("`Linux`")) -.-> linux/BasicSystemCommandsGroup(["`Basic System Commands`"])
linux(("`Linux`")) -.-> linux/FileandDirectoryManagementGroup(["`File and Directory Management`"])
linux(("`Linux`")) -.-> linux/BasicFileOperationsGroup(["`Basic File Operations`"])
linux(("`Linux`")) -.-> linux/UserandGroupManagementGroup(["`User and Group Management`"])
linux(("`Linux`")) -.-> linux/VersionControlandTextEditorsGroup(["`Version Control and Text Editors`"])
shell(("`Shell`")) -.-> shell/BasicSyntaxandStructureGroup(["`Basic Syntax and Structure`"])
shell(("`Shell`")) -.-> shell/VariableHandlingGroup(["`Variable Handling`"])
shell(("`Shell`")) -.-> shell/FunctionsandScopeGroup(["`Functions and Scope`"])
shell(("`Shell`")) -.-> shell/SystemInteractionandConfigurationGroup(["`System Interaction and Configuration`"])
shell/ControlFlowGroup -.-> shell/if_else("`If-Else Statements`")
linux/BasicSystemCommandsGroup -.-> linux/source("`Script Executing`")
linux/BasicSystemCommandsGroup -.-> linux/echo("`Text Display`")
linux/FileandDirectoryManagementGroup -.-> linux/mkdir("`Directory Creating`")
linux/BasicFileOperationsGroup -.-> linux/mv("`File Moving/Renaming`")
linux/BasicFileOperationsGroup -.-> linux/rm("`File Removing`")
linux/UserandGroupManagementGroup -.-> linux/sudo("`Privilege Granting`")
linux/BasicFileOperationsGroup -.-> linux/chown("`Ownership Changing`")
linux/BasicFileOperationsGroup -.-> linux/chmod("`Permission Modifying`")
linux/VersionControlandTextEditorsGroup -.-> linux/vim("`Text Editing`")
shell/BasicSyntaxandStructureGroup -.-> shell/shebang("`Shebang`")
shell/BasicSyntaxandStructureGroup -.-> shell/comments("`Comments`")
shell/BasicSyntaxandStructureGroup -.-> shell/quoting("`Quoting Mechanisms`")
shell/VariableHandlingGroup -.-> shell/variables_decl("`Variable Declaration`")
shell/VariableHandlingGroup -.-> shell/variables_usage("`Variable Usage`")
shell/ControlFlowGroup -.-> shell/for_loops("`For Loops`")
shell/ControlFlowGroup -.-> shell/cond_expr("`Conditional Expressions`")
shell/FunctionsandScopeGroup -.-> shell/scope_vars("`Scope of Variables`")
shell/SystemInteractionandConfigurationGroup -.-> shell/globbing_expansion("`Globbing and Pathname Expansion`")
subgraph Lab Skills
shell/if_else -.-> lab-301457{{"`Implement Custom Trash-Enabled Command`"}}
linux/source -.-> lab-301457{{"`Implement Custom Trash-Enabled Command`"}}
linux/echo -.-> lab-301457{{"`Implement Custom Trash-Enabled Command`"}}
linux/mkdir -.-> lab-301457{{"`Implement Custom Trash-Enabled Command`"}}
linux/mv -.-> lab-301457{{"`Implement Custom Trash-Enabled Command`"}}
linux/rm -.-> lab-301457{{"`Implement Custom Trash-Enabled Command`"}}
linux/sudo -.-> lab-301457{{"`Implement Custom Trash-Enabled Command`"}}
linux/chown -.-> lab-301457{{"`Implement Custom Trash-Enabled Command`"}}
linux/chmod -.-> lab-301457{{"`Implement Custom Trash-Enabled Command`"}}
linux/vim -.-> lab-301457{{"`Implement Custom Trash-Enabled Command`"}}
shell/shebang -.-> lab-301457{{"`Implement Custom Trash-Enabled Command`"}}
shell/comments -.-> lab-301457{{"`Implement Custom Trash-Enabled Command`"}}
shell/quoting -.-> lab-301457{{"`Implement Custom Trash-Enabled Command`"}}
shell/variables_decl -.-> lab-301457{{"`Implement Custom Trash-Enabled Command`"}}
shell/variables_usage -.-> lab-301457{{"`Implement Custom Trash-Enabled Command`"}}
shell/for_loops -.-> lab-301457{{"`Implement Custom Trash-Enabled Command`"}}
shell/cond_expr -.-> lab-301457{{"`Implement Custom Trash-Enabled Command`"}}
shell/scope_vars -.-> lab-301457{{"`Implement Custom Trash-Enabled Command`"}}
shell/globbing_expansion -.-> lab-301457{{"`Implement Custom Trash-Enabled Command`"}}
end