In that case, an alias might be a very good idea (such as alias rm = trash), so even if you do run the rm command, bash, or whichever shell you use will replace rm with trash, but unless they both share the same syntax, you’ll probably get errors for unknown arguments.
You’re right, and I’m not so sure how well that particular alias might work because I don’t know what the differences between the command-line arguments for rm and trash may be (I don’t know anything about the trash command), although it may also be possible to create a separate alias for each argument, but then the order in which they are listed may be important too so things get more complicated in that case, however that could be an interesting bit to explore, and then perhaps incorporate into my system
I think the trash command and the rm command do not use the same syntax in Linux. The trash command is used to move files to a trash bin, while the rm command is used to permanently delete files without recovery.
Command Syntax Comparison
rm Command
The rm command is used to remove files and directories in Linux. Its basic syntax is:
$ rm [options] <file ...>
Options: Common options include:
-f: Force deletion without confirmation.
-i: Prompt for confirmation before each deletion.
-r: Recursively delete directories and their contents.
trash Command
The trash command is an alternative that moves files to a trash bin instead of permanently deleting them. Its syntax is:
$ trash [options] <file ...>
Options: Common options include:
--list: Show files in the trash.
--empty: Empty the trash.
Key Differences
Feature
rm Command
trash Command
Purpose
Permanently deletes files
Moves files to trash bin
Recovery
No recovery option
Files can be restored from trash
Confirmation
Can prompt with -i option
No prompt, but safer by default
Directory Deletion
Requires -r for directories
Handles directories automatically
The trash command is generally safer for users who want to avoid accidental permanent deletions, while rm is more direct and powerful for immediate file removal.
I wonder how “trash” would handle files on a share?
e.g. if I’m using Nautilus to browse files on my hdd - and press delete - they go into “Trash”… However if I’m browsing remote files on an NFS mount (i.e. my NAS) - there’s no “Trash” and delete, deletes the files “permanently”… I don’t have snapshots enabled on my NAS…
I myself have no idea but your questions sounds interesting.
Here´s duckduckgo´s Search Assist´s opinion:
The trash command in Linux, specifically using utilities like trash-cli, can manage files on a shared network by moving them to the trash directory, typically located at ~/.local/share/Trash/. However, the ability to access and manage these files may depend on the permissions set on the shared location. Tom’s Hardware linuxquestions.org
Handling Files on a Share with the Trash Command in Linux
Overview of Trash Command
The trash command in Linux, particularly through utilities like trash-cli, allows users to move files to a trash directory instead of permanently deleting them. This command is useful for recovering files later.
Behavior on Shared Locations
When using the trash command on files located on a shared network drive, the following points are important:
File Movement: The trash command will attempt to move the file to the local trash directory (usually located at ~/.local/share/Trash). This may not work as expected if the shared location does not support this operation.
Permissions: The ability to move files to the trash depends on the permissions set on the shared drive. If you lack the necessary permissions, the command may fail.
Network Protocols: The behavior can vary based on the network protocol used (e.g., SMB, NFS). Some protocols may not support moving files in the same way as local files.
Using Trash-CLI
If you want to use trash-cli for files on a share, you can follow these commands:
Command
Description
trash-put <file>
Move a file to the trash.
trash-list
List all files in the trash.
trash-restore <id>
Restore a file from the trash.
trash-empty
Empty the trash.
Conclusion
Using the trash command on shared files can be limited by permissions and the capabilities of the network file system. Always check the specific behavior based on your setup and the type of shared drive you are using.