A guide to the Fundamentals tutorial: viewing files with cat, detailed listings with ls -l and ls -a, copying and moving with cp and mv, and searching with grep and find.
This tutorial moves beyond navigation into actually working with files: reading them, inspecting them in detail, copying and moving them, and searching. These are the commands you use in real day-to-day work.
Reading and inspecting
cat notes.txt # print a file's contents
ls -l # long listing: permissions, size, date
ls -a # include hidden (dotfiles)
cat dumps a file to the screen. ls -l gives the detailed view, and ls -a reveals hidden files like .gitignore. They combine as ls -la.
Copying and moving
cp report.txt report-backup.txt # copy
mv report.txt archive/ # move into a folder
mv draft.txt final.txt # rename
cp duplicates; mv relocates. Because moving a file to a new name is the same as renaming, mv is also how you rename.
Both cp and mv will overwrite an existing destination file without warning. Check the target name before running them.
Creating nested folders
mkdir -p project/src/components # create the whole path at once
The -p flag creates any missing parent directories, which plain mkdir will not do.
Searching: grep and find
grep "TODO" notes.txt # find lines containing TODO
find . -name "*.css" # find files by name
grep searches inside files for text; find searches the file system for files. A common pattern is using find to locate files and grep to look inside them.
grep -r "text" . searches recursively through every file under the current directory, which is handy when you do not know which file contains what you are looking for.