File Systems

Windows

It's important to know that there are a couple of command line interfaces or CLIs available on Windows. The first one is called the command prompt, cmd.exe. The second one is PowerShell or powershell.exe. ⚙️

The command prompt has been around for a very long time.

It's very similar to the command prompt that was used in MS DOS. Since PowerShell supports most of the same commands as command prompt and many, many more, we're going to use PowerShell for the exercises in this module. 🤖

I want to call out that many PowerShell commands that we'll use are actually aliases for common commands in other shells. An alias is sort of like a nickname for a command. 🐱‍💻

Listing Files and Directories 📁

The first command that we'll use is for listing files and directories. Let's start by listing the directories in the root of our C drive. The C drive is where the Windows operating system is installed. For many of you, it might be the only hard drive that you have in your computer. 💾

To get to the PowerShell's CLI, just search in your applications list PowerShell. From here, we can go ahead and launch the PowerShell program. We're going to use the ls or list directory command and give it the path of where we want to look. The path is not actually part of the command, but it is a command parameter. You can think of parameters as a value that's associated with a command. 🔍

ls C:\

Now you can see all the directories in the root of your C drive. You might just see a few or a whole bunch of directories. It all depends on what your computer is used for. The C drive root folder is what we call a parent directory and the contents inside are considered child directories. 🗂️

As you continue to work with operating systems, you'll encounter terms that may seem a bit out of place at first, but they actually make a lot of sense. Parents and children are common terms that stand for hierarchical relationships in OSs. If I have a folder named dogs and a second folder nested within that folder called Corgi, dogs would be the parent directory and Corgi would be the child directory. 👨‍👩‍👧‍👦

Let's look at a few of the common child directories in this folder:

  • Program Files (x86): These directories contain most of the applications and other programs that are installed in Windows. 🖥️

  • Users: This contains the user profile directories or home directories. Each user who logs into this Windows machine will get their own directory here. 🙎‍♂️

  • Windows: This is where the Windows operating system is installed. 🪟

Exploring Command Options 🔍

If we open up PowerShell and run Get-Help ls, we'll see the text describing the parameters of the ls command. This will give us a brief summary of the command's parameters. But if you want to see more detailed help, try Get-Help ls -Full. 📚

Now you can see a description of each of the parameters and some examples of how to use the command.

What if we wanted to see all the hidden files in this directory? Well, we can use another useful parameter for the ls command, -Force. The -Force parameter will show hidden and system files that aren't normally listed with just ls. 👀

ls C:\ -Force

Now you can see some important files and directories like Recycle Bin. This is where the Recycle Bin lives. When you move files to the Recycle Bin, they're moved to this directory instead of being deleted immediately. 🗑️

ProgramData: This directory contains lots of different things. In general, it's used to hold data for programs that are installed in Program Files. 💾

All right, now that you've seen how to take a look around the file system in Windows, let's see what this process looks like in Linux. 🐧

The Linux File System

The Root Directory

  • In Linux, the main directory that all others stem from is called the root directory.

  • The path to the root directory is denoted by a slash or forward slash (/).

  • An example of a path in Linux that starts from the root directory is /home/cindy/Desktop, just like C:\users\cindy\Desktop in Windows.

Exploring the Root Directory

  • To see what's under the root directory, we'll use the ls (list directory contents) command.

  • If we don't provide a path, it'll just default to the current directory we're in.

  • Let's run ls /.

$ ls /
bin   etc   home  proc  usr
  • There are a lot of directories here, and they're all used for different purposes.

Important Directories

  • /bin: This directory stores our essential binaries or programs. The ls command is located here.

  • /etc: This folder stores some pretty important system configuration files.

  • /home: This is the personal directory for users. It holds user documents, pictures, etc.

  • /proc: This directory contains information about currently running processes.

  • /usr: The user directory doesn't actually contain our user files like our home directory. It's meant for user-installed software.

  • /var: We store our system logs and basically any file that constantly changes in here.

Useful ls Command Flags 🚩

  • The ls command has several useful flags that we can use.

  • Flags are a way to specify additional options for a command, usually using a hyphen (-).

  • You can view available options for a command using the --help flag.

ls -l (Long List) 📋

  • This shows detailed information about files and folders in a long list format.

  • The output includes file permissions, number of links, file owner, group, file size, last modification time, and the file/directory name.

ls -a (All Files) 🗂️

  • This shows all the files in the directory, including hidden files.

  • Hidden files are those that start with a dot (.), like .hidden_file.

Getting Help with Commands 🤖

  • Another method to get information about commands is the man command for manual.

  • This displays the manual pages for the specified command.

  • For example, man ls will show the manual page for the ls command.

Now, you have a better understanding of the Linux file system and how to navigate and explore it using the ls command and its various flags. Let's continue our Linux journey! 🐧

Last updated