7Seg

For Raspberry Pi

Commandline Basics

Contents

Step 1 - Navigation

An important thing to be able to do on any computer is to navigate the file system. Although many of these programs may be run through the 'windows' style interface on the Pi, it is possible, and in my opinion quicker to use the commandline (as well as this being a useful skill). This may seem daunting at first, but when you get down to it, it is rather simple.

When navigating the commandline, all of the moving about is done through one command cd. As well as the dir or ls command to see what is in our current directory (folder). Firstly, if we are in a folder and want to go to the folder above, we have to type cd ... If we want to go into a folder named 'New_Folder' which we have just found by typing ls, then we have to type type cd New_Folder. Have a play around, and you should have the hang of it in no time!

Step 2 - New folder

Now, let's say you want to make a new folder for your 7Seg projects... The command for making new directories is mkdir, so for instance, we can type mkdir 7Seg_projects, and we will have a new folder. Then we can check that this has gone well by typing ls, before moving into the directory using cd 7Seg_projects.

Step 3 - Edit text

Now we need to be able to edit text, and make new files from the commandline. Again, this should not present too much of a challenge. The text editor that I would recommend using is 'nano'. Say we want to create a new python file in nano called test.py. In order to do this, we have to type in the command nano test.py. As soon as you press enter, the nano text editor will open up, and it will be blank (unless there was already a file named test.py, in which case you will now be editing that). Now you can start typing your program. Here, we will just have something simple, so copy out the code below...

print "This is a test"

Once you have completed typing your program, in order to exit, simply type Ctrl + X, then type y to save your work, then press Enter to confirm the file name (which can be edited at this stage). Now this is done, in the case of python you simply have to type python test.py to rerun your program!

Conclusion

I hope this tutorial has been useful, please do contact me if you have any questions. Thanks, Tom.