Chapter 3 of 10All chapters
Chapter 3 of 10
Working with files
Creating, copying, moving and reading.
The commands
touch creates an empty file, mkdir a directory, cp copies, mv moves or renames and rm deletes. cat prints a file and less pages through one.
- rm has no undo and no recycle bin. rm -rf is the command that ends careers.
- Add -i to cp, mv and rm to be asked before anything is overwritten.
Looking inside
head and tail show the start and end of a file, and wc -l counts lines. For a long log, less lets you search with a slash without loading everything into memory.