How To: Show Hidden Files And Folders

Today, you’ll read an article that tells you how to show hidden files and folders (in Linux, of course). This is something everyone should know. This is a basic skill that you’re almost certain to need if you make the decision to use Linux.

Fortunately, it’s pretty easy to show hidden files and folders. You’ll see…

First, I should probably explain what hidden files and folders are. They’re files and folders that start with a period. So .foo.txt is a hidden file and .bar could be a hidden directory. One should remember that Linux is, by design, a multi-user system. With that in mind, having hidden files makes sense – if you don’t want those files to be accidentally (or maliciously) edited.

Any files or folders that begins with a period will be a hidden file. If you’re new to Linux, you might want to leave them hidden until you’re a bit more comfortable working with system files. Or not… It’s your system, you do what you want with it.

In a GUI file manager, you can usually figure out how to show hidden files and folders pretty easily. Sadly, it’s not universal in a GUI. Look in the right click menu, under the “View” option, or in the application’s preferences. It’s also often ALT + H and I want to say I’ve even seen it be ALT + F4. Look around, you’ll find it.

This article is more about showing those hidden files and folders in the terminal. It’s a really easy command and won’t take too long to explain it to you. So, enough preamble, let’s begin.

Show Hidden Files And Folders:

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.

We’ll stay right in the default directory, your home directory. If you’re not currently in your home folder,  you can get there with:

Your home folder should have all sorts of hidden files and folders. First, let’s see your home directory without showing the hidden files and folders:

Unless you’re in the habit of storing files in your home directory, you should have a fairly tidy list of folders and files that you’re likely already familiar with. 

Now, let’s try again – this time showing hidden files and folders:

Or, you can get a more easy to read output with this command (and you get more information with it):

If you want to see it in action, you can try this command:

Now, if you use the ls command you won’t see that file. If you use the ls -a command you’ll see the hidden file that you created called .foo.txt. This of works with directories, as they too can be hidden.

Yup, that’s it. That’s today’s article. See? I told you it was easy.

Closure:

Indeed, it is an easy article – and one most of my readers will already know. This one is aimed squarely at the new user who has yet to learn how to show hidden files and folders. It’s a pretty important skill to learn, and it’s also important to know which ones you probably shouldn’t edit. So, judicious use is important.

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: 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.

Linux Tips
Creative Commons License
This work is licensed under a Creative Commons Attribution 4.0 International License.