← Linux & the Command Line tutorial
Working with Files
mkdir name creates a folder; touch name
creates an empty file. cp source dest copies,
mv source dest moves (or renames — the same command does
both, since a rename is really just a move to a new name in the same
place).
Example: building up a small project structure
$ mkdir project
$ touch project/notes.txt
$ cp project/notes.txt project/notes-backup.txt
$ mv project/notes.txt project/README.txt
The result: a project/ folder containing
README.txt and notes-backup.txt (the original
notes.txt was renamed, not duplicated, by that last
mv). rm name deletes a file — there's no
recycle bin at the command line, so it's genuinely permanent the moment
you press enter. Add -r to rm/cp
to work on an entire folder recursively — and be especially careful with
rm -r, since a mistyped path can delete far more than
intended with no confirmation prompt by default.
$ mkdir project
$ touch project/notes.txt
$ cp project/notes.txt project/notes-backup.txt
$ mv project/notes.txt project/README.txt
Creates a project/ folder containing README.txt and notes-backup.txt (the original notes.txt was renamed).