Creating and Deleting Files and Directories
Asha wants a folder for each season and an empty log file in each one. Later she'll want to clear out a season she no longer needs. Making things on Linux is quick and harmless. Removing them is just as quick, and there is no recycle bin to rescue you.
The rule
Creating is cheap; deleting is forever — look before you rm.
Creating:
$ cd ~/garden
$ mkdir summer # make one directory
$ mkdir -p seasons/2026/summer # make the whole chain, parents included
$ touch summer/log.txt # make an empty filemkdirmakes a directory. It fails if the parent doesn't exist yet, unless you add-p, which creates every missing level.-palso stays quiet if the directory already exists.touchcreates an empty file if the name is new. If the file already exists, it leaves the contents alone and only updates its "last modified" time.
Deleting:
$ rm summer/log.txt # delete a file
$ rmdir summer # delete an EMPTY directory
$ rm -r seasons # delete a directory and everything inside itrmremoves files. Add-ito be asked about each one.rmdironly removes empty directories. That makes it a safe choice: it refuses if anything is still inside.rm -r(recursive) removes a directory together with its whole contents.rm -rfadds "force": no questions and no complaints about missing files. It is the most dangerous everyday command on the system.
Names with spaces need quotes. mkdir summer plans makes two folders, summer and plans, while mkdir "summer plans" makes one. Many people simply avoid spaces in file names and use hyphens instead, as in summer-plans.
Deleted files do not go to a trash folder. Once rm finishes, you can only get them back from a backup.