Sign In Start Free Trial
Account

Add to playlist

Create a Playlist

Modal Close icon
You need to login to use this feature.
  • BeagleBone By Example
  • Toc
  • feedback
BeagleBone By Example

BeagleBone By Example

By : Prabakar
5 (1)
close
BeagleBone By Example

BeagleBone By Example

5 (1)
By: Prabakar

Overview of this book

BeagleBone is a low cost, community-supported development platform to develop a variety of electronic projects. This book will introduce you to BeagleBone and get you building fun, cool, and innovative projects with it. Start with the specifications of BeagleBone Black and its operating systems, then get to grips with the GPIOs available in BeagleBone Black. Work through four types of exciting projects: building real-time physical computing systems, home automation, image processing for a security system, and building your own tele-controlled robot and learn the fundamentals of a variety of projects in a single book. By the end of this book, you will be able to write code for BeagleBone in order to operate hardware and impart decision-making capabilities with the help of efficient coding in Python.
Table of Contents (12 chapters)
close
11
Index

Working on Linux Shell

Simply put, the shell is a program that takes commands from the keyboard and gives them to the operating system to perform. Since we will be working on BeagleBone board as a development board to build electronics projects, plugging it to a Monitor, Keyboard, and Mouse every time to work on it like a computer might be unwanted most of the times and you might need more resources also which is unnecessary all the time. So we will be using the shell command-line interface to work on the BeagleBone boards. If you want to learn more about the Linux command-line interfaces, I would suggest you visit to http://linuxcommand.org/.

Now let's go ahead and try some basic shell commands and do something on your BeagleBone board.

You can see the kernel version using the command uname -r. Just type the command and hit enter on your keyboard, the command will get executed and you will see the output as shown here:

Working on Linux Shell

Next, let us check the date on your BeagleBone board:

Working on Linux Shell

Like this shell will execute your commands and you can work on your BeagleBone boards via the shell.

Getting kernel version and date was just for a sample test. Now let's move ahead and start working with the filesystem.

  • ls: This stands for list command. This command will list out and display the names of folders and files available in the current working directory on which you are working.
    Working on Linux Shell
  • pwd: This stands for print working directory command. This command prints the current working directory in which you are present.
    Working on Linux Shell
  • mkdir: This stands for make directory command. This command will create a directory in other words a folder, but you need to mention the name of the directory you want to create in the command followed by it.

Say I want to create a folder with the name WorkSpace, I should enter the command as follows:

Working on Linux Shell

When you execute this command, it will create a folder named WorkSpace inside the current working directory you are in, to check whether the directory was created. You can try the ls command again and see that the directory named WorkSpace has been created.

Working on Linux Shell

To change the working directory and go inside the WorkSpace directory, you can use the next command that we will be seeing.

  • cd: This stands for change directory command. This command will help you switch between directories depending on the path you provide along with this command.

Now to switch and get inside the WorkSpace directory that you created, you can type the command as follows:

cd WorkSpace

You can note that whenever you type a command, it executes in the current working that you are in. So the execution of cd WorkSpace now will be equivalent to cd /home/debian/WorkSpace as your current working directory is /home/debian.

Working on Linux Shell

Now you can see that you have got inside the WorkSpace folder, which is empty right now, so if you type the ls command now, it will just go to the next line on the shell terminal, it will not output anything as the folder is empty.

Working on Linux Shell

Now if you execute the pwd command, you will see that your current working directory has changed.

Working on Linux Shell
  • cat: This stands for the cat command. This is one of the most basic commands that is used to read, write, and append data to files in shell.

To create a text file and add some content to it, you just need to type the cat command cat > filename.txt

Say I want to create a sample.txt file, I would type the command as shown next:

Working on Linux Shell

Once you type, the cursor will be waiting for the text you want to type inside the text file you created. Now you can type whatever text you want to type and when you are done press Ctrl + D. It will save the file and get back to the command-line interface.

Say I typed This is a test and then pressed Ctrl + D. The shell will look as shown next.

Working on Linux Shell

Now if you type ls command, you can see the text file inside the WorkSpace directory.

Working on Linux Shell

If you want to read the contents of the sample.txt file, again you can use the cat command as follows:

Working on Linux Shell

Alternatively, you can even use the more command which we will be using mostly:

Working on Linux Shell

Now that we saw how we can create a file, let's see how to delete what we created.

  • rm: This stands for remove command. This will let you delete any file by typing the filename or filename along with path followed by the command.

Say now we want to delete the sample.txt file we created, the command can be either rm sample.txt which will be equivalent to rm /home/debian/WorkSpace/sample.txt as your current working directory is /home/debian/Workspace.

Working on Linux Shell

After you execute this command, if you try to list the contents of the directory, you will notice that the file has been deleted and now the directory is empty.

Working on Linux Shell

Like this, you can make use of the shell commands work on your BeagleBone board via SSH over Ethernet or Wi-Fi. We will be seeing how to connect your BeagleBone board to Wi-Fi in Chapter 5, Connecting Physical Computing Systems to the Internet where you can setup your BeagleBone board to connect to your router via Wi-Fi instead of Ethernet to give wireless access to your BeagleBone board.

Now that you have got a clear idea and hands-on experience on using the Linux Shell, let's go ahead and start working with python and write a sample program on a text editor on Linux and test it in the next and last topic of this chapter.

bookmark search playlist download font-size

Change the font size

margin-width

Change margin width

day-mode

Change background colour

Close icon Search
Country selected

Close icon Your notes and bookmarks

Delete Bookmark

Modal Close icon
Are you sure you want to delete it?
Cancel
Yes, Delete