From the course: Learning Linux Command Line
The Linux file system - Linux Tutorial
From the course: Learning Linux Command Line
The Linux file system
- If you've been working with computers for any amount of time, you're probably familiar with the idea of files. Files are collections of information that represent photos, documents, source code, databases, and all kinds of other things. These are the basic concept of data organization we work with in a graphical environment. And that's true in the command line environment as well. There are two commands that I want to point out but not dig too deeply into. These are called file and stat. Both of these commands can take a look at a file and tell us some things about it. The file command will generally be able to tell what kind of file we're asking it about. If a file's name isn't clear or if it doesn't have an extension sometimes it can be tricky to figure out exactly what it is. Using file will give us some insight into whether something is an archive, or a directory, or an executable file, or a safe, a text file, or other kinds of document. I'll write file and then provide the name of my documents directory, and file tells me that that's a directory. While in a desktop environment we might be able to click on a file and view its properties, that feature isn't available to us in a command line environment. The stat command on the other hand tells us some extended information about a file. I'll write stat and provide the directory named documents. As we'll see when we look at the LS command in more depth, some of this information is available using that command as well. But instead provides some useful information. These commands can be helpful to know about if we come across an unknown file. On a Linux system everything is a file, so these tools can come in handy. We organize files into directories which are sometimes called folders, like we would keep a bunch of related papers, or photographs together in a folder or envelope. In the graphical environment we can navigate around these files and directories with the mouse, seeing how they're organized and seeing their hierarchy. We can do the same thing in a command line environment, but in order to do that we need to know where we're working and what's available. So before we start navigating around we need to step back and learn a little bit about the file system and the Filesystem Hierarchy Standard. Working at the command line, we'll often need to refer to files or directories that represent the input, the output, or the configuration for commands we use. And we need to know where commands are located on the system too. On a Linux system, files and directories are part of the file system, which defines the way the data is represented on the system's storage media. Most Linux distributions follow the Filesystem Hierarchy Standard, a standard which defines where certain kinds of files are stored on the file system. Having files like configurations, programs, or binaries and so on in predictable locations is important to the operability of software across Linux distributions. Back here in my file browser we can see what the file system looks like, before we dive into some specific directories. There are a handful of directories here, which can look pretty cryptic and intimidating if we don't know what they represent. So let's explore the purpose of a few of these. The file system starts with the root represented by a slash. The file system root is the highest level of the organizational hierarchy of the file system. Each Linux system only has one file system and everything else directories, external hard drives, network shares, and so on are represented within it. If you're familiar with windows, you can think of the file system root kind of like the my computer level of browsing in the File Explorer. At the next level down the hierarchy are a handful of specific folders, defined by the Filesystem Hierarchy Standard. The home directory is where each user accounts personal files are stored. And our home directory is where most of our work in this course we'll focus. Within the home directory each user has a separate directory named with their username, and each user will be able to use the tilde character to represent their own personal home directory. We'll see more about that later. On desktop Linux distributions, each user's home directory also often contains other directories like documents, downloads, pictures, and so on. The directory named a root is where roots home folder is stored. We'll learn more about the root user later on, but for now it's important to recognize that this directory, and the file system root are both called root. And that can seem a little confusing, though nobody except the root user uses the root home folder. So generally if you hear the term root in relation to a file system path, it refers to the file system root not to the special home folder. Some of the other folders we may need to explore are etc, which is where most programs keep their configuration files. Bin and sbin where programs the system relies on to work are kept, and lib where shared libraries and modules are stored. We may also need to work in the MNT folder, which is where local or network file systems are mounted into the overall file system, or the media folder where removable file systems like USB drives and optical drives are mounted by some distributions that support automatic mounting. There are a few other folders, and some of these higher level folders have sub folders to further organize items. There's a few special folders too, which are related to the system and the kernel. The dev folder is where the system keeps references to all of the hardware it has hard drives, memory, CPU's, and everything else. We won't get into that much here, but if you're interested in learning more about how a Linux system works under the hood, it's a good place to explore. There's a folder called proc, which contains references to processes that are running on the system. And this directory contains details on other aspects of the system as well. And there's a folder called sys, which holds files representing different kernel parameters and system information. If you're interested in learning about kernel development, you'll spend time in this directory. That's a very brief overview of the general structure of a Linux system file system. Don't be afraid of exploring, a normal user generally have permission to make changes in these system folders, so looking around won't do any harm. And as I mentioned, as you learn more about Linux, you'll find yourself starting to use these directories, especially as you expand into learning about system administration or software development. for now though, we won't focus on them because we'll keep our focus on working with files in our own home directory.
Contents
-
-
-
-
-
The Linux file system6m 18s
-
(Locked)
Understanding file paths4m 50s
-
(Locked)
Navigating the file system6m 58s
-
(Locked)
Exploring the output of the ls command2m 33s
-
(Locked)
Create and remove directories3m 36s
-
(Locked)
Copy, move, and delete files and directories7m 53s
-
(Locked)
Find files from the command line2m 10s
-
(Locked)
Understand user roles and sudo6m 3s
-
(Locked)
Understand file permissions5m 57s
-
(Locked)
Modify file permissions7m 4s
-
(Locked)
Create hard and symbolic links3m 26s
-
(Locked)
Challenge: Fix broken syntax26s
-
(Locked)
Solution: Fix broken syntax1m 24s
-
(Locked)
Challenge: Practice working with files34s
-
(Locked)
Solution: Practice working with files32s
-
-
-
-