| |

CLI:Basics File Management Part 2 – Moving, Copying, Creating, and Deleting Files and Directories

Welcome back!
In this part of the CLI:Basics series, we’re continuing to build your Linux file management skills with another set of must-know commands.

Today’s focus: moving, copying, creating, and deleting files and directories — real-world tasks every Linux user needs to master.

Let’s dive in:


📂 Moving Files and Directories with mv

  • Move a file to a directory: mv file.txt Documents/
  • Rename a file: mv oldname.txt newname.txt
  • Move a directory: mv folder/ Documents/

Tip:
Always double-check your move targets — Linux won’t ask for confirmation unless you force it!


📄 Copying Files with cp

  • Copy a file: cp file1.txt file2.txt
  • Copy multiple files using wildcards: cp *.txt Documents/

🏗️ Creating Directories with mkdir

  • Create a single directory: mkdir newfolder
  • Create nested directories with parent flag: mkdir -p parent/child

Using -p ensures that if the parent folder doesn’t exist, it will be created automatically.


🗑️ Deleting Files and Directories

  • Delete a single file: rm file.txt
  • Delete an empty directory: rmdir emptyfolder
  • Recursively delete a non-empty directory (be careful!): rm -r folder/
  • Force delete non-empty directories without warnings: rm -rf folder/

Tip:
Use rm -rf cautiously — there’s no “undo” button at the command line!


Final Thoughts

Linux is about freedom and control
but with that freedom comes responsibility.
Today’s commands gave you direct control over your files and folders, and as always, your path is your own.

“There’s no one right way — just the way that works for you.”

Stay tuned for Part 3, where we’ll continue sharpening your command line skills!

👉 Like, subscribe, and hit that notification bell so you don’t miss it.

https://youtu.be/p9IIZHprYnU

Similar Posts

Leave a Reply