Why file commands matter
You can find your way around. Now, what can you actually do with files? This is Operating Systems from zero, episode two: working with files. Five commands to copy, move, delete, read and search, on Linux, macOS and Windows.
The office desk analogy
Think of an office desk. cp is the photocopier. You get a copy, and the original stays where it is. mv is carrying a paper to another drawer. Or simply writing a new label on it. rm is the paper shredder. There is no recycle bin. cat is reading the page. And grep is a highlighter that finds a word for you.
Command 1: cp
Command one: cp, short for copy. cp report.txt report-backup.txt makes a copy next to the original. To copy a whole folder, add -r. In Windows PowerShell, cp works too. It is a short name for Copy-Item.
Command 2: mv
Command two: mv, short for move. mv report-backup.txt report-2026.txt gives the file a new name. Moving a file inside the same folder is how you rename it. mv also moves files into other folders. In PowerShell the full name is Move-Item, and mv works there too.
Command 3: rm
Command three: rm, short for remove. rm report-2026.txt deletes the file. There is no trash can. When it is gone, it is gone. To delete a folder, add -r. Always double check the name first.
Command 4: cat
Command four: cat. cat prints the contents of a file on the screen. It is perfect for short files, like a report or a settings file. The name comes from concatenate, which means to join files together.
Command 5: grep
Command five: grep. It searches inside a file for a word, and prints the lines that match. The -n flag adds line numbers, so you can jump straight to the problem. Here it found two errors in a server log. grep is case-sensitive by default. Add -i to ignore case.
On Windows and macOS
On Windows PowerShell, cp, mv, rm and cat all work. They are short names for the full commands. The full names are Copy-Item, Move-Item, Remove-Item and Get-Content. For searching, use Select-String. It does what grep does, and ignores case by default. On macOS, all five commands are the same as on Linux, including grep -n.
Recap
Recap. cp copies. mv moves or renames. rm deletes, with no trash can. cat reads a file, and grep finds a word inside it.
Next episode
Next episode: permissions and admin rights. You will learn who may do what, and what sudo really means. Subscribe so you do not miss it, and find written notes for every lesson at changecv.com/skills.