Line: 1 to 1 | ||||||||
---|---|---|---|---|---|---|---|---|
Added: | ||||||||
> > |
Exercises 1: Discovering Linux Goal:Today’s embedded systems are more powerful than many minicomputers we had some 20 years ago. The computer I worked on when starting my job at CERN was a Digital Equipment PDP-11 minicomputer with 128kBytes (kBytes not Mbytes!) and it had a removable hard disk with 600 Mbytes of storage space. Total cost of the machine was some 80 kUS$! This machine controlled our complete linear accelerator with some 1500 control parameters (power supplies, RF parameters, vacuum, instrumentation, operator consoles ….) The Raspberry Pi we will be using during the hands-on part of the course has 1 Gbyte of RAM, a “hard disk” of 32 Gbytes and its CPU exceeds by far that of the PDP-11 mentioned above. This means that we can run a full blown operating system on this machine. In fact we will use a special Linux flavor, adapted to small machines, very similar to the Linux system we can run on PCs. Our first goal is therefore to become acquainted with Linux, its file structure, its commands etc. and this can be done on the PC for which we have created a dedicated bootable USB disk.Exercise 1: Explore the Linux file systemThe Linux file system has a tree like structure with “/” at its root (the rot of the file structure is NOT /root, which is the home directory of the super user. Start a terminal and try out a few commands. Use the
Exercise 2: Create a file system structure for all exercises of this courseIn your home directory, create subdirectories exercises, bin,src (use mkdir). Within exercises, create directories problems, solutions, doc. Within each of these create a subdirectory exercise_1. Put this file into $HOME/exercises/problems/exercise_1. Print this structure using tree. Open a LibreOffice document and write down what you have done. Save this document under the name $HOME/exercises/doc/exercise_1.odt. Continue to document you work during this exercise such that at the end of the exercise session you have a document describing all your work.Exercise 3: Environment variables and shell startupHave a look at all environment variables defined (printenv). What are the values of HOME, PATH, JAVA_HOME, CROSS_COMPILE? To get the value of an environment variable print it (echo command) with a $ in front (e.g. echo $HOME). Have a look at hidden files in you home directory. You will find amongst many other files a file called .bashrc. Open this file with an editor (gedit, emacs, vi ...it is your choice!) and edit it adding three lines concerning .bash_profile, such that end of the file looks as follows: Create a new file .bash_profile in your home directory and enter: # add $HOME/bin to the execution path PATH=$PATH:$HOME/bin Save the file. Print the current environment variable PATH. The execute: source $HOME/.bash_profile. Print the execution path again and observe differences. Now create a new environment variable MY_VARIABLE: export MY_VARIABLE=It’s_Me\! and print it. Get rid of it using unset.Exercise 4: Redirection and pipesTo each executable 3 input output channels are associated:
Exercise 5: File permissionsDo an ls -l in your solutions/exercise_1 directory. Then do the same thing on /bin. Who can read, modify, write each file? Now create a new file yesterday.sh in solutions/exercise_1/with: #!/bin/sh followed by the command you typed when counting the number of “yesterdays”. Save the file.What are the permission of it? Then type chmod +x yesterday.sh and observe the change in permissions. Type ./yesterday.sh, what happens? Too easy?For those who find the above exercises too easy and who want to do more (but who will not have support for this):
Further reading:Try http://linuxcommand.org/lc3_learning_the_shell.php. Article text. -- Uli Raich - 2017-01-03Comments |