Let’s Find The Size Of A Directory

Today’s article is one where we’re going to find the size of a directory. Why? Because that sounds like something fun to do. The site has more than 250 articles, most of which are reasonably productive and authored by me. (I do love me some guest articles – so long as they’re from the community. No more paid stuff! That lesson was learned.) They can’t all be winners!

So, why would you want to know the size of a directory? How should I know? Maybe you need to make space? You could want to upload the directories and want to know if you have space at the destination? Perhaps you are going to transfer the files and you want to estimate how long that will take? You do you. I don’t care why you want to find the size of a directory. That sort of thing is between you and your directories!

Anyhow, we’ll be using ‘du’ in this article. If you want a GUI way to find the size of your directories, you can visualize disk usage easily enough. You can also easily find large files. You shouldn’t need to install ‘du’, it should be installed as a part of the standard toolkit (GNU coreutils). To find out if you have ‘du’ installed, you can just try du --v in the terminal, which will spit out some version information.

So this should be a fairly short article – nice and easy. Let’s get on with it!

Find The Size Of A Directory:

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’re going to us ‘du -h‘ for everything, because that -h stands for ‘human readable’ and it’s just easier than seeing byte sizes. You don’t actually have to use the -h, it just makes good sense to do so.

The format for this is largely ‘du -h /directory‘, like so (using the Documents directory as an example):

You can just add more directories as needed (we’ll add downloads):

That will output the size of both directories. If you are unaware, the ~ (tilde) is a shortcut meaning your home folder. For example, if you’ve navigated away from your desktop, you can cd ~ and get back home. It’s faster than clicking your heels together three times!

By the way, if you’re stringing directories together, you can get the total size of the directories with the following:

That’s about it. That’s all you really need to know for this exercise. I told you that it’d be quick and easy! Most of my articles involve opening the terminal, and yet so many of them are really quite simple to learn and remember. I strongly urge new Linux users learn a bit about the terminal, not because it’s hard but because it’s often easier and faster than using a graphical tool.

Closure:

I wasn’t kidding about there being more than 250 articles. There are 256 of them at this time, and this will make 257. So far, I haven’t run out of ideas and I’ve been able to get one out to you every other day. I hope you find these articles as useful as I’d like them to be. It does take me longer to come up with ideas, so it might have to slow down at some point. I mean, I can’t keep writing these kind of articles forever,  can I? No… No, I don’t think I can.

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: Convert JPG to PNG

In today’s article, we’re going to learn how to convert JPG to PNG image files. It’s a pretty easy process. In fact, the second part of the article should be fairly brief. Read on to learn more!

I should also mention that we’ll be learning how to convert JPG to PNG in the terminal. There are all sorts of GUI ways to do so, from individually converting files to batch conversions. Well, you can do all that in the terminal and this article will show you how.

Why PNG? Well, it supports lossless compression. PNG also supports transparency. PNG also looks better at higher resolutions, as it is able to display more details. Additionally, PNG not only supports lossless compression, it supports compression better – so you needn’t transfer larger files if you have no reason to do so. Plus, PNG is one of the better formats if  you’re going to do things like share the images online.

So, there are a number of reasons why you’d want to convert JPG to PNG. Fortunately, as I mentioned above, it’s really not all that difficult. You have tools to do this right in your default repositories, assuming you’re using a mainstream distro.

Without further ado…

Convert JPG to PNG:

As we’ll be converting in the terminal, you will have to have an open terminal. To do that, just press CTRL + ALT + T and your default terminal should open. See? We’re off to a good start.

Now, the tool we’ll be using is ‘ImageMagick’ and it’s available to install via  your normal channels. If you were using a distro that uses apt (Debian/Ubuntu/Mint/etc) then it’s trivial to install with:

Otherwise, install it with your default package manager tools. (You just might have installed when we covered how to resize images with ImageMagick. If not, now’s a good time to install it and then read that article!)

So, next you’ll either want to use the /path/to/directory where your JPG files are,  or just navigate to the directory where you’ve stored them (the easiest path), and you can convert them all with just one command:

Congratulations, in just that one command you’ll have converted all the JPG to PNG files. Feel the power of Linux! You’ll retain the originals, just in case something goes awry. If you’re happy with the results, you can always delete the originals with any one of a number of commands.

So, what if you just want to convert one JPG to PNG? Well, that’s easy:

See? I told you it was easy. While there’s a whole lot of complexity with ImageMagick, it can be quite simple to use for some very generic day-to-day tasks. Of couse, man imagemagick is always an option to learn more.

Closure:

Yup… It’s really not all that hard to convert JPG to PNG files with ImageMagick. If it’s a large number of files, it could be a bit for you to convert them all, but let it do its thing and it won’t take too long on a modern computer. If you only need to convert one image, that’s fine too.

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.

Find Your Graphics Card Information

Today’s article isn’t all that spectacular, but it is useful, as we’re going to discuss a few ways to find your graphics card information. That’s handy stuff to know, especially if you are new to the computer or are looking to do things like find drivers for said graphics card. This should be remarkably quick and easy, actually.

We will be using tools we’ve used before. These are simple tools, tools used to learn hardware information. Well, they can all be narrowed down to show just the graphics card information. They can also give information about other hardware, not just graphics card information.

All the tools we’ll be using should be installed by default. We will use one program that isn’t necessarily installed by default. That program will be inxi. You can learn how to install inxi easily enough, and the rest should be installed by default. If inxi is not installed, install it.

Like I said, the article should be fairly quick and easy. You only need a few specific commands. ‘Snot all that complicated, now is it? 

So, let’s take a minute to read an article that tells you how to learn more about your…

Graphics Card Information:

As is often the case, this article requires an open terminal. 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.

With your terminal open, let’s go ahead and use the inxi command first:

See? Plenty of graphics card information.

How about we use ‘lshw’, a tool for listing hardware information? Well, the command for that would be pretty easy. You just need to specify that you want graphics card information. It looks like:

Finally, we can use ‘grep’ and ‘lspci’. We’ll also use the -k flag to list kernel drivers. It’s easy. You don’t have to memorize it, you can just refer back here later when you actually have a need for your graphics card information. It looks like:

That should do it. You can use any of those three methods (or more) to find your graphics card info. I just use on-board graphics, so a screenshot would be quite boring.

Closure:

Well, there you have it. You have yet another article. I didn’t go deep into the usage of each tool because there’s no reason to. Each program has a help file associated with it. Consult the help file if you wish to know more. This article’s goal was to demonstrate a specific use.

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: Reload Your .bash_profile

Today’s article is going to explain  how to reload your .bash_profile. It will be just a quick and easy article, one that won’t take up much of your time. It’s not all that complicated, but it’s something folks probably should know.

So, most of you will probably have a .bash_profile. There are other shells, but Bash is the most common. That’s where they store various bash settings. When you make changes to the .bash_profile, the profile needs to be reloaded for the changes to take effect.

I’ve probably covered this elsewhere, though I did write an article to show you how to find out which shell you’re using. If you don’t know, Bash is the name of the shell and stands for Bourne shell. There are many shells, but Bash was the first one ported to Linux. Indeed, it was one of the first applications ported to Linux. It’s still widely used as the default on most distros.

There are times when you’ll want to edit your .bash_profile for additional functionality. It’s where you’d go to change things like terminal output colors and you could even add aliases to the file if you really felt like it. (Those should probably bo in .bash_aliases, for the record.)

With that in mind, I’ll show you how to reload your .bash_profile.

Reload Your .bash_profile:

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.

Like I said, this won’t be a very long article. It’s not terribly complicated.

Let’s say you’ve made a change to your .bash_profile and you want it to take effect immediately. To do that, you enter one of the following two commands:

Alternatively:

You could also close all instances of the terminal and the new .bash_profile changes should take effect the next time you open the terminal. If you really want to have another way, you can reboot and the changes will take effect the next time you open the terminal as that too will reload your .bash_profile.

Closure:

See? I told you this would be a quick and easy article. It’s not all that complicated. You probably don’t need to reload your .bash_profile often, but now you know how to do so when you need to do so. Yup, it’s also another article. There are now more than 250 articles, by the way. Who knew that it’d turn into this?!?

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 How To Change The Open File Limit In Linux

Today, lacking anything better to do, we’re going to learn how to change the open file limit in Linux. Why would you want to do this? Buggered if I know! But, I’m gonna tell you how! (You’re welcome!)

Actually, you could be working with many files and want to increase the number of files that can be open at one time. You might also want the opposite, as a way of limiting system resources.

Basically, in Linux, anything that can use resources has some sort of limitation. For example, there’s a limit to how many arguments that can be passed in a single command or for a new process. You’re unlikely to bump into that limit as a regular desktop Linux user, but that limit is there.

Heck, if you want to learn more about that, click this. I’m not entirely sure how to change that value, but it might actually be in some notes somewhere. Someone’s gotta know how.

Again, you’re very unlikely to run into problems as regular ol’ desktop Linux user. Realistically, you’re unlikely to have to change the open file limit in Linux. However, today is the day I tell you how! Why? ‘Cause I ain’t scared – and it’s not my computer that you’re mucking about in!

I should also mention, more to remind you gentlefolk, that everything in Linux is a file. Everything… So, you’d be surprised how many files you have open at times. Even then, you still probably don’t have too much of a need to change the open file limit.

Change The Open File Limit:

Like many articles, this one requires an open terminal. 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.

With your terminal open, now is a good time to tell you that there’s a hard limit and a soft limit. The hard limit can only be changed by root and the soft limit can be altered dynamically by the process.

You can learn those limits. To find the hard limit, use this command:

And, to find the soft limit, use this command:

Those commands will output the value of your hard and soft limits, respectively. 

You can obviously change those limits, else this wouldn’t be an article. To change the open file limit, you just add a new value as an additional argument. It’s something like:

And, again for the soft limit:

For example, you might increase the hard limit with a command like so:

If  you want to make them permanent changes, you can do that. It’s a little different for the hard limit and the soft limit. So, to make them permanent we need to use nano to do some file editing:

And add this line:

If you want to change the soft limit, it’s a little different. It’s just:

If it’s not obvious, replace the username with your username (and no brackets, of course). Then, of course, you’ll need to save the file. To do that, just press CTRL + X, then Y, and then ENTER and that’ll save the file properly.

You shouldn’t need to reboot. The changes should be immediate and you can run the above commands to verify this. If the changes somehow didn’t take effect, reboot and  you should be good to go.

Closure:

I’ve never really needed to change the open file limit as a desktop Linux user, but you might have a reason to do so. If that’s the case, it makes sense to have this information handy, and now you do.

It’s yet another article in a long, long list of articles – a list that’s growing steadily! I have yet to miss a single publication date, though I feel compelled to do so – as it’d take the pressure off knowing that I no longer have a “perfect” record.

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.