Sikau

Linux and the shell · Day 3 · about 30 min

Creating, copying and deleting

mkdir, touch, cp, mv, rm and brace expansion.

No trash can

Setting up a project means creating folders and files, copying templates, renaming and cleaning up. The commands are short — and rm has no undo, so it pays to know exactly what they do.

The file commands

mkdir -p shop/{src,tests,docs}
touch shop/src/app.js shop/README.md
cp shop/README.md shop/docs/
cp -r shop shop-backup
mv shop/docs/README.md shop/docs/intro.md
mv shop-backup /tmp/
rm shop/README.md
rm -r /tmp/shop-backup
tree shop

Before a scary rm, run ls with the same arguments to see exactly what would be deleted. Add -i to be asked each time.

The rest of this lesson

  • Copying and moving safelyexplain
  • Brace expansionexplain
  • What gets created?predict
  • Which command?match
  • Your turnwrite code
  • Badge quizquiz
  • What you learnedrecap

Continue this lesson free — run real code in your browser

Continue with Google

See all 16 lessons of Linux and the shell