Linux 101: What is the mount command and how do you use it?



Jack Wallen introduces new Linux users to the mount command and how to use it to mount an external drive on the internal file system.

Image: Jack Wallen

Linux is capable of doing all kinds of amazing things, some of which no other operating system on the planet can do.

It is also able to handle very basic tasks. One of these tasks is to mount file systems (such as external drives) to the file system. This is a crucial feature, otherwise you might not be able to expand your storage or connect external data drives.

SEE: 5 Linux Server Distributions You Should Be Using (TechRepublic Premium)

If you’re working with a distribution of Linux that includes a desktop GUI, adding external drives is pretty straightforward. But what if you are using a server without a GUI? For this you will need to use the mount command. Mount does exactly what you think it does, it mounts an external drive on your internal file system.

But it is not that simple. First, you must have a directory on the internal file system to serve as a mount point. You can’t just mount, say, / dev / sdb on the root filesystem.

You can however create a new directory, say data with the command sudo mkdir / data. You will then want to make sure that any user or group that would need to use the directory has access using the chown command (as in sudo chown -R: writers / data) then give the group write access with the chmod command (as in sudo chmod -R g + w / data).

SEE: Linux 101: How to run commands from the nano text editor (TechRepublic)

Once you’ve done that, you have a mount point that can house the external drive. Then you need to know where the drive is, which can be done with the command lsblk. Find the name of the drive associated with the disc and mount it with the command sudo mount NAME / data (Where NAME is the name associated with the drive, such as / dev / sdb).

At this point, whatever is in your external drive will appear in / data.

And that, my friends, is the basis for using the mount command. To learn more about this useful tool, be sure to read the man page with man mount.

Subscribe to TechRepublic How to make technology work on YouTube for all the latest technical advice for professionals at Jack Wallen’s business.

Also look


Leave A Reply

Your email address will not be published.