Linode Manager dashboard. It takes just a few clicks to install Linux with this dashboard. If you don't have a particular Linux distribution in mind, install Ubuntu 16.04 LTS. Ubuntu is good for Linux beginners because it is well-supported and doesn't change often.
After you know which distribution you want to install, follow the instructions for installing Linux in the Getting Started article. Follow that article until you complete Booting Your Linode, then come back here.
Your Linode is physically housed in the Atlanta, Dallas, Frankfurt, Fremont, London, Newark, Singapore, or Tokyo data center, so you have to use the Internet and a terminal to connect to it and start using it. A terminal is a tool that runs a shell that lets you run text commands to interact with your server. The Secure Shell (SSH) protocol lets you send these commands to your Linode over a secure Internet connection from your local machine.
{{< note >}} In this guide, we'll mostly be using the terms terminal, shell, and SSH to refer to the interface you use to send text commands to your Linux system. These are different tools that layer on top of each other to let you interact with your server. To learn more, read these simplified definitions:
To connect to your Linode, follow the next section of the Getting Started article, Connecting to Your Linode. Follow along with the written instructions or watch the videos, or both. It will help you install a terminal emulator and use it to establish an SSH connection to your Linode.
After you connect to your Linode, you should be looking at a shell prompt that looks like this with a blinking cursor:
root@localhost:~#
What does this bit of text mean? The entire thing is the shell prompt. It's your terminal's way of telling you that it's ready for you to enter the next command. The different parts of the shell prompt provide information:
/root
. For users other than the root user, home directories are in /home/user1
, where user1 is the name of the user.You can type any valid Linux shell command at the blinking cursor after the shell prompt. We'll go over a few practical commands in the rest of this article, but to get a really good in-depth introduction to the command-line interface, you should read the Using the Terminal article as well.
{{< note >}} These command line tips will make your Linux forays much more effective:
Return
or Enter
key after you finish a command.pwd
, short for print working directory.Up Arrow
on your keyboard to see or reuse the previous command that was executed. {{< /note >}}In this section, we'll look at the structure of a Linux server. Everything on your Linode is a file or a directory. Remember, directory is the Linux term for a folder. Linux uses a tree of nested directories to keep its files organized. The highest-level directory is called the root directory. It's designated with a single slash. Unlike Windows, there are no different disks or drives; the root directory is the highest-level directory for all Linux systems. Underneath the root directory are more, sub-directories.
Most Linux systems have directories called lib
and var
(along with several others) underneath the root directory. The lib
directory contains system libraries, while the var
directory contains all of the files on your system that are likely to change, such as your logs and your mail messages. Directories can go inside other directories, as illustrated below:
Find out where you are in the directory structure. Make sure your terminal application is selected and that you're logged in to your Linode. You should see a blinking cursor where you can start typing.
For your first command, use the pwd
command. Short for print working directory, it lets you view the full path to your current directory. Type pwd
after the shell prompt:
root@localhost:~# pwd
Press Return
to execute the command. You should see the following output:
/root
The output of pwd
shows you the full path to your current directory or directory. At the moment, you're inside the /root
directory. You will always be inside a particular directory when you execute shell commands, although which directory you're in can change. The pwd
command is very useful because it shows you exactly where you are in your Linode's directory structure.
Let's move into the root directory, /
, with the cd
command. The cd
command is short for change directory. After cd
type a space and then the file path. The file path can be long or short, depending on how deep you're going into the directory structure.
Change to the root directory:
At the shell prompt, type the following command, and press Return
to execute it.
cd /
Now you're in the root directory.
The list command, ls
, shows everything that's directly inside of your current directory. To make the output the most helpful, you can add a few flags to the ls
command. The flags are part of the command. In this case, we'll add the -ahl
flags to show -a
all the files, in -h
human-readable format, and with a -l
long list format. There are more flags that you can add to the ls
command, but you can learn more about them on the web.
List the current directory:
Type the following command, and press Return
to execute it:
ls -ahl
The output should look something like this: {{< output >}} total 84K drwxr-xr-x 22 root root 4.0K Apr 30 2012 . drwxr-xr-x 22 root root 4.0K Apr 30 2012 .. drwxr-xr-x 2 root root 4.0K Nov 6 16:04 bin drwxr-xr-x 3 root root 4.0K Feb 4 2013 boot drwxr-xr-x 11 root root 14K Nov 6 16:17 dev drwxr-xr-x 94 root root 4.0K Dec 10 20:27 etc drwxr-xr-x 4 root root 4.0K Feb 19 2013 home drwxr-xr-x 16 root root 4.0K Nov 6 16:04 lib drwx------ 2 root root 16K Apr 26 2012 lost+found drwxr-xr-x 3 root root 4.0K Apr 26 2012 media drwxr-xr-x 2 root root 4.0K Apr 19 2012 mnt drwxr-xr-x 3 root root 4.0K Nov 18 13:34 opt dr-xr-xr-x 141 root root 0 Nov 6 16:16 proc drwx------ 3 root root 4.0K Apr 7 2013 root drwxr-xr-x 15 root root 560 Dec 10 15:57 run drwxr-xr-x 2 root root 4.0K Nov 6 16:04 sbin drwxr-xr-x 2 root root 4.0K Mar 5 2012 selinux drwxr-xr-x 2 root root 4.0K Apr 26 2012 srv dr-xr-xr-x 13 root root 0 Nov 6 16:16 sys drwxrwxrwt 2 root root 4.0K Dec 10 21:09 tmp drwxr-xr-x 10 root root 4.0K Apr 26 2012 usr drwxr-xr-x 13 root root 4.0K Nov 6 16:04 var {{< /output >}}
There are quite a few files inside this directory. The most important part is the list of directory and file names on the right, listed alphabetically. You'll notice the directories lib
and var
, as well as several others.
{{< note >}} The /root directory is not the same as the / directory. / is the top-level directory of the server. Everything else is inside it. It is called the root directory when you're talking about it, but its name on the server is just /. On the other hand, the /root directory is the home directory for the root user. It's a sub-directory under the / directory, and it's where the root user starts after logging in to a new SSH session. {{< /note >}}
If you open the var
directory, you'll find more directories, such as log
for your logs, and mail
for your system mail.
Move into the var
directory by executing the cd
command:
cd var
View the contents of the var
directory with the ls
command, just like we did earlier:
ls -ahl
You'll see another list of directories:
{{< output >}} total 52K drwxr-xr-x 13 root root 4.0K Nov 6 16:04 . drwxr-xr-x 22 root root 4.0K Apr 30 2012 .. drwxr-xr-x 2 root root 4.0K Nov 19 06:27 backups drwxr-xr-x 9 root root 4.0K Apr 6 2013 cache drwxrwsrwt 2 root whoopsie 4.0K Apr 26 2012 crash drwxr-xr-x 37 root root 4.0K May 29 2013 lib drwxrwsr-x 2 root staff 4.0K Apr 19 2012 local lrwxrwxrwx 1 root root 9 Apr 30 2012 lock -> /run/lock drwxr-xr-x 14 root root 4.0K Dec 12 06:53 log drwxrwsr-x 2 root mail 4.0K Aug 8 03:50 mail drwxr-xr-x 2 root root 4.0K Apr 26 2012 opt lrwxrwxrwx 1 root root 4 Nov 6 16:04 run -> /run drwxr-xr-x 6 root root 4.0K May 29 2013 spool drwxrwxrwt 2 root root 4.0K Feb 4 2013 tmp drwxr-xr-x 2 root root 4.0K Apr 6 2013 www {{< /output >}}
Here you can see the log
and mail
directories, as well as several others. At the top of the list, you see two directories named .
and ..
with periods. Similar to the tilde (~) we saw earlier, these directories are actually shortcuts or aliases, that appear in every directory. The single-period directory indicates the current directory. The double-period directory indicates the directory above the current one. If you are inside a lower-level directory and want to move to the directory above it, type cd ..
.
To move back up to /
from var
, type the following command:
cd ..
You should be in the /
directory again. You can use pwd
to verify this.
pwd
Let's take a look at the lib
directory. Move into lib
with the cd
command:
cd lib
List its contents with the ls
command:
ls -ahl
Inside, you'll see more directories and long list of library files that all start with lib
. The output is very long, so we're just showing part of it here. The ...
indicates that the output continues.
{{< output >}} total 1.2M drwxr-xr-x 16 root root 4.0K Nov 6 16:04 . drwxr-xr-x 22 root root 4.0K Apr 30 2012 .. lrwxrwxrwx 1 root root 21 Apr 6 2013 cpp -> /etc/alternatives/cpp drwxr-xr-x 2 root root 4.0K Apr 26 2012 firmware drwxr-xr-x 2 root root 4.0K Feb 4 2013 hdparm drwxr-xr-x 3 root root 8.0K Oct 23 00:28 i386-linux-gnu drwxr-xr-x 2 root root 4.0K Mar 18 2013 init -rwxr-xr-x 1 root root 74K Mar 30 2012 klibc-LZ1cv1NoEVO2ugnvqTw3e4qPc8Y.so lrwxrwxrwx 1 root root 25 Sep 30 14:38 ld-linux.so.2 -> i386-linux-gnu/ld-2.15.so -rw-r--r-- 1 root root 143K Mar 20 2013 libdevmapper.so.1.02.1 lrwxrwxrwx 1 root root 16 Apr 30 2012 libfuse.so.2 -> libfuse.so.2.8.6 -rw-r--r-- 1 root root 179K Mar 2 2012 libfuse.so.2.8.6 ... {{< /output >}}
Now you know how to use the pwd
command to show you where you are, the cd
command to move to a new directory, and the ls
command to show you the contents of a directory. These are the basic tools you need to navigate through your Linode's files and directories. To learn more about navigating directories, read the linked section of the Using the Terminal guide.
One of the easiest ways to upload your own files to your Linode is with a Secure FTP (SFTP) program. See Migrate from Shared Hosting to Linode for a walkthrough on how to upload your own files using SFTP.
Linux uses a powerful system of users and permissions to make sure that the right people get access to the right files. For example,
You can set users and permissions for each file directory on your Linode.
Three categories comprise the file access system in Linux:
The next important concept is permissions. Every file and directory on your Linux system has three possible access levels:
View the users and permissions for a particular file or directory.
Run the ls -l
command replacing my_directory with the name of your own file or directory:
ls -l my_directory
That command produces output like the following:
drwxr-xr-x 13 user1 group1 4.0K Nov 6 16:04 my_directory
The user and group are listed in the middle. In this case, the user is user1 and the group is group1. The user is listed first and the group second. The permissions are listed at the beginning of the line. Ignoring the first character, you can see that the permissions for the my_directory
directory are rwxr-xr-x.
The user permissions are listed first and the group permissions are listed second. The everyone permissions are listed last.
my_directory
directory, run files in it, but not change them.var
directory, but not change them, because the permissions for everyone are r-x.To learn about users and groups in more detail, read the Linux Users and Groups article.
This section shows you how to install, run, update, and uninstall software from a Linux system.
Like most things in Linux, installing software is accomplished by typing and executing a specific text command. The most popular Linux distributions come with package managers that make it relatively easy to install and uninstall software on your Linode. Debian and Ubuntu use the Advanced Packaging Tool (APT) package manager, and Fedora and CentOS use the Yellowdog Updater, Modified (yum) package manager.
Our Quick Start Guides series contain basic instructions for installing and configuring many common types of Linux software. The Hosting a Website guide shows you how to install software to run a website, while Running a Mail Server is for email servers.
Because we've been working with the Ubuntu 16.04 distribution so far, let's look at an example with APT. The general form of the installation command for Ubuntu and Debian systems is:
apt-get install software
Replace the word software in the command above with the package name for the software you want to install. There are thousands of different programs available to install on your server. If you search online for the software you need, you can find the correct package names to use with the APT installer. For example, if you searched for "ubuntu web server," you would find information about the Apache web server, and its package name, apache2.
Run this command to install the web server Apache, which lets you display websites:
apt-get install apache2
apache2 is the name of the package for Apache in the Ubuntu repositories. A package is a piece of software. Repositories are collections of software for your Linux distribution. The apt-get
command looks up an Ubuntu repository (specified on your system), finds the apache2 package, and installs it along with anything else you need for Apache.
Using yum on Fedora and CentOS systems is just as easy:
yum install software
There are three main ways to run programs in Linux.
Always on:
You want some programs, like your web server, to run constantly. These are the programs that run as services on your Linode. For example, your web server keeps your website visible, so you want it to stay on all the time. Server processes that stay running in the background are known as daemons. To start a daemon, run the following command, replacing software with the name of the software you want to run. The name will be the same one you used to install it (for example, apache2 for Apache):
systemctl start software
Once:
Sometimes you want to run a program on an as-needed basis. For example, you might want to run a script to rename a group of files.
cd
command to move into the directory where the script is located.ls -l directory
to check that your user account has execute permissions for the script file in the directory. If you need to modify the permissions, see the Linux Users and Groups guide../my_script
Scheduled:
Sometimes you want to run a program at regular intervals, as in the case of a daily backup script. The best way to do this is with the cron tool. Read the Schedule Tasks with Cron article to learn more. Scripts that you run this way also have to be executable.
As long as you installed your software with a package manager, use APT or yum to update your entire system with one simple step.
Update a Debian or Ubuntu system:
apt-get update
apt-get upgrade --show-upgraded
Update a Fedora or CentOS system:
yum update
{{< caution >}} Updating your software is good for your system security. In most cases updates will go smoothly, but it's possible that some updates may break something on your server. It's always wise to make a backup of your system before updating it. {{< /caution >}}
If you need to uninstall software, use the apt-get remove
command:
apt-get remove software
If you also want to remove all configuration files associated with the software, run this command instead:
apt-get purge software
Here's the yum version for Fedora and CentOS:
yum remove software
When you run a Linux system, you are in charge of its security. The Internet is full of people who want to use your Linode's computing power for their own goals. If you neglect to change default passwords, install out-of-date software, or leave other security holes available for hackers to exploit, it won't take long for your system to get hacked. Follow the steps in the Securing Your Server guide to harden your server's security.
The main differences between Linux distributions tend to be from goals and aims of the distribution developers and which bundles of software are installed by default, rather than differences in the code of the Linux kernel.
RedHat Linux (which includes Fedora and CentOS) and Debian Linux (which includes Ubuntu) share a large amount of code with each other. The kernels are largely the same, and most of the user utilities and applications from the GNU project are the same.
Some distributions are designed to be as simple and minimalistic as possible, while others are designed to contain the most current, bleeding-edge software. Still others aim to provide the greatest amount of stability and reliability. In addition to the personality of each distribution, which you'll have to discover for yourself, there are a number of factors that you might find useful when choosing a distribution.
.deb
packages, CentOS and Fedora use yum to manage .rpm
packages, and OpenSUSE also uses .rpm
packages but manages them with a tool called yast. In many cases your choice of distribution will come down to the one that provides the tools you need and are most comfortable with.Different distributions of Linux are right for different situations. You should experiment until you find the best fit for you. Given the similarities between different distributions, don't be afraid switch to a new one that will serve you better. If you're familiar with the concepts in this article, you're well on your way to administrating your system like a pro with any distribution of Linux.