Skip to content

Review UNIX (and preview the IxE filesystem)

Wendy Ju edited this page Jan 30, 2016 · 4 revisions

Let's go over a couple of basic commands to help you move around the Linux filesystem. Right now, you are in your home directory. Directories are basically the UNIX name for a Folder. We will take a look at the file structure for our example "Hello You" project.

1. List directory

To see what is in the directory you can type ls

pi@ixe-05 ~ $ ls
audio      helloYou             node_modules      Public        Videos
Desktop    ixe-creator-webpage  node_tests        python_games
Documents  ixe-project-base     Pictures          sketchbook
Downloads  Music                processingJSTest  Templates

All of the listings in the home directory are other directories. Lets take a look inside one.

pi@ixe-05 ~/helloYou $ ls helloYou
helloYouSketch  node_modules  package.json  public  README.md  server.js

This shows us what is in the helloYou directory, but our working directory is still the 'home' directory.

2. Change directory

To change the working directory, type cd [directory-name]

pi@ixe-05 ~ $ cd helloYou/
pi@ixe-05 ~/helloYou $

The heading of the line (~/helloYou) tells us what directory we are in.

We can see what is in the helloYou directory using ls again.

pi@ixe-05 ~/helloYou $ ls
helloYouSketch  node_modules  package.json  public  README.md  server.js

Here we see a mix of directories (public) and files (server.js). server.js will be the webserver we will run with node.js. Inside the public directory are the files we will serve as our webpage.

Lets look in the public directory and see what is there. (Pro-tip: Use the tab key to autocomplete listings).

pi@ixe-05 ~/helloYou $ cd public/
pi@ixe-05 ~/helloYou/public $ ls
client.js  index.html

We can see two files here, client.js and index.html. client.js will control the interactivity and messaging for our webpage. index.html is the webpage markup or content of the page.

3. Return to higher level directory

To move up 1 level in the directory use cd .. where the .. means up one level. You can list the files to check you are in the correct directory.

pi@ixe-05 ~/helloYou/public $ cd ..
pi@ixe-05 ~/helloYou $

pi@ixe-05 ~/helloYou $ ls
helloYouSketch  node_modules  package.json  public  README.md  server.js

4. Jump to arbitrary directory

Though we often traverse the directory structure by going into and out of directories one level at a time, we can actually jump to any directory if we know the complete path or the path relative to the 'home' directory.

pi@ixe-05 ~/helloYou $ cd sketchbook/blink
pi@ixe-05 ~/sketchbook/blink $ ls
blink.ino  build-micro  makefile

5. Show absolute path

If you get lost, you can type 'pwd' to get a listing of your absolute path in the directory structure.

pi@ixe-05 ~/sketchbook/blink $ pwd
/home/pi/sketchbook/blink

6. Show what is in a file

You can type 'cat [filename]' to look into a text file.

pi@ixe05 ~/sketchbook/blink $ cat blink.ino
// Blink sketch
int led = 10;

void setup(void) {
  pinMode(led, OUTPUT);
}

void loop() {
  digitalWrite(led, LOW);
  delay(1000);
  digitalWrite(led, HIGH);
  delay(1000);
}

7. Change to home directory

To get back to the home directory no matter where you are in the file structure, you can just type cd without a path (the location of the directory you would like to change to) or cd ~

pi@ixe-05 ~/sketchbook/blink $ cd
pi@ixe-05 ~ $

pi@ixe-05 ~ $ ls
audio      helloYou             node_modules  processingJSTest  Templates
Desktop    ixe-creator-webpage  node_tests    Public            Videos
Documents  ixe-project-base     oldconffiles  python_games
Downloads  Music                Pictures      sketchbook  

###8. Super User mode

###9. Halt It is important that you shut down your IxE properly to avoid damaging the filesystem. To shutdown, use the halt command.

sudo halt

###10. Other Unix commands Here is a Unix cheatsheet that shows other basic commands worth knowing about.

IxE Workshop

For Novices

  1. Unix command review

  2. Hello You Introduction

  3. Log on to your IxE

  4. IxE overview

  5. Run the Hello You example

  6. Understanding Hello You

  7. Logging Out & Shutting Down

Post Novice
0. Logging in as Pi

  1. Preview the larger IxE image
  2. [Project Ideas](Project Ideas)

Also [Related Links](Related Links)

Clone this wiki locally