The Command Line, Enough of It · practice
Make and Move Things
Listing and reading do not change your project files. These two commands do. First run pwd and make sure it reports /workspace. If the previous lesson left you in data, run cd /workspace before continuing.
mkdir makes a directory:
mkdir notes
mv moves a file to a new path:
mv README.txt notes/
Moving a file is changing its path
mv looks like two different commands depending on how you use it, and it is worth seeing that it is one.
mv README.txt notes/ moves the file into a directory. mv README.txt READ_ME.txt renames it. Those feel like different operations, but both give the same directory entry a new path. Renaming and moving are the same act described from different angles.
The trailing slash in notes/ is not required, but it is a good habit. It says “this destination is a directory”, and if you have mistyped the directory name, the command fails instead of quietly renaming your file to something you did not want.
Your turn
The project has a README sitting in its root, and it is about to have company. Give it somewhere to live.
In the
Make a directory called
notesin the project root.Move
README.txtinto it, so the file ends up atnotes/README.txt.
Leave everything else where it is. report.py and data/books.txt should stay exactly where they are.
When you are done, run ls and ls notes to check, then press Check my work.
Checking with ls after each step is not fussiness. It is how you find out whether what you typed did what you meant, while you still remember what you typed. The notes directory is saved along with the rest of your project, so it will still be here in the next lesson, where you will put something into it.
Why are renaming and moving the same command?