Create folders and files, then copy, rename and delete them from the command line.
Open this lesson in KodokonKnowing how to move around is good; acting on files is better. Five commands cover 90% of what you will do: mkdir to create a folder, touch to create an empty file, cp to copy, mv to move or rename, and rm to delete. They all share the same shape: the name of the command, then whatever it acts on. Let us start with mkdir, which stands for make directory. You give it the name of the folder to create. By default it creates only one level: if you ask for mkdir src/pages while src does not exist, it refuses. The -p option (for parents) fixes that by creating every missing intermediate folder along the way.
mkdir my-project
cd my-project
mkdir -p src/pages
lstouch creates an empty file if it does not exist yet. You can create several at once by separating the names with spaces. It is handy for laying out a project structure before opening it in your editor.
touch index.html
touch notes.txt README.md
lscp (copy) takes two arguments: the source, then the destination. To copy an entire folder with everything inside it, add the -r option (for recursive, meaning "and everything in there"). mv (move) works the same way, but moves instead of copying. One detail that often catches people out: renaming is moving. Moving notes.txt to notes-personal.txt inside the same folder is exactly the same thing as renaming it, and mv is indeed the command for the job.
cp index.html backup.html
mv notes.txt notes-personal.txt
mv notes-personal.txt src/
cp -r src copy-of-src
lsdemo folder, move into it, then drop the file src/pages/index.html inside it.mkdir demo
cd demo
mkdir -p src/pages
touch src/pages/index.htmldraft.txt to report.txt?rm. Where do you find it if you change your mind?