Deleting Files and Directories
Understand how to delete files and directories using the command-line rm command, including recursive deletion, wildcard usage, and handling permissions for efficient file system management.
We'll cover the following...
We'll cover the following...
In the GUI, we delete files by dragging them to the Trash, the Recycle Bin, or some other metaphor for reclaiming disk space. On the command line, we typically skip that intermediate step and directly remove the files or directory.
The rm command
To delete a file, we use the rm command. Let’s delete the chapter1.md file in the files/backups/ directory:
mkdir -p files/{movies,music,photos,docs/{diagrams,markdown},code/{go,js,elm}}
touch files/docs/markdown/chapter{1..3}.md
mkdir files/backups
cp files/docs/markdown/*.md files/backups
clear
rm files/backups/chapter1.md
ls files/backups
Run the above code on the terminal below for practice.
Like the ...