Skip to content

Insight and analysis of technology and business strategy

Linux file system for SQL Server DBAs

With Microsoft releasing SQL Server on Linux and a lot of SQL Server DBAs coming from a predominantly Windows background, this post is going to arm the DBA with the fundamental knowledge of the Linux file system. If you come from a Windows background and are expecting to see the traditional c:\, d:\ etc on Linux, you will be mistaken. Installing SQL on Linux is as easy as running a couple of commands: see here. The Linux operating system at its core is a set of files in a file system. Although the folder structure differs from distribution to distribution, there are a couple of core folders that every administrator should be aware of in all of the distributions. Before we dig into each of the folders, we should talk about general partitioning of the file system. A typical install will have three partitions normally spread across different disks.
  1. Root (/) - Everything is stored under root. The operating system files, the home directory, media files, literally everything. Typically, root is on separate drives to home and swap partitions for performance reasons. This is similar to the c:/ in windows.
  2. Home (/home/user) - Each user has is own home folder under the home directory and this is where all user data and application settings specific to the user are stored. This is similar to the user folder in Windows.
  3. Swap partition (/dev/"SwapFile") - This is similar to the page file in Windows and is a file that the OS can use when needing to flush files from memory to disk.
The important thing to remember in Linux is EVERYTHING is a file. Now let's move on to the individual folders that are common in all Linux Distributions and their uses [caption id="attachment_104508" align="alignnone" width="960"] The Linux File System The Linux File System[/caption]  


This is the root directory of the system and as mentioned above, all folders and files are stored under this folder. The closest comparison to this on Windows is the root of the c:/.


This is the binaries folder. This folder contains base executables which are required for the Linux operating system to work. Software and application files are stored in here and are executed at runtime. Executables in this folder can be run by anyone. Some example programs that are installed by default are the "ls" command and various commands for manipulating files such as "cp"."rm","mv" etc. The comparison to this on Windows would be the c:\Windows folder.


This is the folder where all the files are stored that are needed for the Linux kernel to boot the machine. This folder should never be modified by a user as it can cause severe issues with starting the machine. The closest comparison to this would be the Windows boot loader or master boot record.


This is the folder where all the devices are stored. Remember that everything in Linux is a file? Well, that includes devices, too. Any attached devices will show up in this folder. Some examples are hard disk drives (sda,sdb,sdc etc), webcams, printers, etc. The closest Windows comparison here is the entries in the My Computer section of Windows or, on newer versions of Windows, the Devices section under control panel.


This folder contains most, if not all, of the system-wide configuration files. Some examples of this are the fstab file for configuring your file system table on boot. I remember this folder as "everything to configure" as it contains all the configuration files. There is no comparison to this in Windows, as configurations are stored differently depending on the application installed.


/home is where you will find your users' personal directories and files. On my system, I have three folders here:
  • /home/daniel - My home folder
  • /home/bobby - My son's folder
  • /home/guest - A guest folder in case someone needs to borrow my computer
Typically, this is where all your personal documents media files, etc, are stored. The comparison on Windows is C:\Users


/lib is where libraries are. Libraries are files containing code that your applications can use. They contain pieces of code that applications use to draw Windows on your desktop, control peripherals, or send files to your hard disk. There are more lib directories scattered around the file system, but this one, the one hanging directly off of /, is special in that, among other things, it contains the all-important kernel modules. The kernel modules are drivers that make things like your video card, sound card, WiFi, printer and so on, work. There is no Windows comparison for this folder.


This is the default folder where external media is mounted. Once a device is attached and shows up in /dev you still have to mount the device. This is the folder where most modern distributions automatically mount the device. You can change where a device is mounted. The Windows comparison is My Computer.


This is where you would manually mount storage devices or partitions. It is not used very often today as most modern distributions automount devices to /media. If you have to manually mount devices, then normally you would mount them to a new directory with a meaningful name. There is no Windows comparison for this folder.


The /opt directory is often where the software you compile (that is, you build yourself from source code and do not install from your distribution repositories) sometimes lands. Applications will end up in the /opt/bin directory and libraries in the /opt/lib directory. A slight variation: another place where applications and libraries end up in is /usr/local, When software gets installed here, there will also be /usr/local/bin and /usr/local/lib directories. What determines which software goes where is how the developers have configured the files that control the compilation and installation process. There is no Windows comparison for this folder.


/proc, like /dev is a virtual directory. It contains information about your computer, such as information about your CPU, RAM and changes as your computer is running throughout the day. The closest comparison to this on Windows is Device Manager and Task Manager.


This is the home directory of the superuser root. You should not need to touch this folder as you should keep your own files in your own home directory. This folder is not under /home for that very reason. The closest folder to this in Windows is the User/Administrator folder.


/run is is a folder system processes use it to store temporary data for their own reasons. This is another one of those DO NOT TOUCH folders. There is no Windows comparison for this folder.


/sbin is similar to /bin, but it contains applications that only the superuser will need. You can use these applications with the sudo command that temporarily gives you superuser powers on many distributions. /sbin typically contains tools that can install stuff, delete stuff and format stuff. As you can imagine, some of these commands are lethal if you use them improperly, so handle with care. There is no Windows comparison for this folder.


The /usr directory was where users' home directories were originally kept back in the early days of UNIX. However, now /home is where users keep their stuff, as we saw above. These days, /usr contains a combination of directories which in turn contain applications, libraries, documentation, wallpapers, icons and a long list of other stuff that need to be shared by applications and services. You will also find bin, sbin and lib directories in /usr. What is the difference with their root-hanging cousins in here, you ask? Not much, nowadays. Originally, the /bin directory (hanging off of root) would contain very basic commands, like ls, mv and rm; the kind of commands that would come pre-installed in all UNIX/Linux installations, the bare minimum to run and maintain a system. /usr/bin, on the other hand, would contain stuff the users would install and run to use the system as a workstation - things like word processors, web browsers and other apps. But many modern Linux distributions just put everything into /usr/bin and have /bin point to /usr/bin just in case erasing it completely would break something. So, while Debian, Ubuntu and Mint still keep /bin and /usr/bin (and /sbin and /usr/sbin) separate, others like Arch and its derivatives just have one "real" directory for binaries, /usr/bin, and the rest of the bins are "fake" directories that point to /usr/bin. The closest Windows comparison to this would be C:\Program Files.


This folder contains files for use by servers. Things like web server files if you're hosting a web server /srv/www or ftp files if you were hosting an ftp server /srv/ftp, There is no Windows comparison for this folder.


/sys is another virtual directory like /proc and /dev and also contains information from devices connected to your computer. You can manipulate these files as superuser, but be very cautious about what you're doing. For example, you can change the screen brightness of your screen by modifying a particular file here. You can also really hurt your system by incorrectly configuring other files, which is why you require superuser privileges to do anything in this folder. Do not touch this folder unless you are certain of the action you are completing/configuring.


The /tmp folder is for storing temporary files. Applications tend to use this folder to store temporary data they may need later in a process they are running. Users can also store tempory files here, as this folder is one of the only folders where you don't need to be a superuser to use directly from the root.


/var was originally given its name because its contents were deemed variable, in that it changed frequently. Today the name is a bit of a lie because there are many other directories that also contain data that changes frequently, especially the virtual directories we saw above. /var typically contains things like logs in the /var/log sub-directories. Logs are files that register events that happen on the system. If something fails in the kernel, it will be logged in a file in /var/log; if someone tries to break into your computer from outside, your firewall will also log the attempt here. It also contains spools for tasks. These "tasks" could be jobs you send to a shared printer when you have to wait because another user is printing a long document or could be mail that is waiting to be delivered to users on the system. There may be other folders hanging directly off / (root), depending on the distribution. If you have any questions regarding those, feel free to comment below or contact me. In relation to SQL Server, below are some of the folders and files of interest. /opt/mssql/bin/mssql-conf setup - This is the location of the config file/script for changing SQL Server settings. /opt/mssql-tools/bin/ - This is the location of the SQL Server tools that you can use. To find out how to customise and configure SQL Server on Linux, please click here.

Top Categories

  • There are no suggestions because the search field is empty.

Tell us how we can help!