✂️ Creating, Copying, Moving, Deleting
Now that you know how to view files, it's time to learn how to manage them — creating new files, copying them for backup, moving or renaming them, and cleaning up by deleting. These are the essential file operations you'll use every day in Linux.
touch — Creating New Files
The touch command is primarily used to create empty files quickly. It can also update the timestamp of an existing file, but we'll focus on creating files for now. Think of it like grabbing a blank notebook and putting it on your desk — ready to write in.
touch notes.txt
✅ This creates an empty file called notes.txt in your current directory.
Creates 3 empty files in one command. Super handy when you're starting a project and need multiple placeholders.
If the file already exists, touch will update its last modified time:
This doesn't change the content — just the "last edited" timestamp.
cp — Copying Files and Directories
The cp command is used to make copies of files or directories. Think of it like photocopying a document — the original stays, and you get a duplicate to work with.
cp notes.txt backup_notes.txt
- notes.txt stays intact
- backup_notes.txt is the new copy
Copies both file1.txt and file2.txt into backup_folder.
Note: The folder must exist beforehand.
To copy entire folders, use -r (recursive):
Projects/ folder and all its contents are copied to Projects_backup/.
If the destination file exists, you can ask Linux to prompt before overwriting:
It will ask "overwrite? y/n" before replacing the file.
mv — Moving or Renaming Files
The mv command is like the "cut & paste" or "rename" tool in Linux. It can move files/folders to a new location or rename them in the same directory. Think of it like reorganizing your desk: moving a notebook to a drawer, or renaming it so it's easier to find.
mv notes.txt Documents/
Moves notes.txt into the Documents folder. The file no longer exists in the original location.
You can rename a file by giving a new name in the same location:
mv notes.txt class_notes.txt
notes.txt is now renamed to class_notes.txt.
Moves both files into the target folder.
Like cp, you can ask Linux to prompt before overwriting:
It will ask "overwrite? y/n" if the destination has the same filename.
rm — Deleting Files and Directories
The rm command is used to delete files or directories. Think of it as throwing something in the trash — but in Linux, it permanently deletes unless you take extra care.
rm notes.txt
notes.txt is permanently removed from your directory.
Deletes both files at once.
To delete a folder and all its contents, use -r (recursive):
Deletes Projects/ and everything inside it.
You can make Linux confirm before deleting:
It will ask "remove file? y/n" before deletion.
To ignore warnings and delete without confirmation:
⚠️ Be careful — this is dangerous. It will permanently delete everything in OldProjects/ without asking.
Real-life analogies
touch = Grabbing a blank notebook and placing it on your desk — ready to write in
cp = Making photocopies — you keep the original safe and work on the copy
mv = Reorganizing your desk — moving notebooks to drawers or renaming them for clarity
rm file.txt = Throwing a single paper in the trash
rm -r folder/ = Dumping a whole box of files
rm -rf folder/ = Nuclear option — makes sure nothing is left behind