Hdi2u S19

From wiki
Revision as of 22:36, 19 April 2017 by Rf (talk | contribs) (Created page with "= Removing files and directories = * The key difference between deleting something from the command line and using the graphical file browser is that in the first case the fi...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

Removing files and directories

  • The key difference between deleting something from the command line and using the graphical file browser is that in the first case the file vanishes immediately, but in the second it will be stored for a while in the Rubbish Bin and can be retrieved.
  • So these can be very destructiv commands, and they should be used carefully and not in a rush.
  • To remove a file or files, use the rm command followed by the name of the file(s) you wish to delete.
rm file1
rm file2 file3 file4
rm foo/*
  • Removing directories cna be done with rmdir, but this is a conservative comamnd as it will refuse to delete if the directory has any files.
rmdir thisdir
  • A much more powerful command is
rm –r fulldir
  • This will wipe out the directory empty or not.
  • With this command, you need to be 100% confident that you will never make a mistake

Exercises

  • Move into the testdir directory.
  • Delete mythirdfile.txt using the command line
  • Delete myfourthfile.txt using the graphical file browser. Is the files now sitting in the Rubbish Bin?
  • Back on the command line, move back into your Home directory.
  • Then delete myfirstfile.txt from testdir without moving back to the testdir directory.