uwlogo CS137 - Programming Principles

Home/Announcements
Avoiding Accidentally Deleting Files

At times the bash commands rm, cp, and mv can remove or overwrite files permanently (unlike the Mac or Windows trash can). To avoid accidentally doing this go to the directory [username] (where username is your questID, ex. asrowaan) in the student environment. Using your favourite text editor open the hidden file .aliases

In this file after all other code add these three lines exactly:

  alias cp="cp -i"
  alias mv="mv -i"
  alias rm="rm -i"

Save and close .aliases.
Now, still in your [username] directory, open .profile using your favourite text editor. At the very bottom you should see the line:

  source .aliases
If it is not there then add it, as seen below:

Save and close .profile. The results will take affect the next time you log into the student environment. Now whenever you tell the terminal to delete or overwrite a file using one of rm, mv, or cp it will double check with you first to make sure that you are sure you want to permanently delete or overwrite the file:

Remember: still be careful when deleting and moving files! "-i" is just meant to be a safety feature, it will not stop you from deleting important files if you confirm you want to.