Linux Basics

Starting a journey with linux can be tough at times, especially when you are no tech pro. Yet, it’s worth taking a while to get to know this system and it’s basics. Maybe someday you will switch to, say,  Ubuntu instead of pricey Windows. Who knows? ;)

Nowadays, Linux is not a command shell handled with bunch of unclear commands. It’s now beautifuly designed, fast and handy OS, just take a look on Fedora or Ubuntu. But, there is always a but ;) Raspi cannot handle such eye-candy OS, so we have to go with light but amazingly fast distros like Raspbian, raspbmc. Thus most of maintenance have to be done through mentioned command shell. But fear not, once you learn below basics you’ll be all set to comfortably use linux command shell. I tired to make it as complete as possible, yet if I missed something, failed to explain or so, let me know in comments area what you think, I’ll appreciate any help.

Run console application if your raspi is connected to monitor, mouse, keyboard etc. or connect to it using Putty.

1. Directories

Linux uses different structure of directories from what structure windows uses. Main folder is /, you cannot go higher than that. It’s called root folder, for example, /home/pi/importantstuff.pdf shows full path to importantstuff.pdf file in pi’s home directory under root directory. There are also two special directories:

. – dot. This is current directory, so ./importantstuff.pdf tells you to search for importantstuff.pdf in current working directory

.. – double dot. This is parent directory, going up if you like.

~ – tilde. This represents your home directory, e.g. home directory for user pi is /home/pi/


/bin – important binary applications
/boot – important filles that linux needs to boot
/dev – the device files
/etc – configuration files, startup scripts
/home – users home directories
/lib – system libraries
/media – mounted media such as pendrives, CDs
/mnt – all mounted filesystems
/opt – installed optional applications
/proc – currently running processes
/root – root user home directory
/sbin – important system binaries
/sys – system files
/tmp – temporary files
/usr – applications and files for all users
/var – variable files such as logs

2. Basic commands

Just basic commands that allows to move around in directories and do basic operations on files/directories.

ls (list). Lists filest and directories that are in your current directory.

But beware, ls do not in fact list ALL your files and directories, by default hidden objects remain hidden. File or directory is considered hidden when first character of its name is . (dot).  To list also such objects you have to use -a parameter:

To list all attributes of files you should use -l parameter:

And parameters are, in order: permissions, owner, group, size, date of last change and file name. You can also use many other parameters, those are only most commonly used ones, to list all use ls –help.

mkdir (make directory). Creates subdirectory in your current directory, for example:

cd ( change directory). This is self explanatory, changes directory :)

pwd ( print working directory). Prints your current working directory.

cp (copy). Makes a copy of file.

Cp will not ask you if it should overwrite file if destination file already exists. You have to know what you are doing because there is no easy way to recover file after overwritting or deleting (believe me, I know something about it ;) ). To make sure that you will never accidentally  overwrite any file you can use cp with -i parameter. Cp will ask you if should overwrite, Y(es) accepts N(o) denies.

mv (move). This command moves a file from one place to another.

You can define also as a second parameter new name for a file, in other words you can use mv to rename file.

Exactly same situation as with cp, remamber to be careful because you can easily overwrite files.

rm (remove) and rmdir (remove directory). To delete a file, use the rm command, to remove directory use rmdir.As simple as that.

But, if the directory is not empty you have to either empty it or use rm -r as in recursive to delete directory along with all contents.

cat (concatenate). The command cat is mostly used to display the contents of a file on the screen.

And that’s all. I merely scratched surface of this topic, if you feel that we should more advanced linux tutorial let us know in comments.

Here is your raspberry pi ampilight system!