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
linux(("`Linux`")) -.-> linux/BasicSystemCommandsGroup(["`Basic System Commands`"])
linux(("`Linux`")) -.-> linux/BasicFileOperationsGroup(["`Basic File Operations`"])
linux(("`Linux`")) -.-> linux/FileandDirectoryManagementGroup(["`File and Directory Management`"])
linux(("`Linux`")) -.-> linux/VersionControlandTextEditorsGroup(["`Version Control and Text Editors`"])
linux/BasicSystemCommandsGroup -.-> linux/source("`Script Executing`")
linux/BasicFileOperationsGroup -.-> linux/ls("`Content Listing`")
linux/BasicFileOperationsGroup -.-> linux/touch("`File Creating/Updating`")
linux/BasicFileOperationsGroup -.-> linux/rm("`File Removing`")
linux/BasicFileOperationsGroup -.-> linux/chown("`Ownership Changing`")
linux/BasicFileOperationsGroup -.-> linux/chmod("`Permission Modifying`")
linux/FileandDirectoryManagementGroup -.-> linux/mkdir("`Directory Creating`")
linux/VersionControlandTextEditorsGroup -.-> linux/vim("`Text Editing`")
subgraph Lab Skills
linux/source -.-> lab-301457{{"`Implement Custom Trash-Enabled Command`"}}
linux/ls -.-> lab-301457{{"`Implement Custom Trash-Enabled Command`"}}
linux/touch -.-> lab-301457{{"`Implement Custom Trash-Enabled Command`"}}
linux/rm -.-> 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/mkdir -.-> lab-301457{{"`Implement Custom Trash-Enabled Command`"}}
linux/vim -.-> lab-301457{{"`Implement Custom Trash-Enabled Command`"}}
end