Script Valley
Developer Environment Setup (WSL, Terminal, VS Code)
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

Linux file management commands

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/helpers

Copying 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/

Up next

How to read and search file contents with cat, grep, and less

Sign in to track progress