Basic Linux Guide

From Pandora Wiki
Jump to: navigation, search

New to the wonderful world of Linux? No problem! You don't need mad terminal skills to open a web browser, but it can be nice to know what you're doing once in a while.

The structure of the file system

If you're used to the file system of e.g. MS Windows, you will find that a Linux file system is rather different from what you're used to. In this section, we will go through everything you have to know in order to feel comfortable with using the Pandora's file system.

Basic philosophy

In Windows, you have multiple file system roots, called "drives", that are labeled with different letters, like "C:" or "D:". In Linux, there aren't multiple root directories, but rather just one root directory, called "/". All other directories are inside of this directory, including other drives.

Common directories

Inside of the root directory ("/") are quite a lot of other directories. Here are the most important ones for a Pandora user:

Folder Comment
/media/* External media such as SD cards, flash drives and HDDs show up in here as folders. You can think of these folders as shortcuts to the devices. Almost everything you do on the Pandora will be done here.
/usr/ Here is where you'll find programs and files installed on the Pandora itself. Core applications such as the web browser, media player, and other applications that are available the first time you start your Pandora are stored here inside the "/share" folder. If you decide to install anything via the "ipkg" command (covered later), this is where the files needed by those installations will end up.
/etc System-wide configuration. Should only be touched by power-users.
/home This is where all of the files that are owned by all users are stored. Users do not generally have write-access to anything outside of this directory. This directory is on the NAND and has limited space, as are all directories except for /media
/home/username Here are the personal files of user "username". In this directory, you will find a directory called "Documents", "Pictures", "Desktop" etc. that correspond to that user's personal directories. This directory is also called "username"'s home directory, and can be abbreviated with "~/" (if you're currently logged in as username) or "~username/".
/tmp Home of temporary files. On the Pandora, you'll find several files here with .out extensions. If a program crashes, the developers may ask you to find its .out file and copy+paste the content, so they can see what went wrong.
/boot This is the directory where the Linux kernel is stored, and other files that are needed at boot time can be accessed. Do not touch this directory (You can't even do it if you wanted to)!
System binaries and libraries are stored here. Most of the terminal commands mentioned below can be found inside of "/bin". You should generally never have to touch this directory, either.
/mnt/utmp Often, programs will ask you to save to their folders in this directory. Anything "saved" here is actually saved at the analogous location in your "/media/[your SD card]/pandora/appdata" directory.
/mnt/tmp This is a read-only folder that will show you the contents of a PND file if you have one open. You can also view PND contents by copying it over to your PC, changing its extension to .sfs and opening it with 7zip. (see here)

Don't worry if this doesn't make any sense; It was thought up by bearded engineers back in the seventies. They liked the idea that everything would be in a predictable place, but this is no longer completely the case.

Basic Terminal Commands

Note: Linux is case sensitive. This applies to filenames and directories too. "/home/me/stuff" is a different folder than "/home/me/STUFF", you can actually have both. You can have "/home/me/Stuff" too if you like, and all three are separately recognised directories.

If you are in Terminal you can send commands to your shell (here it is BASH)


In the terminal, you are always in some folder. Think of it like being in a file manager: you can see the contents of the directory you're in, you can do things with those files, or you may decide to go to some other folder and continue your work there.

There are a few essential commands that are used to navigate around your system via the terminal:

Command Comment
pwd Print the current working directory (will print e.g. "/home/user")
ls List directory contents (similar to "Dir" in Dos, and the Linux command "dir" will actually emulate the DOS command if you want to!)
cd <directory name> Change to a different directory, eg. "cd music" or "cd /home/me/music"
cd .. Go up one directory level (similar to "cd.." in Dos)
cd Go back to your home directory (similar to My Documents in Windows)
cd - Go back to the previous directory you were in (handy if you forget)

Controlling Running Apps

Command Comment
top View running processes (like the Task Manager in Windows) press "q" to quit
killall [program name] Stops running process (use with care)

File Manipulation

Command Comment
rm <filename> Remove a file, eg. "rm somefile.txt" or "rm /home/me/randomfiles/somefile.txt"
rmdir <directory> Will remove a directory, but **only** if it is empty!
rm -r <directory> Will remove a directory and its contents ("-r" means recursive)
rm -rf <directory> Will remove a directory, all of its contents, without asking you first. Use with extreme care. ("-f" means force)
mv <original filename> <new filename> Moves a file to a new place, also used for renaming, eg. "mv somefile.txt somefile_backup.txt" will rename it, but "mv somefile.txt /home/me/backup/somefile.txt" will move it. This will also work for directories.
cp <file to copy> <new filename> Copy a file, eg. "cp twoweeks.txt twomonths.txt" copies into current directory, while "cp twomonths.txt /home/me/ihaveadream/twoweeks.txt" copies to another directory.
cp -r <directory to copy> <new directory name> Copy a directory and all of its contents to another location.
touch <new file name> Makes a new (empty) file
mkdir <new directory name> Makes a directory


Command Comment
cat <filename> Prints the contents of a file, eg. "cat hellolo.txt"
clear Clears screen, terminal input begins at the top again
date Your friend, the terminal will tell you the date
cal [month] [year] Makes a pretty calendar, eg. "cal 12 2009" or "cal * 2010" or "cal 1 2010 > fingers_crossed.txt" sends output to file
history Gives a list of the recent commands you have run. Running !number (e.g. !15) will rerun that numbered command in the history list
vi <filename> Opens the file for editing in vi [1]

Bash tips

History Search: Press CTRL-R. As you type, BASH will try and find the command in your recent history that most closely matches what you are typing. To get back to the prompt, press CTRL-C.

Autocompletion: Press TAB. The terminal (also called the shell) will attempt to intelligently figure out what you're trying to type. It needs something to work with however, so try pressing TAB half way through a command or location.

eg. "cd /home/me/pandora_suc" *TAB* will complete it as "cd /home/me/pandora_success" or with a filename "cat /home/me/letters/i_want_the_pandora_to_fa" *TAB* will turn into "cat /home/me/letters/i_want_the_pandora_to_fall_into_my_hands"

Directory aliases: There are some special directory names you can use to refer to a directory that would be too long to type otherwise, or that you simply don't know the name of.

  • "~" - Refers to your home directory e.g. "/home/user".
  • "~seconduser" - Refers to someone else's home directory.
  • "." - Refers to the current directory, or the "same directory" in a path. What this means, is that if you type "cd .", nothing will happen since you already are in ".", and if you type "cd somedir/././././././.", you will simply go to "somedir", since the "."-directories that come after it are the "same directory" as the one before them.
  • ".." - Refers to the directory in which the current directory is, or the "parent directory" in a path. If you type "cd .." you will come to the parent directory of your current directory, and if you type "cd s1/s2/s3/../../..", nothing will happen, since the path you specified cancels itself out.

See also

To mount a folder via ssh

  • Install an ssh server on the computer on which the folder you want to use on your Pandora is - on Ubuntu, for example you can do this by installing the package "openssh-server".
  • Find out the computer's IP, on Linux by entering
    ifconfig device
    on the pc, where device is for example eth0 or wlan0. This may output something like this:
eth0      Link encap:Ethernet  Hardware Adresse 00:23:54:40:b5:70  
          inet Adresse:111.222.333.444  Bcast:  Maske:
          inet6-Adresse: fe80::223:54ff:fe40:b570/64 Gültigkeitsbereich:Verbindung
          RX packets:2409696 errors:0 dropped:0 overruns:0 frame:0
          TX packets:1568020 errors:0 dropped:0 overruns:0 carrier:1
          Kollisionen:0 Sendewarteschlangenlänge:1000 
          RX bytes:2481151337 (2.4 GB)  TX bytes:281823385 (281.8 MB)

"111.222.333.444" is your IP.

  • On the Pandora open a terminal and type
    sudo mkdir /some/path
    where "/some/path" is where you want to mount the folder, for example "/media/desktoppc" or whatever.
  • Then enter
    sshfs user@IP:/folder/to/mount /where/to/mount/on/the/Pandora
    where "user" is your username on the pc, "IP" it's IP address, "/folder/to/mount" the folder on the pc you want to mount on your Pandora (for example /home/user) and "/where/to/mount/on/the/Pandora" the folder you created where you want to mount it on the Pandora.
  • You will be asked for a password, here enter the password of the user on the pc whose name you entered for "user" in the last step

Network shares

Look up, NFS, sshfs, cifs, samba old board topic