Switching to Linux. Disks, files and file systems

This is the second article in our series on migrating to Linux. If you missed the first one, you can find it here. As mentioned earlier, there are several reasons why you might want to switch to Linux. Perhaps you are using or developing Linux code in your work, or you might just try something new.

Either way, having Linux on your main desktop will help you quickly become familiar with the techniques and tools you’ll need. In this article, we will introduce Linux: files, filesystems, and disks.

Where is my C: ?

If you’re on a Mac, Linux should feel familiar enough to you, as the Mac uses files, file systems, and disks pretty close to the way Linux does. On the other hand, if your experience is primarily Windows, Linux disk access can seem a little confusing. Typically, Windows assigns a drive letter (for example, C: ) to each system drive. Linux doesn’t do this. Instead, Linux is a single file and directory hierarchy for everything on your system.

Let’s take a look at an example. Suppose you are using a computer with a primary hard drive, a CD-ROM with Books & Videos folders, and a USB flash drive with an AndreyEx catalog. On Windows, you will see the following:

C:  [Hard drive]

├ System

├ System32

├ Program Files

├ Program Files (x86)

└ <дополнительные папки>


├ Книги

└ Видео

E: [флэш-накопитель]

└ AndreyEx

Instead, a typical Linux system:

/ (самый верхний каталог, называемый корневым каталогом) [Hard drive]

├ bin

├ etc

├ lib

├ sbin

├ usr

├ <дополнительные каталоги>

└ media

   └ <ваш логин>

       ├ cdrom  [CD-ROM]

       │  ├ Книги

       │  └ Видео

       └ Kingme_USB [флэш-накопитель]

           └ AndreyEx

If you are using a graphical environment, typically the Linux file manager will present a CD and USB drive with icons that look like a device, so you may not need to know the specific media directory.

File system

Linux emphasizes what are called file systems. A file system is a collection of structures on media (such as a hard drive) that keep track of all files and directories on the media. Without a file system, we could store information on a hard drive, but all of the data would be a mess. We would not know which data blocks belong to the file. You may have heard names like Ext4, XFS, and Btrfs. These are the types of Linux filesystem.

All types of media containing files and directories have a file system. Different types of media can use specific types of file system that are optimized for the media. Therefore, the CD-ROM uses the ISO9660 or UDF file system types. USB drives usually use FAT32, so they can be easily exchanged with other computer systems.

Windows also uses file systems. He just doesn’t say as much about them. For example, when you insert a CD-ROM, Windows will read the structures of the ISO9660 file system, assign it a drive letter, and display files and directories under the letter (for example, D: ). So if you’re into the details, technically Windows assigns a drive letter to the file system, not the entire drive.

Using the same example, Linux will also read the ISO9660 filesystem structures, but instead of a drive letter, it will mount the filesystem to a directory (a process called installation). Linux will then display the files and directories on the CD in the supplied directory (ex: / media / / cdrom).

So to answer the question “Where is my C: ?”? Linux does not have C: . It works differently.


Windows stores files and directories (also called folders) on its file system. However, Linux allows other things to be inserted into the filesystem. These additional types of things are native objects in the filesystem and are actually different from regular files. Linux allows you to create and use hard links, symbolic links, named pipes, device nodes, and sockets in addition to regular files and directories. We won’t go into all types of filesystem objects here, but there are some useful information to help you do this.

Hard links are used to create one or more aliases for a file. Each alias is a different name for the same content on disk. If you edit a file under one file name, the changes are displayed under different file names as well. For example, you could have AndreyEx_Resume_2018.doc to have a hard link to Resume.doc. (Note that you can create a hard link using the ln command from the command line.) This way you can find and edit AndreyEx_Resume_2018.doc and then send AndreyEx_Resume_2018.doc to your potential clients to help them keep track of what’s going on there – which will contain all your updates.

Symbolic links are a bit like Windows shortcuts. The file system entry contains the path to another file or directory. In many ways, they work like hard links as they can create an alias for another file. However, symbolic links can contain directories of aliases as well as files, and symbolic links can link to items in a different file system on different media, where hard links cannot. (Note that you can also create symbolic links with the ln command, but with the -s option.)

Access rights

Another big difference between Windows and Linux has to do with permissions on filesystem objects (files, directories, and others). Windows implements a rather complex set of file and directory permissions. For example, users and groups can have permissions to read, write, execute, modify, and so on. Users and groups can be granted permission to access everything in the exception directory, or not allowed to allow anything in the exception directory.

However, most people using Windows do not use special permissions; so it is surprising when they find that the default permission set is used and applied in Linux. Linux can enforce more complex permissions using SELinux or AppArmor. However, most Linux installations use the built-in default permissions.

In default permissions, each item in the file system has a set of permissions for the owner of the file, the group for the file, and everyone else. These permissions allow you to: read, write, and execute. Permissions have a hierarchy. First, it checks if the user (username) is the owner and has permission. If not, then it checks if your user (username) is in the group for the file and the group has permission. If not, then it checks if everyone else has permission. There are other permission settings, but three sets of three are most commonly used.

If you are using the command line and you type ls -l, you can see the permissions presented as:

rwxrw-r-- 1 andreyex destroyer 27 Aug 33rd 19:35 rolldice.sh

The letters at the beginning, rwxrw-r–, indicate permissions. In this case, the owner (andreyex) can read, write and execute the file (first three letters, rwx); members of the destroyer group can read and write the file, but not execute (second three letters, rw-); and everyone else can only read the file (last three letters, r–).

(Note that on Windows, to make the script executable, you make the file extension something specific, such as .bat. On Linux, the file extension does not mean anything to the operating system. Instead, its permissions must be set so that the file is executable.)

If you are getting permission denied, you are most likely trying to run a program or command that requires administrator rights, or you are trying to access a file that does not have permissions for your user account in order to access it. If you are trying to do something that requires administrator rights, you will need to switch to the root user account by logging in as root, or using the sudo helper on the command line, which will allow you to temporarily run as root. The sudo tool will, of course, ask for a password to make sure you do have permission.

File systems on hard drives

Windows primarily uses the NTFS file system type for hard drives. On Linux, you can choose which type of filesystem you want to use for your hard drive. Different types of file systems have different characteristics and different characteristics. The main Linux file system in use today is Ext4. However, you can choose from a variety of file system types during installation, for example: Ext3 (predecessor to Ext4), XFS, Btrfs, UBIFS (for embedded systems), etc. If you don’t know which one to use, Ext4 will work fine.