Show pageOld revisionsBacklinksExport to PDFBack to top This page is read only. You can view the source, but not change it. Ask your administrator if you think this is wrong. ====== Add ‘trash’ functionality to Ubuntu Server ====== If, while working on the console of the Ubuntu Server, you often have to delete some files, you might be prone to accidentally delete something you actually needed to keep. The problem with Ubuntu Server is that its ‘rm’ command deletes immediately. Fortunately, there is ‘trash-cli’ package that can help.You can install it by using apt-get commend: <code bash>apt-get install trash-cli</code> After installation, you will have several new commands available.: * trash-empty – to empty the trash * trash-put (or short: trash) – to move the file into trash * trash-list – to list the trash contents Now, you only have to stop using the rm command. You can make it easier by creating a new alias * in the ~/.bash_aliases file for current user * in the /etc/skel/.bashrc file for all users Set alias as follows: <code bash>alias rm='/usr/bin/trash'</code> You can notice that /etc/skel/.bashrc checks each users home directory for the .bash_aliases file and executes it. <code bash> if [ -f ~/.bash_aliases ]; then . ~/.bash_aliases fi </code> The new alias will be available only on new terminals. In order to get them on existing terminals, type the following: <code bash> source ~/.bashrc source /etc/skel/.bashrc </code> You can check if the new alias is active by typing: <code bash> command -v rm alias rm='/usr/bin/trash' </code> The trash command has the same options and switches as the rm command, so you shouldn’t have to modify any scripts you might be using. Note: Do remember to empty the trash every once in a while. linux/ubuntu/trash.txt Last modified: 2019/10/31 09:05by 127.0.0.1