For Linux/macOS users: the terminal, the miniforge installation, and the Python interpreter#
You will likely not need the terminal very often in this class (unless you want to use it), mostly for starting Python, jupyterlab, and some other Python tools. Still, it is important to have a basic understanding of how to use it and what is happening in the background.
You can do many things in the terminal, but the one thing you will really need is to navigate to the folder of your choice. The name of the currently active folder is always indicated at the end of the prompt.
A few commands that may be useful:
ls: list the files and directories (folders) in the current locationls -a: list the files and directories in the current location, including the hidden ones (starting with a dot)pwd: print the path of the current working directorycd folder_name: navigate to the folder folder_namecd ..: navigate one folder upcd: navigate to your home directory (very useful if you get lost)mkdir new_folder: create the new directory new_foldercp old_file new_file: create a copy of old_file and call it new_filemv old_file new_file: rename old_file to new_file. If you replace new_file with folder_name the file is moved to folder_name.rm file: delete a file. Careful, files will be deleted immediately and do not go to the trash.rm -r directory: delete entire directory with all its contentsTAB: ask the command prompt to complete the name for you. For example, if you are lazy and type only two letters of the desired folder, typingTABmight complete it for youexit: exit the terminal (you can also simply close the window)
That’s it! The reason why you need to be able to navigate to a specific folder will be explained in the next section.
What happened when we installed miniforge?#
Visually, one thing changed: when you open a terminal window now, the command prompt starts with (base). This shows that your installation was successful and that when you now type in python to open a Python interpreter, the new miniforge installation is used instead of any default Python installation you may have on your system. During the installation, a directory was created in your home directory where the Python installation resides. Go to your home directory and list all the file and folders:
cd
ls
You can also type which python to see the path of the Python installation being called when you type python. How does your terminal know that it should use the new installation? This information was stored in your .bashrc file during the miniforge installation. It is a hidden file (starts with a dot) in your home directory and contains commands that are executed when you open a terminal. You can open it with a text editor, e.g.,
vim .bashrc
and find the section starting with # >>> conda initialize >>>. You can close vim by typing :q.
The Python interpreter#
The Python interpreter can be opened in many different ways, one is by typing python into the terminal. The Python interpreter is recognizable by the three “greater than” signs at the beginning of the command line >>>. The Python interpreter is where the Python commands are valid.
Summary
In the terminal, you can navigate between directories, move files and directories, create new directories, etc.
During the miniforge installation, Python was installed in your home directory and information was stored in your
.bashrc, which tells the system to use the new installation when you open a terminal window.You can start the Python interpreter from the terminal by typing
python, where you can type Python commands and much much more.