Skip to main content

Exploring the Linux Filesystem

Hands-On Lab

 

Photo of Ross Brunson

Ross Brunson

Linux Training Architect II

Length

00:30:00

Difficulty

Beginner

A familiarity with the structure of the SUSE Linux filesystem and how to navigate it is critical for any system administrator or user. One of the challenges that those using text-only or command-line systems often complain of is the apparent lack of ways to visualize files, directories, and their structure from the console.

In this lab look at ways to experience the files and directories on a filesystem in relation to each other, and from different perspectives.

What are Hands-On Labs?

Hands-On Labs are scenario-based learning environments where learners can practice without consequences. Don't compromise a system or waste money on expensive downloads. Practice real-world skills without the real-world risk, no assembly required.

Exploring the Linux Filesystem

Introduction

A familiarity with the structure of the SUSE Linux filesystem and how to navigate it is critical for any system administrator or user. One of the challenges that those using text-only or command-line systems often complain of is the apparent lack of ways to visualize files, directories, and their structure from the console.

In this lab look at ways to experience the files and directories on a filesystem in relation to each other, and from different perspectives.

The Scenario

We have inherited an existing SUSE Linux Enterprise Server from the former systems administrator of the company. We want to know more about the filesystem and to get an idea of what SUSE systems have in what locations. We'll be using filesystem tools to look at the structure from both the command line and from the GUI desktop perspectives.

Logging In

Use the credentials provided on the hands-on lab overview page, and log in as cloud_user.

Use Command-Line Tools to Visualize Filesystem Structure

Use the tree command to visualize the structure of the SUSE Linux filesystem, limiting the depth of queries and using alternative display and searching methods. From our home directory, we can run tree with no options. We'll see all of the directories in ~/, in a tree format. Now, if we run the command against the root of the filesystem, we'll get way more output than we can handle. But try it and see, just to say you did:

tree /

Remember that you can hit Ctrl +C to stop it. If we want to see that in bite-sized chunks, we can run the same command, but pipe it into less:

tree / | less

There's still a lot of information there, but we can at least paginate through the results. But even better than that is redirecting all of the tree output to a file:

tree / > root_file-listing.txt

But do we necessarily need all that? What if we just want to see the directories, and not all of the files in them all? Well, there's an option for that:

tree -d /

That's still a lot of information. What if we just want the / and its immediate subdirectories (only one level down)? Let's run this tree command:

tree -L 1

If we change that 1 to a 2, we'll get two levels down from /. We'll notice that we're getting files in our output. What if we only want to see directories? Well, run this:

tree -L 2 -d

Let's sweeten the deal. Now we're going to show just subdirectories, but we're also going to show permissions. And this time we'll just run it on a directory that's smaller than /:

tree -d -p /usr/share/doc/release-notes

This will list out /usr/share/doc/release-notes, then all of the subdirectories and their permissions, in a tree view.

There's one last option we ought to see in action, -f. This will show the path of each of the directories/files in the tree output:

tree -d -p -f /usr/share/doc/release-notes

Note: We can redirect the output from any of these commands to a text file, for later study.

Use the Graphical File Manager to Create and Copy Files and Directories on a SUSE Linux Enterprise System's Desktop

We've gotten familiar with looking at files and directories in the command line. Now let's play with the GUI, shall we? We'll use the graphical file manager to perform some basic file and directory traversal tasks, including creating directories, copying files, and navigating to other parts of the system via the file manager application.

Logging into the GUI

To get into the GUI, we've got to do a bit of VNC finagling.

  1. Open a shell prompt on the Mac or Windows
  2. Copy the remote lab/playground server IP address
  3. Execute the following on your system in the shell
    ssh -L 5901:localhost:5901 cloud_user@<IP_ADDRESS>
  4. The SSH client will prompt us to say yes/no to the RSA fingerprint, so type yes
  5. Then the client will prompt us for the password, and we'll use the cloud_user password from the hands-on lab overview page.
  6. Start a VNC client, and for the server address use localhost:5901. We should not be prompted for a password here.
  7. The SLE Server will then load the GUI, and we can log into the desktop (with that same password) from there.

Once we're in, click on Activities in the upper left of the screen. Now click on the Files icon (the blue file cabinet), and click Documents on the left.

Create a Directory

Click on the icon (in the upper right of this window) that looks like three horizontal lines. Now click the icon with a folder next to a + sign. We're creating a new directory now, and will get prompted to name it. Enter something like my_dir and click Create.

Copy Files

Now let's create a new tab in the window. Just like in a web browser, Ctrl + T will do it. With the right-hand Documents tab highlighted, go click on + Other Locations. Once there, click on Computer, which will take us to the root of the filesystem.

Use the Menu

We're going to copy the config.bootoptions file in there to our new directory. Right click on it, and select Copy to.... Navigate to Documents and my_dir, then click the Select button up in the top right of the window. If we go look in that directory, we should see the file is in there now.

Drag a File

In that same right-hand tab, navigate again to + Other Locations, Computer, then usr -> share -> bash -> helpfiles.

Click on one, any one, and then drag it up to the left-hand tab (which should still be Documents) but don't let go of the mouse, just hover. If we wait there a second, the tab will turn green, and then we'll be looking in that directory. Now we can drag the file back down a bit to put it in our my_dir directory. But wait! If we just hover over that directory, the screen will change a bit and we'll now be looking in there.

We can go as deep as we want by hovering over whatever subdirectories are in front of us. And if we go too deep, just hover back up at the top of the window to one of the higher-level directories. We can go down a different path. As long as we don't let go of the mouse button, we can keep looking for where we want to drop the file.

Conclusion

Well, we made it. We've gone through and used the command line to try and get a handle on how the filesystem is laid out, then we used the GUI to create a directory and copy some files around. Congratulations!