Linux – Make, Rename, Move, Delete Folders (mkdir, mv, cp, rm)

Managing folders is much like managing files in Linux. Just remember to use the -r option (recursive) for copying and deleting.

Make Directory

  • mkdir newfolder – Creates a folder called folder

Rename Directory

  • mv newfolder newfolder2 – Renames folder to be folder2

Move Directory

  • mv newfolder folder/newfolder – Moves newfolder into the folder directory.
  • Warning: You can move AND rename a folder at the same time even by accident.

Copy Directory

  • cp -r newfolder newfolder.bak – Copies newfolder and contents to newfolder.bak
  • -r means “recursive” and so copies both the folder and all contents.

Delete Directory

  • rm – rf newfolder – Deletes newfolder and all contents
  • -f is the “force” option and may be needed if files within the directory are protected for some reason.

Be the first to comment

Leave a Reply