When working on the command line you may find that you need to create directories (folders), view a list of files, move to a new directory, edit files, move files, or delete files. There are simple command line arguments that allow you to do all of this.
NOTE: In all examples on this website, anything in <these brackets> are denoting a description of what should be put in that location. Do not include the brackets or description in your own command, but replace with the pertinent information.
View listing of existing files
ls will list all files. The optional argument -l gives you more detailed information about each file.
Make a new directory in current directory
mkdir <new name>
Move into another directory
cd <directory name>
The directory name can also be a path. For instance I can move to simulations/predprey/results with “cd simulations/predprey/results”.
Special location characters:
- “.” represents the current directory
- “..” represents the parent directory (i.e. the directory in which your current directory exists)
Move a file into another directory
mv <file> <directory>/.
The directory here can also be a path. To move a folder, use “-r” before the file name.
Of course, be careful with this command. There is no “undo”! If the file exists, it will be deleted. You can delete an entire folder with “-r” before the file.
You can edit files on the command line using either vim or emacs. Different CS faculty will argue that each is better. Just pick one. You can find guides on the commands to use within them online — just remember that you are purely command line based, and therefore can’t use your mouse the way you are used to doing!