Unix Shell (Terminal)
Overview[edit]
Being able to use the Unix Shell and terminal commands is an invaluable skill, and a requirement for this course. Follow this software carpentry link for more learning resources.
Useful Commands[edit]
Command | Description |
---|---|
ls | List current files and folders in directory |
ls -al | List details about everything |
pwd | Print current (working) directory |
cd <directory> | Move into the specified directory |
cd .. | Move up one directory |
ifconfig | Shows details on current network interfaces (requires package net-tools to be installed) |
touch <file> | Creates a file. For example "touch.txt" will create a file in the directory you are in. |
nano <file> | Opens the specified file in nano, a text editor |
mkdir <directory> | Creates a directory |
sudo <command> | Executes <command> with super user privilages |
man <command> | Opens the user manual relating to the specified command |
Aliases[edit]
Sometimes you may want to run long or complex commands. In this scenario, it can be useful to create an alias. This allows you to rename a command (or chain of commands) to an easier to type or remember command. An alias is a sort of shortcut, and it can be temporary or permanent.
For example, the command vcgencmd measure_temp
on a Raspberry Pi will return the core temperature. However, this can be a tricky command to remember. So, let's create an alias.
For a temporary alias, you can just enter in alias temp="vcgencmd measure_temp"
on the command line. This will allow you to type "temp" and get the temperature. However, this alias will expire when you end your session (log out). To create a permanent alias, the following is required.
- Open .bash_profile:
nano ~/.bash_profile
- Add a line for the alias:
alias temp="vcgencmd measure_temp"
- Save and close the file
- Reload .bash_profile:
source ~/.bash_profile