How To: Find Your Man Pages’ Location On Disk

Today’s article is going to teach you how to find your man pages’ location on disk. It may not be a very useful skill, but it’s one that will come in handy in a future article. (That’s called ‘foreshadowing’!) Well, it seems likely that it’ll come in handy with a future article.

By the way, if you’re curious about why the first lines in these articles are often ‘forced’, it’s because of search engine optimization. You can blame the search engines, but it works.

Many of you will be familiar with the which command. You can use that to locate a binary for an application. For example, you can go with:

Which will output something along the lines of:

And that’s great. If that’s what you need to know, that’s what you need to know. However, what if you want to also know where your man page file is located? 

It should come as no surprise that Linux will happily spit that information out, so long as you know the correct incantations. And, for that, you have Linux Tips – where I’m gonna tell you how to find your man pages’ location.

Man Pages Location:

This article requires an open terminal, like many other articles on this site. If you don’t know how to open the terminal, you can do so with your keyboard – just press CTRL + ALT + T and your default terminal should open.

The tool we’re going to be using is similar to which, and even spits out the same information. The tool in question whereis and the man page describes it as:

whereis – locate the binary, source, and manual page files for a command

As you can see, it’s a pretty simple command. It will also only show you the source if you actually have the source. In most cases, you have compiled binaries and that’s what your system uses. It’ll happily locate the binary just like the which command does.

So, let’s test it… Hmm… Let’s test it with the ‘ls’ command:

whereis command in action
See? It does exactly what i told you it would do! That’s why I make the big bucks!

So, if you want to know where your man pages are located for a specific applications, this is an easy way to do that. Obviously, it’s the 2nd bit of information. Though, I suppose if you only want the output to contain the path to the man pages, you could use a command like this:

That will just spit out the path to the man page, if that’s all you want to see. Try it with a few different commands and you’ll lock it into your memory – ’cause you never know when it’s going to come in handy.

Closure:

And there you have it… You have another article! This is just one of many articles, so feel free to browse around. You might even learn something new! I’ve officially written so many of these things that I can’t actually remember them all. I legit need to search first and make sure I haven’t already written the article. (I probably should have devised a system to avoid this, but the search function appears to be pretty good and effective.)

Thanks for reading! If you want to help, or if the site has helped you, you can donate, register to help, write an article, or buy inexpensive hosting to start your own site. If you scroll down, you can sign up for the newsletter, vote for the article, and comment.

How To: Make A Directory In Linux

Today’s article will teach you how to make a directory in Linux. Making a directory in Linux is pretty basic, straightforward, and easy. There are some options when making directories which we’ll be covering, but we’ll just be using ‘mkdir‘ for this exercise.

You’ll find the man page describes mkdir eloquently enough:

mkdir – make directories

And that’s exactly what it does. It’s a tool for making directories. Again, it’s pretty straightforward.

If you want a decently useful directory structure, you’re going to want more than the default directories. You’re going to want to make a consistent and meaningful directory structure, which will save you quite a bit of time and effort. Life is easier when you have a useful directory structure that makes sense to you – making things easier to find.

In case one doesn’t know, you can use ‘folder’ as a synonym for ‘directory’. It’s a hierarchical marker to which files can be designated – meaning you can stick stuff in your folder if you want to. They’re one of the best ways to organize your files in a meaningful fashion.

Like files, there are permissions for folders. Often, those permissions are inherited by the files within, though that’s not strictly necessary. We’ll lightly cover that as well.

For such a simple subject, there’s a bit of meat to it. We’ll cover that too in this article about how to make a directory in Linux. It’s mostly a beginner oriented article, but there may be some options that are unfamiliar more advanced users.

On to the article!

Make A Directory In Linux:

This article requires an open terminal, just like many other articles on this site. You can do so with your keyboard – just press CTRL + ALT + T and your default terminal should open.

Once you have your terminal open, you can change directories or make these practice directories in your home folder (which would lead to clutter). So, if you want you can run mkdir tmp && cd tmp to get a fairly clean workspace going. (See? We’re using mkdir already!)

Anyhow, a nice basic use is to make a directory. To make a directory called ‘foo’ then you’d simply use:

If you want to make parent and child directories, you can also do that with just one command:

You can even make multiple directories in the same directory. That’s just a simple use of brackets and looks like this:

If you want to set permissions at the same time, that’s also an option:

You can also add the -v flag (meaning ‘verbose’) to any of these commands. That will output the results of your command so that you can verify that the command actually created the appropriate directories. After all, you never know when you’ll fat-finger something.

Closure:

There you have it! It’s another article, this one teaching you how to use the mkdir command to make a directory in Linux. This article is not terribly difficult, but there are a few advanced options that can make your file management even better. It’s a handy set of flags to know if you’re keen on keeping your system free of clutter.

Thanks for reading! If you want to help, or if the site has helped you, you can donate, register to help, write an article, or buy inexpensive hosting to start your own site. If you scroll down, you can sign up for the newsletter, vote for the article, and comment.

Let’s Learn About Absolute And Relative Paths

In your Linux journey, you’ll use both absolute and relative paths. It’s important to know the difference and, perhaps, when you want to use absolute paths or when you want to use relative paths. It’s a pretty easy lesson and not a terribly long article.

First, paths are directory names and links to files. They’re always unique names to files and folders. They’re useful for referencing things, knowing where things are, organization, and the likes. To manage a file, you should probably know where it is.

An example of an absolute path would be something like:
/home/<user>/.bash_profile

An example of a relative path would be something like:
~/.bash_aliases

An absolute path will always begin with a /, for example. As they’re the easiest, let’s cover them first:

Absolute Paths:

Let’s say you have a file in your Documents directory and it is named foo.txt. If you wanted to read that file, you could navigate to the Documents directory and use cat foo.txt to read the file. 

That’s only going to work when you’re already in the Documents directory. If you’re not in the proper directory, you’ll have to use the absolute path. That would look like cat /home/<user>/Documents/foo.txt and that would work. 

As I said already, absolute paths have to start with a /. They’ll also start with one of the root directories, such as /etc, /bin, or /media. You can see those directories in your file manager by going up a level until you can go no further, when you’re at the absolute / directory.

An absolute path works even if you’re working in a different folder in the terminal. When you’re in /home/<user>Pictures, cat /home/<user>/Documents/foo.txt will still work just fine. 

Again, they’re a unique identifier for a directory or a file. If you wanted to change the directory in the terminal, you could use cd /home/<user>/Pictures. That would work just fine.

Relative Paths:

Relative paths are paths based on where you are already. They’re based on your “PWD” or Present Working Directory. There’s a few ways that these can be used. Conversely, a relative path never begins with a /.

For example, if you’re already in /home/<user> then you can cd Documents to get to your Documents directory. As you can see, that’s much easier to type.

Of course, there’s the tilde – which already means /home/<user>. So while possibly not the same thing you’re thinking of when you think of relative paths, you can also get to the Documents directory with cd ~/Documents.

If you’ve used the ‘ls‘ command before, you may have noticed a . and a .. in there. Well, the . stands for your current directory (and some commands will want that) and the .. stands for the next highest directory.

Assuming you were in the Documents folder, you could do cat foo.txt you could also do cat ./foo.txt and get the same results.

While in the Documents directory, you could cd . and that’d take you exactly nowhere. More useful, you can cd .. and you’d be back in /home/<user>. If you did cd ../.. you’d end up in the /home directory.

You can also (though I have no idea why you’d want to) use the above mentioned $PWD environment variable, but I never do and I don’t see much of a reason why you’d want to. Assuming you were in /home/<user> you could, again if you wanted, use cd $PWD/Documents and happily reach the Documents directory just fine.

Absolute and Relative Paths:

As you can see, there are different times and places to use a relative and an absolute path. When in doubt, I prefer the absolute path. If I’m writing notes that may apply differently to different systems, I’m more likely to use the absolute path. When I’m in a hurry, I tend to use a relative path – when I can use one.

You might as well get used to using both of them. They both have a right time and place. Commands like chmod may want an absolute path or will want the directory included. So, you’ll possibly need to chmod +x ./foo.txt instead of chmod +x foo.txt. In time, you’ll adjust and know which suits your needs best.

By the way, if the tab autocomplete doesn’t work after the command, the command probably demands that you denote the current directory with the . indicator like in the chmod above. If you type chmod +x fo<tab> it will refuse to autocomplete the filename. Once again, in time you’ll learn when that’s needed.

Learning to use Linux is a journey, not a destination!

Closure:

And there you have it! You have yet another article said and done. This one isn’t like some of my normal articles, but it’s still information folks might want to know. I find as the site grows, it gets possible to reference earlier articles, which is quite nice.

There are some articles I simply can’t write until I’ve taken the time to write other articles. I kinda like that. I’ve been enjoying typing these things out. I find the better I can explain them, the better I understand them. Heck, I recommend y’all make your own sites as this is pretty darned informative for me. The feedback is awesome and helps me understand even more.

Thanks for reading! If you want to help, or if the site has helped you, you can donate, register to help, write an article, or buy inexpensive hosting to start your own site. If you scroll down, you can sign up for the newsletter, vote for the article, and comment.

Let’s Decompress A File (tar.gz) In The Terminal

Pretty much every Linux user has to look up how to decompress a file in the terminal. Ask them to do it by rote and they’ll balk, but it’s actually pretty easy. Heck, there are entire jokes and comic strips dedicated to it. The thing is, it’s actually pretty easy and this article is going to show you how.

The tool we’ll be using for this is called ‘tar’ and the man page helpfully describes it like this:

tar – an archiving utility

If one is curious, the .gz is for gzip. It’s both a file format and a compression utility. The .tar is a container for multiple files. Its name comes from tape archive, where one would store multiple compressed files in one file. Think of it as a container for .gz files, if that helps.

Today’s article is meant to be REALLY basic, so we’re only going to approach this with the tar command. The only goal of this article is to teach you how to decompress a .tar.gz from the terminal. (There are a dozen GUI ways to do this, but not all systems have a GUI available.)

Decompress A File:

This article requires an open terminal. You can do so with your keyboard – just press CTRL + ALT + T and your default terminal should open.

You’ll also need a .tar.gz, but I’m going to assume you already have. If you don’t have one, you’re bound to reach that eventuality so long as you continue to use Linux. It’s a preferred file distribution format for things like source code. 

Anyhow, it’s really simple. Navigate to the folder where your .tar.gz file exists and run the following command:

You really only need to remember the vzf. In order, those stand for verbose (tells you what’s going on), z (decompress the files inside), and f (means the name of the file you’re working on).

The x flag means extract and we’ll get back to that in a moment.

You can even tell tar to extract the files in a specific directory. That’d look like this:

But, that’s not too terribly important, so long as you clean up after yourself and don’t leave a bunch of clutter. 

Let’s get back to that x flag. See, if you want to go the other way, that is to compress some files, you just change the x to a c.

In this case, we’re only to cover compressing all the files in a specific folder. That’s a little something like this:

So, really, you only need to remember the “vzf” and x for extract or c for compress. That’s the basics of decompressing a file in the terminal. There are a zillion possible combinations and the man page for tar is about a mile long.

In the vast majority of cases, those are the only two ways you’re going to use the command. If you need something more specific, check man tar.

Closure:

And, there you have it. You have the very basics on how to decompress a file from the terminal. There’s a lot more to the tarball but we really don’t need to cover that. If you need more, there’s the manual – but you probably won’t need more than that.

Thanks for reading! If you want to help, or if the site has helped you, you can donate, register to help, write an article, or buy inexpensive hosting to start your own site. If you scroll down, you can sign up for the newsletter, vote for the article, and comment.

Let’s Use ‘ls’ To Sort Files By Time

Today’s article is going to tell you how to sort files by time while using the ‘ls’ command in the terminal. I find sorting by time is often easiest when working with a lot of files that have less-than-helpful filenames. For example, it’s nice to sort by time when I’m dealing with screenshots, knowing that I took a new screenshot that’s helpfully named something like ‘kgiii@kgiii-msi: ~-Downloads_032.png’.

It’s usually easy enough to graphically sort files by time and date. In your file manager, you might need to select list view, add the column, and then select at least one of the time options. Different GUI file managers will have different options, and may not include all possible time values stored in the file’s meta information. Speaking of screenshots, it might look something like this:

sort by modification time
In this case, arranging items by ‘modification time’ is an available option.

The file’s metadata has several time options and we can sort by those with the ‘ls’ command while in the terminal. The output of ‘ls’ is usually sorted alphabetically. It’s not terribly difficult and will help you along your Linux trails. I find it useful when picking among a large number of files.

Parsing the output of the ‘ls’ command is generally considered a bad idea. We won’t really be doing that, but this is a good time to mention it. If you don’t know why, click this link. They explain it better than I can. That’ll save some time!

Today we will learn to use ‘ls’ to sort files by a few time value stored in the file’s meta information. It’s an easy enough process and a handy tool for your growing toolbox of Linux commands.

Sort Files By Time:

Obviously, you’ll need an open terminal. You can do so with your keyboard – just press CTRL + ALT + T and your default terminal should open.

Once you have it open, the /home/user directory is a fine choice. We won’t need to change directories – but you can. If you have a lot of screenshots saved in ~/Pictures, then you may find that directory more informative. Either way, let’s start with the basics:

This first one will show the last time the file was modified – which may be the creation date and time. That command is (the -l used in each command means use the long listing output):

You can sort by access time, sorting by the last time the file was opened. (Yes, this is all part of a file’s metadata.) To do that, you just use:

With that done, we have one more. This one shows the last time the metadata was changed for the files listed. If you were to use touch to change the last modified time, this would show when you did that. Make sense?

And there you have it! If you want to show the output in reverse order, you just use a -r flag and you can still use the -a flag to show hidden files, should you need to do something like that.

Closure:

That’s about it. You can now sort files by time. It’s a pretty handy tool and one you may find yourself using often. As mentioned above, I find it handiest (with my particular uses) when working with all the screenshots I take. I take a whole lot of screenshots. I assume I take more screenshots than most folks.

Thanks for reading! If you want to help, or if the site has helped you, you can donate, register to help, write an article, or buy inexpensive hosting to start your own site. If you scroll down, you can sign up for the newsletter, vote for the article, and comment.

Subscribe To Our Newsletter
Get notified when new articles are published! It's free and I won't send you any spam.
Linux Tips
Creative Commons License
This work is licensed under a Creative Commons Attribution 4.0 International License.