Linux for Windows Server Admins

Sometimes, even a Windows admin has to get their hands dirty and touch a Linux server of some sort. The day will arrive when the Linux guy is off and something needs fixing! In this series of articles I hope to cover the basics of Linux administration. In today’s post, I’ll start off with the basics of Linux and logging in and exploring mounted media, and how to change between users and manage users.

In these tutorials I am using CentOS 6, a RedHat clone that is almost identical to RedHat, minus the trademarks. You can download and use CentOS 6 for free. CentOS is but one of several distributions (also known as “distros”). I chose it for no other reason than personal preference, and that it is also one of the most popular distributions used and backed by a very large vendor.

Other popular Linux distributions are SuSE, Debian, and the ever popular Ubuntu. Most of the commands and theory we’ll go into in this series work well on all mainstream Linux distributions. You should be able to easily download the distro that takes your fancy. These distros usually come as a bootable ISO installer. The one area that does vary is software installation.

Although Linux does have an optional GUI, very few Linux servers use it. Therefore this tutorial will concentrate on using the CLI to manage the machine. Important point: Please be aware that all Linux commands are lower-case (the switches may not be though) and Linux is case sensitive.

Using PuTTY

Obviously there is no RDP on the Linux server, so how does an administrator connect to a Linux server in the first instance? It is done by using a secure shell application (SSH). A user can login to the CLI using an SSH client. A very popular and free client I recommend is “PuTTY.”

putty configuratin linux

Download and open the PuTTY client, and fill in the fields for username, password, and server address for the Linux box in question. One suggestion I would make is that if you are really new to Linux, running a test machine in a virtual environment is wise – this way any mistakes don’t result in tears. I can wholeheartedly recommend Virtualbox. This is a very good virtual environment, and even better, it is free to use.

Using Secure Shell

When connecting to the secure shell, an administrator may get errors such as “Incorrect username or password” if they try to login as the root user, equivalent of the Windows local admin. This is because SSH is designed to be secure as possible. Without modification, users can only login with non-root credentials and then switch to the root user.

linux putty login using secure shell

There is an easy fix to the above error. An administrator will need to create a user at the server console or using PuTTY if they have the correct user rights. It is possible to tell immediately if logged in as root because the CLI prompt will have # rather than a ~. The current user can also be gleaned by using the command whoami, which does what it says on the tin: gives the name of the current user.

Create and Add Users

Add the user by typing in useradd followed by the desired login name to create. An example would be useradd sburns. This will follow with a few questions to answer and finally create the user. You should now be able to login with PuTTY.  Once logged in as the nonprivileged user, the administrator can elevate their privileges to root.

Using su – will allow a user to switch between users, even root, as long as the user knows the relevant password. The command itself is shorthand for “switch user.” As root an administrator can change to any other user by using the command su simon (or su bill or whomever), assuming the password is known. The “” switch is used to give all the environmental variables. Using su – without specifying a user will assume you want to switch to the root user. There is a file called /etc/sudoers that holds the configuration for su.

So now we are logged in, lets cover some rudimentary file system-related items. When logged in as a normal user, they would initially be placed in their home directory that was created when the user was created, as was shown before. Move about the system using the command cd, the same as Windows, but remember that Linux is case sensitive.

Using the Linux CLI

With Linux, the backslash becomes a forward slash. To return to your own home directory at any point, just type cd without any arguments. If you are also not sure where you are in the file structure, there is a command called pwd. This command will give the full path to your current location. This is a very useful command, especially if you have many windows open – and double check before using potentially dangerous commands!

Managing Drives with Linux

Linux has no concept of drive letter mappings. Instead drive letters map to what are known as mount points. A very rudimentary example is with CD ROM drives. In Windows, when a CD is inserted, it is mounted as a drive letter. For example, E: This differs in Linux because when you mount a CD, it essentially links the contents of a CD to a folder. Something to bear in mind is that as a rule Linux machines do not auto mount media.

An administrator would have to mount the CD and link it to a folder. Most modern Linux distributions come with a media folder for this purpose. To mount a CD, use the command mount /dev/cdrom /media. Similarly, to dismount a disk, use the command umount /media. This mounting method is not only for CDs but also for USB sticks, hard disks, and most other media, albeit with some occasional options to specify file systems and such.

 

Managing drives with Linux mount media

To see what is mounted currently, type the command mount. Standard mounts are stored in the file /etc/fstsab. You can modify this file to add additional mount points if you wanted to add additional storage systems at boot. Pro tips: First, make sure you have a backup (use the command cp /etc/fstab fstab.bak). Second, use the mount -a command to verify the fstab file is still valid before you reboot it and find that it isn’t!

Now it might be a good time to introduce you to how most Linux installations are organized from a file and directory perspective.

  • / – root, as in the top level of the disk
  • /home – where users home directories and personal data are located
  • /boot – contains important boot files. You will rarely need to go in here
  • /dev – contains pseudo devices that link directly to the hardware
  • /root – the roots home directory, and where a root can store its files
  • /etc – contains all the configuration files for pretty much everything: networking, services, and some applications
  • /mount – This folder is used to mount NFS mounts and removable media
  • /var – Contains many system components, logs, and miscellaneous
  • /proc – Holds information about running processes.
  • /bin – Contains program files
  • /sbin – Contains system administration binary files

Useful Linux CLI Commands

When working with files, there are some useful commands you can run to help you manage them, as Linux doesn’t tend to do file extensions. If you want to know what type of file you are looking at, you can use the command file file, and it will interrogate the file and provide all the information it can gather.

To view human readable files, you can use the cat command. To edit a file, use the nano editor (for example, nano filename).

If you need to find a file, you can use the locate command. For example, to locate redhat-release (This file holds the release information for the RedHat Build) use the command locate redhat-release.

Other useful commands we can use right now are df, which gives disk space statistics. Using df -h may prove a better option as it gives sizes in human readable form of megabytes, gigabytes, and such, rather than an unwieldy size in bytes.

Managing drives with Linux disk free

If you want to change your password now, you can use the command passwd. Used without any switches, it will allow you to change the password of the user you are logged in as. If you are logged in as root, you can change other people’s passwords by using the passwd command, followed by the username. An example would be passwd stuart.

It is also possible to edit the user setup by use of the command usermod. This will allow you to manage and modify settings on a per-user basis; for example, changing the username or home directory.

Hopefully you now understand the basics of logging in and exploring mounted media, and how to change between users and manage users. In the next installment of this series, we will look at managing services, software installation, and how to keep your system up to date.