Linux Terminal FundamentalsLesson 2.2
How to create, copy, move, and delete files in the Linux terminal
touch command, mkdir with -p flag, cp command, mv command, rm and rm -r, rmdir, glob patterns, safety with rm
Managing Files and Directories
These five commands handle every routine file management task you will do as a developer.
Creating files and directories
touch index.js
mkdir src
mkdir -p src/utils/helpersCopying files
cp file.txt backup.txt
cp -r src/ src-backup/Moving and renaming
mv old-name.js new-name.js
mv file.js src/
mv src/ lib/mv handles both renaming and moving. There is no separate rename command.
Deleting
rm file.txt
rm -r dist/
rmdir empty-dir/There is no trash or undo with rm. Before running rm -r, double-check the path with ls first.
Glob patterns
rm *.log
cp *.js src/