Command line

The command line is a place where you can do almost everything you can do with the windows. There are some basic commands that will make your life easier.

Platform specific resources

Linux and Mac are the most straightforward for the command line. You can always run Linux on any machine by running a virtual machine with Linux installed as the system. For information on how to do that see this page.


There really isn’t a command line in Windows (I know there is the command prompt but it really isn’t going to serve the same purpose for us). Some people use powershell and others install CygWin. I can’t suggest these as I have not used them, but if you find them helpful, please share. In general, you won’t need to do too much with the command line in windows. Instead, python is going to be run in its own separate window. Not being much of a Windows user, I will add more information here as questions (and answers) come up.


In Mac, the command line is mostly done through the Terminal which can be found in the Applications/Utilities/Terminal. If you open that, you can do all the commands that we list below. If there are more specific issues that cause problems, I will list more information here.


This is my preferred system. In Linux the command line is accessed via the Terminal. It should be relatively easy to find.

Here are some basics and following those commands you will find some other resources.

  • cd <directory>: change the current directory to the given directory
  • cd ~: change to be in the home directory
  • ls <directory>: list contents of directory
  • ls: list contents of the current directory

The above commands are used in this session with results:

smitty@blacklabsmith:~$ cd /home/smitty 
smitty@blacklabsmith:~$ ls 
bin Desktop Downloads lib Pictures var Video
smitty@blacklabsmith:~$ cd /
smitty@blacklabsmith:~$ ls
bin   cdrom  etc   initrd.img      lib ...
smitty@blacklabsmith:~$ cd /home/smitty 
smitty@blacklabsmith:~$ ls 
bin Desktop Downloads lib Pictures var Video
smitty@blacklabsmith:~$ cd /
smitty@blacklabsmith:~$ ls
bin   cdrom  etc   initrd.img      lib ...
File Manipulation

Here are some basic commands for copying, moving, and deleting files.

  • cp originalfile copiedfile: copy the original file to whatever you put as the “copiedfile”
  • mv originalfile movedfile: move the original file to the new location. This is less safe than copy but it does allow you to rename a file.
  • rm originalfile: delete the file. There is no trashcan, so when this is done, that is it. The file is not retrievable.

Here are some commands for folders

  • mkdir foldername: this will create a directory with the name folder name
  • rm -r foldername: this will delete a directory with the foldername. You will notice that this is the same command as the remove file, but with the -r option. This -r stands for recursively.

There are some conveniences that you can employ. Say that you want to delete a lot of files. Say you want to delete all the files in a folder that have the .txt ending on the filename. To do that you would do rm *.txt. You can use the * wildcard for any of the commands except for things like making directories. Be careful with wildcards though.

Another convenience is tab completion. To see what I mean, if you go into the terminal and type cd and then before you hit enter, hit the tab key a few times. It will list the options, or the folders to which you can change into. You can start typing the name of one of the directories and hit tab again and it will show you the reduced options and if, given what you have typed, there are no more options, it will just complete the word for you.

There are many other shortcuts and tricks and if there are some that are particularly helpful, I can add them here.


There is a lot more information on other sites. This was the primary way for interaction with the computer for decades (and still is the primary interface for many programmers throughout the day) so you can imagine we aren’t even scratching the surface. Here are a few sites, but honestly any search will lead you to more information. (If you have other great links to suggest, just leave a comment)

Leave a Reply