SARA Linux Beginning Points

Linux Introduction

Linux is very flexible on any computing system, but you must communicate in a manner it understands and controls. You must know about Linux directories (and structure) along with some common commands, file permissions, network configurations and connectivity before you can really start to experience the power involved. The most used method for starting and really learning Linux is to do this by using the bash shell.

For the RPi you must install the OS on the micro-SD card (using a different computer). Then just insert the card into the RPi and boot the RPi. Next you typically connect to the internet (WIFI/Ethernet connection) and install any software updates. Checkout the graphical interface to quickly see what is installed on your RPi. Insure the hardware and network is properly configured. Explore and enjoy the Raspberry Pi from this point. We also show you how to do that step-by-step on our SARA's RPi Initial web page. SARA's Linuix information is geared towards RPi, but concepts generally apply to any computer running a full Linux distribution.

We hope this information is a concise list of memory joggers and a jumping off point for further investigations. The job is (as we see it) to show you where to look, not to provide you the information itself. Other have the information online, but knowing where to look for the information is the key to effficient use of your time. Give us feedback and let us know if you find better places to gather the information, contact us with the email link in the footer of each Web page. Thank You.

Debian Distro Information

The NOOBS/Raspian distrobution is 'Debian' based and the naming follows the Debian released naming. 'Raspian' is a special build of Debian setup for the RPi. Full Debian release information can be found at Front Page at Debian.org. That data says:

LabelNamedDate Released
Debian 8.3JessieJan-23-2016
Debian 7.9UpdateSep-05-2015
Debian 7.0WheezyMay-04-2013
Debian 6.0.0SqueezeFeb-05-2011

The Raspian releases followed these Debian naming conventions based upon the initial Debian designer.

Many Linux distros come with very nice Graphical Users Interfaces [GUIs]. These allow for quick efficient usage of a computer system, without requiring a full understanding of the command line details. For many users this interface is all that they require to use the system. However, if you wish to really understand the system and be able to interface it with external (outside wolrd) systems, it is required that you learn the command line and probably more than one programming language. The reason for the RPi is to learn how to interface computers to the outside world and learn the operating system details required to do the interfacing. It is an experimenting environment and you need to understand the goals at the start. The RPi is NOT a general users computer system for using advanced application programs, though it can be pressed into that duty. The trade off is speed versus costs.

 

Go back to top ↑

 

SARA's Linux ~ RPi Learning Map

Lets start with a overview of what we think you should learn ASAP. If you already have the knowledge, just skip on. Otherwise we suggest the following order to getting your RPi / Linux system off to a good fast start. Remember to go at your pace and learn as you go. Enjoy the process (do not make it a work item).

  1. Pluging-In and Booting the RPi

    Gather and connect the necessary hardware and SD card, the get it booted up.

  2. Gain some very basic Command Line knowledge by moving around the file system

    file data, programs and devices are all treated the same in Linux. Understanding the directory tree structure (what is where) is key to your understanding the system. In order to do that, you need to be able to get to the various directories/sub-directories. Learn about 'man' pages and what they contain.

    Try these commands to see what man provides:

    • $ man man
    • $ man bash
    • $ man builtins
    • $ man grep
    • $ man ls
  3.  

  4. Learn to Shutdown Properly

    Linux is a 'caching type' of system that uses memory to store temporay results and files. If you do not shutdown properly then fragments of files and data will be come fragmented and lost. You change yor status from "if you may have an issue: to "when you have an issue". It is IMPERATIVE that you power down properly to maintain system integrity. 'halt' and 'shutdown' become a way of life after a couple of these types of system crashes (it usually becomes one of those "hard life lessons".

  5. Investigate the File System on your RPi as installed

    Knowing how to move around then leaves to investigate where things are located. Note all the sub-directories in the 'root' directory. Move to each one and see what resides in each one... repeat looking further and further into each sub-directory level. Be sure to look for 'hidden' files and directories in each one. As you progress, you will start to understand how Linux connects these into doing something useful.

    We suggest you use the 'Midnight Commander'. You may need to install it first. $ sudo apt-get install mc, it is a menu driven console which allows moving around with the arrow keys and . mc will invoke it, then 'F1' will open a help screen. 'F10' will exit midnight commander.

  6. Connect to a Network / Internet

    You need to connect your RPi to the internet via a network. It is key to getting to other resources and keeping your system 'current.

  7. Update / Upgrade your system software

    Learn to use "apt-get" properly. It is how you update, upgrade, add (and remove) programs. It is a good idea to "update/upgrade" your system software before installing any program (package). Linux is "always changing" and being current is key to proper software operation in many, many cases.

  8. Install your "Other Hardware"

    If you have USB/HD devices, sound card devices, printers, screens (vs a monitor), HAT devices, TNCs, etc. now is the time to go through the installs

  9. Set up SSH on your RPi

    Even if you have no current plans to use SSH, it is a good time to set it up. If you do have plans, the process of setting it up will assist your knowledge of the system.

  10. Learn your GUI

    RPi Raspian has a great GUI, learn to use it and get around. For many people, the GUI will be the place they launch from.

  11. Learn to Backup your SD card

    Learn to backup your SD card. You have it setup and updated, now is the time to back it up just in case. You may later want to repeat with a version with your software packages installed. These can save you from redoing these tasks from the start if someting bad happens (if you are like me, it always happens when I can least afford lots of time to recover).

  12. Install Software packages from the repository

    The repository hold many free applications for use on your system. Think of it as a large library at you command that holds all these programs you need to use. Most Linux programs require 'packages' of files. A package is a collection of programs and files that when come together, make an application to what it does. Changing a small part of a file that is part of a package collection can have large impacts on the application. The application writer does not need to change the entire collection (say to add a new option / feature to the application or to fix an error), just change a small part and place that in the repository package. When the end user updates his package, the change is spread to the user (almost automatically).

    Investigate how these application installs changed you file structures. Where did they put the program files, where do they store the data, etc. You can learn alot by understanding how the application designer structured the system changes to do the task.

  13. Investigate Programs (inside of the applications) you use

    Looking around inside the information you can start to learn what programming language(s) are being used. The knowledge may allow you to make a small change (improvement) to the application. It will add to your knowledge of various programming languages and may spark an interset to 'roll your own' application/project. Learn about 'pipes' and 'redirection' in Linux. This allows you to use the input to or output from one file and connect it to another file.

  14. SSH into your RPi from a remote computer

    Controlling your RPi from a remote computer is a good thing to discover, It will start you thinking about what your RPi might control in your environment fro a remote location. If you have a 'smart cell phone', think about what you might control or monitor remotely. this is also the key to remotely monitoring various sensor you may wish to have connected to yoour RPi.

  15. Learn about the GPIO on the RPi

    The GPIO pins are the control connection to the outside world. You can monitor sensor, turn on and off things, run motors, etc. For making small control projects, the RPi is a great tool. Learn the basics of how to use it and then expand to whatever your mind desires.

  16. Learn to Program your RPi

    Start simple and learn one programming language at a simple starting point, then add another and then repeat. The ability to program is a learned response. Soon you will learn the tradeoffs of one language vs another. Just start slow and keep going, soon you will be able to use many and be able to be fast and efficient with your progams. It can be enjoyable and impressive to all your other contacts.

  17. Editors - Linux has several

    Debian/Raspian comes with a number of different editors. We recommend you install the vim package. Unified access is provided to the system default editor via command "/usr/bin/editor" so other programs (e.g., reportbug(1)) can invoke it. You can change it by the following $ sudo update-alternatives --config editor. Using "/usr/bin/vim.basic" over "/usr/bin/vim.tiny" is recommended for newbies since it supports syntax highlighting.

Go back to top ↑

 

Learning the RPi Command Line

The Raspberry Pi Foundation has a magazine, "The Magi-Pi", with a very nice learning the 'Command Line' series of articles for the RPi. We suggest you go these articles and read them all. Downloaded copies of the magazine are free. Below is a small list of 'what is where' in these articles.

Issue #Article #Topic(s) CoveredPage #
311Begin RPi ~ Look Around and Moving48
322Read & Write Text = nano Editor42
333File Permissions & File Updates32
344Manipulating Text = pipes34
355Customize Command Line38
366Connecting Disks48
377Remote Access RPi = SSH (samba ~ printer / network sharing)48
388 (last)Downloading & Installs (unpack tar, wget, curl ) New SD Cards56

The following is a shortened list of information for your quick reference to information (not in order of topics).

 

Go back to top ↑

 

Linux Network Tools

Linux provides a number of tools for network configuration and connectivity verification. The following are some of the tools that allow you investigate and control your network from the shell command line [bash shell]. You may wish to connect your RPi to the network for several reasons, so these become important for you to understand.

CommandInformation Returned
ifconfigDisplays the configuration for a network interface
pingChecks network connectivity
tracerouteShows the path taken to reach a host
routeDisplays the routing table and/or lets you configure it
arpShows the address resolution table and/or lets you configure it
netstatDisplays the status of the network

Go back to top ↑

 

Working in the Bash Shell with Linux

Here is a good point to introduce the "man" {manual} command (did you try those suggested commands above? ~ see learning map item #2). This command yields access to all the details of most line commands. Results may look cryptic at first, but get in there and look it over frequently. Soon you will be able to read it through and it starts making more and more sense. Learn to use the 'man' often at the start and you will learn quickly.

The bash shell serves as the 'go-between' where the user and the Linux kernel connect. Bash is the most common shell in use today for Linux. Use bash and command line as the same term when you are getting started. Efficient interaction between the various Linux commands becomes much easier if you understand 'pipes' and 'redirection' concepts. The "pipe" allows the output of one command to become the input of the next. Redirection directs how inputs and outputs connect together in a command string. Environment and system variables are another area that yoy need to understand. Spend some time in the online tutorials for Linux and you will gain the knowledge rapidily. Watch for the following items as you read, Debian Tutorial from the Debian organization, a great place to start and it is free. It is written towards a "full install", but has an easy to follow path to great knowledge.

Pipes

  • command1 | command2

Redirection

  • command > file: output goes to file
  • command < file: input from file
  • command >> file: append to file
  • command2> file: errors go to file

Special Commands

CommandAction
alias:Defines a shortcut for a long command
apropos:Searches the manpages for keywords
history:Displays the most recent commands
locate:Finds files
whereis:Finds executable files for a command
which:Shows the full pathname for a command
man:Displays online help
printenv:Displays the environment variables

Some Environment Variables:

  • HOME: User's home directory
  • PATH: Directories to search for commands
  • TERM: Name of a terminal type

A good explanation of shell and evironmental variables can be found at Digital Ocean - Tutorial.

NOTE: The actual system variable usually are different with different boot ups. A 'log-in' vs 'non-log-in' or 'interactive' vs 'non-interactice' type of start will set different system variables. Read the tutorial for a good explanation.

Go back to top ↑

 

Linux File System Structure Basics

To interact with the Linux file system, you must understand the basic system structures. Some the directories are key to using Linux. The structure builds upwards from the 'root' through other layers of directories with directories and sub-directories containing files. A few common commands and knowledge of permissions will add to you abilities to use the file system. Control of the file system becomes important when using Linux.

Key Directories

*/: Root directory (base of file system)
/bin:Executable programs
/boot:Linux kernel and boot loader
/dev:Special device files
/etc:System configuration files
/home:Home directories of all users
/lib:Library files for programs
/media:Mount points for CD-ROM and other media
/root:Home directory of the root user
*/sbin:System administration commands
/srv:Data for services such as Web and FTP
*/tmp:Temporary directory
/usr:Many of the important administration programs
/var:Various system files, such as logs

A Few Common Linux Commands

cat:Copies a file to the standard output
cd:Changes the current directory
chmod:Changes file permissions
chown:Changes file ownerships
cp:Copies files
dd:Copies blocks of data
df:Reports disk space usage by device and available space
diff:Compares two text files
du:Reports disk space usage by directory
file:Displays the type of data in a file
find:Finds files based on specified criteria
grep:Searches for text in a file
ln:Links a filename to an alias name
ls:Displays the contents of a directory
mkdir:Creates a directory
more:Displays a text file, one page at a time
mount:Mounts a file system
mv:Renames or moves a file
pwd:Displays the current directory
rm:Deletes files
rmdir:Deletes directories
sort:Sorts lines in a text file
split:Splits a file into smaller parts
umount:Unmounts a file system
wc:Counts the words and lines in a file

Go back to top ↑

 

File Permissions

Permissions can be thought of as three sets of four levels. The three sets belong to: Owner, Group, and Others. The level for place values can be an "R W X -". Leading to the permission line of nine places with each place being a r, w, x and '-', which stand for: 'read', 'write', 'execute' and - 'no permission' respectively.

r w x r w x r w xThree sets of rwx levels.
r w x - - - - - -Only the owner can read, write, and execute.
r w x r - - r - -Owner can read, write and excute, everyone else can read only.
r w - r - - r - -Everyone can read, and the owner can also write.
r w - - - - - - -Only the owner can read and write.
r - - r - - r - -Everyone can read.

Permissions can also be expressed numerically {as three digits or an 'octet'}, where read (r) is equal to 4, write (w) is equal to 2, execute (x) is equal to 1, and no permission is equal to 0. Therefore, r w x r w x r w x is equal to 777, r w x r w - r w - is equal to 744, r w x - - - - - - is equal to 700, r w - r - - r - is equal to 644, r w - - - - - - - is equal to 600, and r - - r - - r - - is equal to 444. Consider three digits as the sum of the values, 4, 2, 1, or a maximum of 7 for each set of three - this is the 'octet' values.

Now you try it on your RPi on a command line (using LXTerm). Lets move into the /home/pi directory and we'll assume you are not sure where in the file directory we are currently at, so the first command will move to the 'root' directory. Followed by a move to 'home/pi' directory and finally a special list command for that directory. That will look like;

cd / then "enter"

cd /home/pi then "enter"

ls -la then "enter"

I know there are ways to quickly figure out where in the file ystem you are located, but leaving those for you to find on your own.

Now you can see all the files and information about them. It easy to see I did not tell you about the character preceding the file permissions. It is a single character that deifnes file type:

charactermeaning
-normal file
ddirectory
lsymlink
ccharacter device node
bblock device node
pnamed pipe
ssocket

 

When you see a "." {period} before the filename in Linux it means that it is a 'hidden' file. You can make a file hidden by starting the file name with a period. As you can see, it does not really hide it very deep, so is a very low level of security. There other details you can read about on your own, you can start to understand some details.

To see a detailed listing of commands check Linux Debian Reference.

Go back to top ↑

 

GUI Articles in 'Mag Pi'

Changing the Graphical Users Interface [GUI] may be something you wish to investigate. It allows you to customize the GUI to be what you want it to be. This is true for all Linux distros, including the RPi. A nice set of articles in "The Magi-Pi" covers this topic quite well, see below:

Issue #Article #Topic(s) CoveredPage #
321Hack Desktop46
322Customize LXPanel36
323Customize Openbox38
324 (last)Hacking RPi Desktop40

Miscellaneous Web Data

Some items you might like to review are below here. They are of a general interest, but do not fit into other topics listed. Check them out!

 

Go back to top ↑