How To Get Started With A Linux Server
A guide to the commands, directories and conventions you’ll need to know about when getting started with a Linux Server.
So you’ve signed up for your first Linux server. Whether it’s VPS or dedicated, unless you have some prior Linux or Unix experience, you’re likely to suddenly come up against a seemingly vertical learning curve.
If you’ve only been using computers in the post-Windows ’95 world, the concept of configuring a server with a text-only interface can seem daunting and old fashioned. Thus, there are many control panel systems available to manage your server, such as cPanel and Virtualmin, which can vastly simplifying many of the tasks you’ll need to do.
For this article we are going to concentrate on a basic Linux server, so these details apply whether you have a control panel or not.
First you need to be able to connect to the server to configure it. Secure Shell (SSH) is a Linux tool that allows users to log-in to a server remotely, and use a command line interface exactly as if they were sat at a monitor and keyboard connected to a server.
This is the most common method used for Linux server management. The secure aspect is that all communications between you and the server are encrypted, so anyone snooping on the traffic shouldn’t be able to see what you are doing. All our Linux servers come with the SSH server installed and ready for you to connect.
For Windows users, the most commonly used SSH client is probably PuTTY. It’s a fairly self explanatory tool and also freeware. Another recommended option is SecureCRT, although that will cost you.
For Linux/Mac users the openSSH client is installed by most distros as standard and can be run from terminal by typing “SSH username@server’s.hostname.or.ip.address” for example “SSH root@example.com”. Your host will usually provide you with an initial username and password combination for accessing the server that you would use here. The user named root is the default superuser account in Linux and Unix.
Once connected, you will usually find yourself in your current user’s home directory, this is where a user would normally store their personal files. Linux and Unix have a number of conventions for their directory structure and I’ll explain a some here:
/ the root of the filesystem, this is the very start of the filesystem containing all the directories.
/home the home directory, this is where your user accounts directories live with all their data, the equivalent to Windows’ ‘Documents and Settings’.
/var this directory usually contains variable files and status files.
/etc this directory usually contains configuration files and scripts for the system
/dev this directory is not really a directory as such, it’s used to show you the devices on your server. These devices, such as hard drives, cd drives, usb devices etc, show as directories and files but can’t be accessed as such without special tools.
/boot this directory contains boot related files
/bin /sbin these directories contain important binary files (programs) for using the system. /bin contains user-level programs and /sbin contains system administration programs.
/lib /lib64 These directories contain library files that are important for use by the programs above.
/root the root user’s home directory, which is separate from the normal user’s home directories.
/proc This stands for processes. This directory is similar to /dev in that it isn’t a real directory as such, but contains information about currently running processes. The files and directories in here are all references to those rather than actual files.
/usr This directory usually holds user-level programs and libraries that are considered non-essential to the running of the system. It has sub directories similar to / in that you’ll find /usr/bin and /usr/lib
Other notable directories and files you may be interested in are:
/etc/init.d This directory contains startup scripts for many of the services you will install to your system, they are usually invoked using the switches of start|stop|restart.
/var/log This directory contains logfiles for your server. Default configuration for most software will put the software’s logfiles in a subdirectory there. Some important logfiles here are messages, syslog and dmesg. The first logs the basic outputs from most software running on your server in RedHat-based distributions, syslog does much the same for Debian based ones, dmesg is more device-specific, so will help give you an insight into hardware problems with your server. Not all messages logged are errors, many are simple status updates. There are many other logfiles in here, the use of most is fairly self explanatory.
/var/www In a default apache web server configuration this is the directory that your web pages will serve from.
/home/username/public_html This is the default directory that many control panel configured systems use for the web pages that the server serves. This allows each user on the server to have their own website files, which makes controlling many websites on one server easy.
Top Tip
You should have a look round your file system and try to get to know it, the more familiar you are with it, the easier it will be to solve problems as they arise.
A couple of commands that would be useful here are…
“cd” – the change directory command.
“ls” – the list directory contents command.
A complication to Linux server management is the number of different distributions available. The main ones you will find in a server environment will be Redhat-based (Red Hat Enterprise Server, CentOS, Fedora), or Debian-based (Debian, Ubuntu). Both families of Linux have different conventions and sometimes different tools available to do different tasks, some are easier in places than others, but both have many similarities.