The Command Line
18 Jan 2022Below consider the a set of commands to navigate your computer’s file system from the command line (i.e., the Command Prompt on Windows and the Terminal on the Mac).
Windows (cmd.exe)
dir
returns the contents of the current directory (i.e., folder)cd XYZ
changes from the current directory to the subdirectory XYZcd ..
moves to a directory one level up (toward the root directoryC:\
)cd \
moves to your PC’s root directory (likelyC:\
)echo Hello > XYZ.txt
creates a plain text file called XYZ in the current directory containing the word “Hello”del XYZ.txt
deletes the file XYZ.txtmd XYZ
creates a new subdirectory (i.e., folder) in the current directoryrmdir XYZ
deletes the directory XYZ
The path to some image file Cat.jpg
on the Desktop of some User JohnDoe is: C:\Users\JohnDoe\Desktop\Cat.jpg
.
MacOS (Terminal.app)
ls
returns the contents of the current directory (i.e., folder)cd XYZ
changes from the current directory to the subdirectory XYZcd ..
moves to a directory one level up (toward the root directory/
)cd /
moves to your Mac’s root directory (i.e.,/
)touch XYZ.txt
creates an empty plain text file called XYZ in the current directoryrm XYZ.txt
deletes the file XYZ.txtmkdir XYZ
creates a new subdirectory (i.e., folder) in the current directoryrm -R XYZ
deletes the directory XYZ
The path to some image file Cat.jpg
on the Desktop of some User JohnDoe is: /Users/JohnDoe/Desktop/Cat.jpg
.