Professional Documents
Culture Documents
(CHEAT SHEET) Programming On The Raspberry Pi
(CHEAT SHEET) Programming On The Raspberry Pi
(CHEAT SHEET) Programming On The Raspberry Pi
Shell Scripts
1. Create a file with a ".sh" extension by entering this at the command prompt:
sudo nano example.sh
2. Add the shebang to the first line of the script file:
#!/bin/sh
3. Write and save the script, then make it executable by entering this at the command prompt:
sudo chmod +x example.sh
4. To run the shell script, navigate to the directory where you saved the script file and enter this:
sh hello-world.sh
or
./hello-world.sh
Python Programs
1. Create a file with a ".py" extension by entering this at the command prompt:
sudo nano example.py
2. After writing your program, you can run it by navigating to the directory where the file is saved, then entering this:
python example.py
3. To make the program executable, enter this at the command prompt:
chmod +x example.py
4. Now you can run the program by entering this:
./example.py
C Programs
1. Create a new file with a “.c” extension by entering this at the command prompt:
sudo nano example.c
2. Write your code, save the file, and exit Nano.
3. Compile the source file into a new file with this command:
gcc example.c -o compiledexample
4. Make the compiled file executable by entering this at the command prompt:
chmod +x compiledexample
5. Run the program by entering this:
./compiledexample