Beginning UNIX on a Raspberry Pi

Beginning UNIX on a Raspberry Pi

Logotype Original Proposed evolution to allow for consistent use at all sizes across various applications Beginning UNIX on a Raspberry Pi Beta version 1.1 (04 June 2013) ! ! 2 Contents Making your output count ............................................................................................. 36! Sort ........................................................................................................................................ 37! Unique .................................................................................................................................. 38! Contents ................................................................................................................................. 1! Exercises using wc, sort and uniq ............................................................................... 39! The command line ............................................................................................................. 3! Knowledge check questions ......................................................................................... 40! Raspberry Pi Setup ............................................................................................................. 5! Answers to file and navigation exercises ................................................................ 43! Getting Logged in ............................................................................................................... 6! Answers to redirection exercises ................................................................................ 45! Formatting conventions ................................................................................................... 6! Answers to exercises using grep ................................................................................. 46! UNIX commands ................................................................................................................. 8! Exercises using wc, sort and uniq ............................................................................... 48! Navigating the file system .............................................................................................. 9! Knowledge check answers ............................................................................................ 49! Listing Files ........................................................................................................................ 13! Possible additions ....................................................... Error! Bookmark not defined.! File information ................................................................................................................ 17! Wildcards ............................................................................................................................. 19! Creating / moving and copying files ......................................................................... 21! Making life easier (or being lazy!) .............................................................................. 23! Getting help ........................................................................................................................ 24! File and navigation exercises ...................................................................................... 25! Viewing text ....................................................................................................................... 27! Piping and redirection .................................................................................................... 29! Redirection exercises ...................................................................................................... 31! Searching within files ..................................................................................................... 32! Exercises using grep ........................................................................................................ 34! ! ! 2 The command line Linked to the issues of memory, is the additional challenge of getting help on what you are doing. In a graphical environment, you can have overlaid help pages, pop-up help text or a wizard that steps you through each step. The command line was the way that any user interacted with their In contrast, a UNIX environment has a manual that is consulted separately computer until the early 1990’s when graphical interfaces like Windows in they way you might consult a reference book. Again, we need to know took over as the means by which the typical computer user interacted with what we are doing in order to get the help we need. their machine. In contrast to the point and click interface of the graphical interface, the command line typically viewed as a flashing cursor waiting Another issue is one of too many options. If you want to edit a text file on to receive your text based instructions. a Windows system you will typically use notepad. On a UNIX machine you get the choice of vi, pico, nano and many others depending on the default configuration. To undertake some text substitution in a workflow we can use sed or tr. With many opinions out there are to the best options, making choices can be overwhelming. Often a successfully executed command yields absolutely no response, just another command prompt awaiting your input when the task has completed. To the novice used to progress bars, popups and lots of feedback this lack of response can prove unsettling. Why does bioinformatics use the command line? So why do so many bioinformatics tasks rely on this complicated and unfriendly interface? Bioinformatics often requires the combination of various analysis stages with differing outputs and is often a task of a repetitive nature (e.g. applying a similar analysis with subtle changes to parameters each time). This would be a time consuming and potentially error prone task to undertake in a point and click environment, but programs with a command Why do people fear the command line? line interface can overcome these issues and help with the easy automation of your analysis task. The main reason is that the command line relies on your memory. In contrast to a graphical interface there is no clues as to what you may want The command line does come with a few discomforts in the early stages, to do next, or any of the settings/parameters that you might want/need to but the benefits once you’ve overcome this early hump are huge and really set. As a user you have to have a plan about what you want to do and how do outlay the negatives. After all, not many racing drivers rely on a about are going to go about achieving it. automatic gearbox! 4 Raspberry Pi Setup Getting Logged in USB Keyboard & Preloaded SD Mouse Card Network Username: Power Supply pi Password: raspberry HDMI-VGA Note your password isn’t displayed when typed in. Monitor Convertor (VGA in) Once logged in your command prompt: pi@raspberrypi ~ $ You can change your password using the command: Monitor (HDMI in) passwd 6 Formatting conventions UNIX commands In these training materials we will use a few conventions that will As we’ve previously pointed out, UNIX relies on your memory to recall hopefully make determining the difference between input, output and which command you need to run to undertake a particular task. However options clear. to the novice arrays of commands with names like cd, rm, ls, cp, wc or even cat and man provides absolutely no help to your memory recall. Commands that you can enter on the command line will we in red and look like this: Just like the evolution of text speak to aid the speed and ease of sending SMS messages, the sending the creators of UNIX were equally creative and lazy and reduced the names of their commands to the fewest numbers of runme -on thisfile letters, providing ultra-concise names for the most used commands. The output returned from a command will be inverted from the way it is In learning these key UNIX commands you may wish to not only learn the show on screen and be black text on a white background: two or three character command name, but also the function it is trying to achieve, which will most certainly help in you remembering both the names and functions of these core functions. runme... execution successful. thisfile has been output into thatfile For example: Summary information about a command and any useful flags you may wish If I want to alter the directory I am looking at, to pass to a command are presented as blue text on a grey background: I need to change directory, runme Converts thisfile to thatfile Using the cd command. -on Defines the file to convert If I want to get a summary of the number of words, lines and characters in a particular file, I need a word count, Which will use the wc command 8 Navigating the file system We also get a clue about our location by looking at the first bit of the command prompt. The tilde (~) lets us know we are in our home directory. Just like any other operating system, UNIX operating system keeps things pi@raspberrypi ~ $ tidy and ordered by storing files in a series of different directories. These directories all have standard uses, but the one we are going to pay attention to is home. Similar to the ‘My Documents’ directory on a Moving around windows system, each user has a home directory where they can store their personal files. Changing directory is achieved using the cd (change directory) command. So to change into a directory on your SD card called ‘/home/pi/files’ we can just issue the command: cd /home/pi/files We can

View Full Text

Details

  • File Type
    pdf
  • Upload Time
    -
  • Content Languages
    English
  • Upload User
    Anonymous/Not logged-in
  • File Pages
    27 Page
  • File Size
    -

Download

Channel Download Status
Express Download Enable

Copyright

We respect the copyrights and intellectual property rights of all users. All uploaded documents are either original works of the uploader or authorized works of the rightful owners.

  • Not to be reproduced or distributed without explicit permission.
  • Not used for commercial purposes outside of approved use cases.
  • Not used to infringe on the rights of the original creators.
  • If you believe any content infringes your copyright, please contact us immediately.

Support

For help with questions, suggestions, or problems, please contact us