Introduction to the linux shell
For users who are new to linux, this page will give you an quick intro to the shell and make the telnet commands listed on other pages not so scary.
- 1 Intro for Windows/Mac Users
- 2 Command Prompt Basics
- 3 Linux File System and unRAID folders
- 4 Some Useful Commands to know
- 5 Getting things installed on your unRAID server
Intro for Windows/Mac Users
The linux shell accessed over telnet is basically exactly the same as Remote Desktop for Windows or MacOS - you just don't get a GUI, you get a command line. Drag and drop is replaced with "cp", the trash/recycle bin is replaced with "rm", and double click is replaced with an "<application> <filename>" convention. Most people shy away from the command line because it looks complex, but it's really not. In most cases, you can copy and paste commands given on the How-to pages in this wiki, and once you have done it a few times, you'll start to recognize commands and be able to do things on your own.
For an increasing number of users, unRAID is their first exposure to linux, and the command line. The web GUI is great, but there are many things you can't do there, and most people will need to use the command line as some point, so let's dive in.
Getting access to your server
To get connected to your server, we need to use telnet. Telnet is a basic remote command line program installed by default in both MacOS and Windows (used to be, see the note below).
Telnet in Windows
Note: Windows 7 and newer have removed telnet by default but you can "turn it on" easily. Enable Telnet in Windows 7 and newer
- Open the Windows Command Prompt - usually under All Programs > Accessories > Command Prompt
- Type in "telnet <your server name>" and press Enter
- Enter the username "root" when asked and press Enter.
- Enter your password when asked and press Enter.
- You'll get the linux command prompt.
Telnet in Mac OS
- Open Terminal - Applications > Utilities > Terminal
- Type in "telnet -l root <your server ip address or name> and press Enter
- Enter your password when asked and press Enter.
- You'll get the linux command prompt.
This is the linux shell. unRAID uses "bash" and the command prompt - basically the linux version of DOS.
Command Prompt Basics
The prompt itself
Since we are using bash, the command prompt that we are give shows us some useful information. When you first login you should see this:
Linux 3.4.11-unRAID. root@knox:~#
If we break that down we can learn the following information
- root - the user you are logged in at
- knox - the server we are logged into - my unraid box is called knox, yours is probably "tower" or what ever you changed it to
- ~ - the folder we are currently in - ~ represents your home directory which is actually /root
- # - the prompt where you can type a command
Type in "cd /boot" and you'll see that the "~" changes to "/boot"
All linux commands follow the structure
<command> <flags> <arguments>
- <command> represents the command or program you are going to run
- <flags> represents a modification of the command that changes the way it works
- <arguments> represents the data or file you are passing to the command
Take the following example:
ls -la /boot/config
This command will give a detailed list of all files in the /boot/config directory.
- ls - the list command
- -la - the long (detailed) flag and the all (include hidden files) flag
- /boot/config - the directory we are going to list.
You should get the following output (or something similar):
# ls -la /boot/config total 72 drwxrwxrwx 4 root root 4096 2012-10-12 23:39 ./ drwxrwxrwx 9 root root 4096 2012-10-19 16:40 ../ -rwxrwxrwx 1 root root 256 2012-10-12 13:41 Pro.key* -rwxrwxrwx 1 root root 8171 2012-10-21 16:54 disk.cfg* -rwxrwxrwx 1 root root 101 2011-12-16 15:29 flash.cfg* -rwxrwxrwx 1 root root 792 2012-10-22 14:17 go* -rwxrwxrwx 1 root root 302 2012-10-12 17:25 ident.cfg* -rwxrwxrwx 1 root root 198 2011-09-01 09:37 network.cfg* -rwxrwxrwx 1 root root 946 2012-02-13 07:54 passwd* drwxrwxrwx 11 root root 4096 2012-10-19 14:56 plugins/ -rwxrwxrwx 1 root root 712 2012-02-13 07:54 shadow* -rwxrwxrwx 1 root root 345 2012-10-12 17:25 share.cfg* drwxrwxrwx 2 root root 4096 2012-10-11 11:59 shares/ -rwxrwxrwx 1 root root 673 2012-10-11 12:37 simpleFeatures.cfg* -rwxrwxrwx 1 root root 413 2012-10-12 17:24 smb-extra.conf* -rwxrwxrwx 1 root root 428 2012-02-13 07:54 smbpasswd* -rwxrwxrwx 1 root root 4096 2012-10-12 23:39 super.dat*
Linux has a built in help system called man ("man ls" should bring up help on ls). However, since unRAID is run off a flash dirve, the man help files are EXCLUDED to save space. You can access the man pages easily on google though. Try searching for "man ls" and you'll get the help page for this command.
Linux File System and unRAID folders
Linux doesn't use a letter or volume system to map drives. So there is no "C:" or "Macintosh HD". Instead there is a single file system and your actual drives are mounted with in that as folders. In unRAID that gets more confusing because the file system becomes virtual through the use of a RAM drive. More details below...
- / represents the top of the file system so everything is within that.
- /boot is where your flash drive is mounted - the boot drive
- /mnt is where your hard drives are mounted - cache, disk1, disk2, etc
- /mnt/user is where your user shares are mounted.
So if you want to see the contents of a user share called "media" you would type the following:
Let's take a look at the files on your flash drive.
cd /boot ls -l
Note: when no folder is passed to the ls command, it assumes you mean the current directory. This should output something close to the following:
root@knox:/# cd /boot root@knox:/boot# ls -lh total 35M -rwxrwxrwx 1 root root 2.2M 2012-09-17 20:32 bzimage* -rwxrwxrwx 1 root root 33M 2012-09-17 20:40 bzroot* drwxrwxrwx 4 root root 4.0K 2012-10-12 23:39 config/ drwxrwxrwx 2 root root 4.0K 2012-10-22 15:51 extra/ -rwxrwxrwx 1 root root 32K 2012-10-10 19:17 ldlinux.sys* -rwxrwxrwx 1 root root 5.1K 2012-09-17 20:40 license.txt* drwxrwxrwx 2 root root 4.0K 2012-10-12 23:37 logs/ -rwxrwxrwx 1 root root 781 2012-09-17 20:40 make_bootable.bat* -rwxrwxrwx 1 root root 161K 2012-09-17 20:40 memtest* -rwxrwxrwx 1 root root 60K 2012-10-10 19:17 menu.c32* drwxrwxrwx 2 root root 4.0K 2012-10-12 16:54 packages/ -rwxrwxrwx 1 root root 82K 2011-08-28 13:34 preclear_disk.sh* drwxrwxrwx 2 root root 4.0K 2012-10-12 13:46 preclear_reports/ -rwxrwxrwx 1 root root 18K 2012-09-17 20:40 readme.txt* -rwxrwxrwx 1 root root 173 2012-10-10 19:17 syslinux.cfg* -rwxrwxrwx 1 root root 27K 2012-09-17 20:40 syslinux.exe* -rwxrwxrwx 1 root root 9.4K 2011-11-23 16:11 unraid* root@knox:/boot#
The h flag makes the file sizes come out in a human readable format. Here is what we are seeing...
- -rwxrwxrwx - this is the file permissions - every users has full access to these files
- the first char indicates the file type: - is a regular file, d is a directory, l is a link (alias/shortcut)
- the next three chars indicate the permissions for the owner (r = read, w = write, x - execute)
- the next three chars indicate the permissions for users in the file's group
- the next three chars indicated the permissions for all other users on the system
- 1 - the number of links to that file
- root - the owner of the file
- root - the group of the file
- 2.2 MB - the size of the file
- 2012-09-17 20:32 - the modification date of the file
- bzimage - the name of the file
The unRAID RAM drive
Since unRAID is installed on a flash drive (which is not very good for reading and writing a lot of data), unRAID actually creates a small drive in RAM for your system to run out of.. if you go to / you are in that drive. One VERY important thing to remember is that a RAM drive is erased when rebooting. So if you create a file in your home directory (/root/important-file.txt) it will be deleted when your server is rebooted. The only place files are safe is in the /boot folder (which is actually your flash drive), on an array disk at /mnt/disk# or in a user share at /mnt/user/<folder name>.
You'll notice that most plugins install themselves in the linux equivalent of "Programs" or "Applications" at /usr/local. Since this is not on a physical drive, this is deleted when we reboot. The solution is that plugins actually re-install themselves each time you boot up your system.
Important unRAID files and directories
On your flash drive (/boot) there are several important directories to know:
- config/ - this folder contains all the unraid config files
- config/plugins - this is where plugins are installed - they are automatically loaded at each boot
- extra/ - any slackware packages in this folder will be installed automatically at boot
- packages/ - a folder where plug-in dependancy packages are stored (packages that are required to run plugins)
- config/go - the go script is executed when the server boots - this is where you can enter any commands you want to run at boot up
- config/Pro.key or Plus.key - this is your unraid licence file that you installed
- config/smb-extra.conf - this is an extra config file for Samba (windows network shares) - you can put in custom Samba configs in here
Some Useful Commands to know
Basic File Commands
lists the contents of a directory. ls /boot/config
changes to the directory cd /boot/config/plugins
cp <source> <destination>
copies the source file to the destination cp /boot/packages/my-package.tgz /boot/extra/
mv <source> <destination>
moves the source file to the destination - mv is also used to rename files - just move it from the old file name to the new one. mv /boot/packages/my-package.tgz /boot/extra/my-package-with-a-new-name.tgz
deletes the file rm /boot/config/plugins/bad-plugin.plg
mkdir <directory name>
creates a new directory mkdir /boot/custom-scripts
Basic Telnet Programs
shows the list of programs running on your server
a basic text editor that will allow you to edit <filename> - I would HIGHLY recommend installing nano if you're new to linux (see below)
wget <file url>
downloads a file off the internet to your server
Getting things installed on your unRAID server
There are a few ways to install things on your unRAID server, over the network share, or directly with the command prompt. Now you are a telnet expert, we're going to install nano - a user friendly text editor - over the command prompt.
Wer're going to install nano in the /boot/extra folder so that it will be installed each time we start the server. So let's go there... cd /boot/extra Now, we want to find a copy of nano on the internet. Remember before I mentioned slackware packages when talking about the /boot/extra directory? Well I'm going to search the Slackware Linux package browser and I'll find nano here. I'll use wget to download the file. wget ftp://ftp.slackware.com/pub/slackware//slackware-14.0/slackware/ap/nano-2.3.1-i486-2.txz That is all we have to do, that will be installed automatically when we reboot, but to use it now, we need to install the package: installpkg nano-2.3.1-i486-2.txz Now we can edit a file with nano.. nano /boot/config/go At the bottom of the screen you'll see the commands The ^ symbol means "Control", so CTRL+x will exit out.
I hope you found this basic introduction useful.
--Whiteatom 13:26, 23 October 2012 (UTC)