LinuxSQLServer

Linux for the SQL Server DBA- Part I

For the Oracle DBA, Linux is life.  When I was at Oracle, Linux projects were the easy part of my job, unlike the ones on Windows, AIX, HP-UX and at times, even Solaris.  You knew the Linux ones received the most love from development, had the most time towards patching and received attention if there was a bug.

History

Linux was introduced in 1991, thanks to Linus Tovalds and has been in active development, with introduction of different “flavors” of the OS over the years.  As many folks know, Linux was carved out of the GNU open license project, which its original OS, Hurd, just hadn’t become successful over the years since it’s development since 1983 and was a main reason that Linus ended up developing Linux.

Linux development is done on the GNU or Intel C Compiler.  The original goal of the OS was to limit any commercial activity, which seems a bit foreign today as its become so standard for most IT shops- so much so, that Microsoft now is inspired to take it on with SQL Server 2016/2017.  Where Linux has become very commercial in recent years, it’s sibling is OS popularity on the GNU project, Debian, has stayed less in the limelight and is used in many open source projects like one of my favorite, the STEM powerhouse and inexpensive computer, Raspberry Pi, (Raspbian). You’re going to hear other flavors, like SUSE, RedHat, Ubuntu and others, but there are minor differences in each, (even if those religiously loyal to one or an other swears on the details otherwise) at this point, knowing that they exist will help you get past this and move onto the important stuff.

Accessing a Linux System

You use a terminal to log into a Linux system.  Putty is free and a favorite of most DBAs.  If you’re on Mac, then you can just use the Terminal and log straight in.  We’ll get into Graphical UIs later on, but understanding the command line is essential for Linux.

Linux has some basic information that surrounds OS users, logging in and permissions.  You SSH (secure shell) into a Linux host, just as you’ve done from Microsoft Windows.

Also, just as in Windows, you must be able to “reach” the host or ping the host, just as you would with a Windows box:

From putty or your terminal, test this with the DNS for the hostname or directly to the IP Address:

ping <IP address or hostname>

You log in with the following command:

ssh OSUsername@<hostname or IP address>

If it’s the first time you’ve logged into the host, it will ask you to add the routing address to your list and then you can confirm and you will log in.

The Linux File System

In Linux, everything is configured as a file.  Not just text files, but executables, directories and even device drivers.  Due to this, the way you, as a user view everything is a bit different than the kernel views the system.   Similar to Windows OS, there will be a clear hierarchal layout of all the files that culminate up to root, which is identified by a forward slash, “/”, unlike in Windows, identified by a back slash, (and yes, this will be a common typo you’ll be correcting as you go along… :))

For the kernel, it doesn’t see the hierarchy and in its world, everything is very flat and identified by something called inodes. Each of these inodes have a number of unique identifiers that represent each file, each directory, each permission and so on and so forth.  It allows the kernel to identify, search, locate and perform any process very quickly.

OS Users and Groups

Along with Root, there are users created.  These are the logins and owners of files on the OS and each of these users are assigned to one or more groups that allow them a set of permissions to different file structures.  For the Oracle DBA, it is common to login as their username, (example dsmith) and then switch user, (command su) over to Oracle, (database and oracle installation owner) to perform critical tasks.

Belonging to a group allows you to perform the same tasks and have grants to files in directories.  Each user has, (or should have) a home directory that contains their configuration files and aliases for the user.  You may have someone ask you what is in your profile or bash profile.  These files start with a “.” and aren’t available with a simple list command, which we’ll discuss next.

Beginning Commands

We’ll start with a few simple commands on the system now that you’re logged in

ls = list and is like dir, the directory command on Windows.

The list command is something you’ll use often, even more so when you first start.  I don’t know how often I attempt to use “ls” on Windows and curse, then promptly type in “dir”.

ls -a will give you all the files, including hidden files.

ls -ltr will give you the files ordered from most recent and comes in quite handy for large directories.

pwd = current directory location.  You’ll need to know where you are, as you go down the rabbit hole, there’s rarely Alice to show you… 🙂

cd <> = change directory with additional arguments to fulfill the request.

cd without an argument will take you back to your home directory.

cd .. will take you to the directory one up from where you currently are.

cd <new directory path> will take you to that new directory

Users and Files

For each file and directory, there should be an owner and a group assigned to it.  We do this by using the change modify, (chmod) command and the change owner, (chown) commands which we’ll dig into in subsequent posts.  It’s important now for you to just simply understand the different categories:

  • User/Owner=u
  • Group=g
  • Other=o
  • All Users=a

For permissions, there are three just like in Windows that can be assigned singularly or in combinations:

  • Read
  • Write
  • Execute

Where this can be confusing for some, is that we visibly identify the grants by their values, either as separate values or as totals.

  • Read,(r)= 4
  • Write,(w)= 2
  • Execute, (x)=1

To give you an example, if you were to see the following file:

test.sh is a shell file that has permissions 777.  This means that EVERYONE has permissions to read, write and execute test.sh.  Why?

  • owner has 4+2+1=7
  • group has 4+2+1=7
  • other has 4+2+1=7

You may see files that have values of “764”, which would be mean the owner can do anything, the group can read and write to the file and other can just read it.  Understanding these privileges is essential to a DBA so you can manage the privileges to system and data files, securing your database.

We’ll dig into how to assign and update privileges to files in a later post, but I want you to start to recognize this information as we proceed forward understanding Linux.  Hopefully this was a great beginning and will give you a good foundation as we proceed forward into commands and navigating the Linux server.

 

 

 

Kellyn

http://about.me/dbakevlar

One thought on “Linux for the SQL Server DBA- Part I

Comments are closed.