A Couple of Ways To Resize Images With ImageMagick

In today’s article, we’re going to go over a couple of ways to resize images with ImageMagick. It’s a useful skill to have if you’re into sharing images or the likes. This will actually be pretty quick and easy. I won’t take much of your time today but it’ll be longer than some other articles – but it really should be a quick read for you today.

It’s nice to not put full resolution pictures online – unless there’s a reason for the higher resolution. So, it’s a bit of a politeness to resize your images. I try to be considerate, ’cause I know what it’s like to have limited bandwidth. You people who started off in life with things like 100 GB fiber have no idea the pain we went through to get here! Alas, that whining is perhaps subject to another article, though probably not really a suitable article for this site. There are people who still use slow connections, and metered connections are entirely too popular.

So, what is ImageMagick? It describes itself as:

ImageMagick – is a free software suite for the creation, modification
and display of bitmap images.

ImageMagick is actually quite a useful application for quickly and easily manipulating images in the terminal. ImageMagick is so robust that trying to cover all of it in a single article would be foolish. I simply couldn’t do it within the bounds of a single article.

That’s why we’ll just be examining a couple of quick ways to resize images with ImageMagick. We couldn’t possibly cover it all today. If you want to see what all the options are, I’d recommend checking the man pages – and reading other tutorials that cover the things you’d like to do.

With that said and done, let’s resize some images with ImageMagick!

Resize Images With ImageMagick:

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 first thing we’re going to need to do is make sure you have ImageMagick installed. So, let’s install it. The command below is for those who use apt, but you can easily change it to your own package manager. I’m 99% certain that ImageMagick will be in your default repositories! It’s a pretty widely used application! The command for those of us who are apt-using people is simply:

Follow any on-screen prompts to install it, else it’ll tell you that it is already installed. ImageMagick appears to be installed by default on a number of distros, but it’s easy enough to install. You can actually just add a -y to it and skip some of the prompts:

Of course, you’ll still need to enter your password. Well, if you really want to live on the edge, you can enable passwordless sudo easily enough. I don’t really suggest that, but I do tell you how to do it. ‘Snot something for the faint of  heart.

Ah well… Onto the meat of the article!

Resize By Resolution:

Now that you have ImageMagick installed, let’s try resizing something. What we’re going to do first is resize it by way of the resolution. That is, we will resize it by declaring the new height and length. To do so, you’d use a command like:

For example, you might try something like this:

See? Pretty easy. I told you this wouldn’t be too hard – nor will this article be all that long. Well, it might be a bit longer than some, but I won’t let it be too long. I know my reader’s attention span! You should make sure to use the same base resolution. If the image is 16:9, your resized image should retain that aspect ratio. Otherwise, your images may appear warped and ugly.

I should probably mention that it’s possible to make images larger with this command. However, when you make an image larger you lose fidelity. Making an image too large is going to result in an ugly image. It’s not like the television where you can just keep zooming in and enhancing. Ones and zeros don’t work like that.

Resize By Percentage:

This is my favorite way to resize images with ImageMagick, unless I have a specific reason to resize images by resolution. In this case, you just declare a percentage of the original and ImageMagick does the rest. It’s really a very easy command. It looks a little like this:

If you want, here’s an example of how you can use that command to resize images by percentage with ImageMagick:

That command will make ImageMagick output a file that’s 50% smaller than the original image. Not only will this be a smaller image visually, it will have a smaller file size. Because of the way images work, this doesn’t mean the new file size, size on disk, will be reduced by 50%. It just means you’ve reduced the image’s dimensions by 50%. The size on disk will also be lower, but it’s not directly proportionate. 

Like above, where  you resize the image by resolution, you can use this to make images larger. The same caveats exist that existed above. That is making an image too large means it results in a poor quality image. As you can guess, making images larger isn’t always a good idea, but it’s generally fine if the operation is making the images smaller.

Closure:

And there you have it. You have another article! This time, we’ve covered how to resize images with ImageMagick. I think that’s a useful skill to have and it’s a quick/easy thing to learn. Of course, you can always check man imagemagick to check the man page. That man page will be enlightening, I suspect.

I’ve changed the format a bit for this article (though I’ve used it before), and made it a bit longer than the recent articles. If you have an opinion on the matter, please feel free to leave a comment. The more I know about your wants, the more I can tailor the content. The more I can tailor the content, the better you’ll enjoy the content. To do this, I need to know your thoughts on the matter. Speak up!

So, do you enjoy the longer articles? Do you enjoy the shorter articles? Do you appreciate a mix of them, and each article only being as long as it really needs to be? I normally try to keep all my articles friendly, informative,  and fairly strictly informal. Lately they’ve been pretty  short, but I can be more verbose, as many of you will have witnessed.

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: Search With apt

Today we’ll learn how to search with apt. There are any number of reasons why you’d want to do this. You can use this to find applications by name or subject. Maybe you want to find files that meet a certain criteria? It could be that you’ve forgotten the name of the application you’re thinking of? Perhaps you want to know if an application is available in the repositories before you go seeking it elsewhere?

There are all sorts of reasons, including those, why you might want to search with apt. Obviously, this requires an operating system that uses apt, so that limits you to things like Debian, Ubuntu, official Ubuntu flavors, Linux Mint, etc… So, well, it’s a pretty sizable number of distros where this will work.

This will be a pretty simple article. It will also be pretty brief. I’ve likely mentioned searching in another apt article, but it’s important that we cover it. Alas, I’m running out of things that make for longer articles (in the notes I’m working from), so this is just another article where I’m trying to make you aware that certain tools exist.

This should absolutely be a short and easy to understand article. In some recent commentary, I realized that what’s ‘simple’ to me is something that someone else has been dealing with for the past year. Even my easier articles have the chance to help people figure out their Linux problems. Good… It makes me feel better when I write an ‘easy’ article.

So, with all that said… Let’s learn how to:

Search With apt:

This article pretty much requires an open terminal, like oh so many other articles on this site. If you don’t know how to open the terminal, and you should by now – if you’ve been following along long enough, you can do so with your keyboard – just press CTRL + ALT + T and your default terminal should open.

Now, it should go without saying, apt is how you interact with your package manager. It’s how you install, uninstall, or otherwise manage your software in the terminal. You could insist on using a GUI to install software, in which case this won’t be of much interest to you, or you could just do it all in the terminal. Either way, if you are using a different package manager then this will be of no value to you.

Me? I prefer to do this sort of stuff in the terminal because I find it easier and faster. I’ve already got a terminal open anyhow, so I might as well use it.

Anyhow, with your terminal open, go ahead and type:

For example:

Seriously, if you’ve never used the search function, go ahead and try the above command. You might be surprised by what you find.

Now, if you’re trying to narrow it down some, you can use the –names-only flag. Which isn’t as accurate as it could be. For example, try:

But, as near as I can tell, that’s searching not just the names but also searching the one-liner description. Like, if you run the above command you’ll also see ‘terminator’, which is definitely not ‘terminal’.

However ‘terminator’ includes ‘terminal’ in the description. So, I’m not sure where that’s going with that and the man pages weren’t all that helpful. You can also use RegEx (Regular Expressions, for the uninitiated). For example,  you can run:

This, of course, only works if you have Google’s Chrome repositories enabled. Otherwise, pick something else to test this with. Or, just trust me when I say RegEx works, which the man page will confirm.

Anyhow, our example command from above would (on this computer) would have an output that looks like this:

Which, as you can see, means I have multiple versions of Chrome available. So, that’s something positive in my life! But, the point is, I did a search with apt and came away with the information I wanted. I’d normally send you to the application’s man page, but in that probably won’t make it all that much clearer. 

Closure:

Yeah, that’s it. You can now search with apt and find what you’re looking for. Use some of your own search terms, like apt-cache search image editor, and see what sorta results you get. It’s not the most refined, but it’s an effective way to search with apt.

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 Talk About Using dos2unix

Today, we’re going to talk about using dos2unix, a tool for converting Windows text files to Unix (Linux) formatted text files. The command isn’t very difficult to use, so this article is more about making you aware of the existence and purpose of said dos2unix. It should be a remarkably short article.

First, we have to go back in time…

Once upon a time, when you reached the end of the line with text, you had to instruct the hardware to start a new line. These were the old days of things like teletype machines and dumb terminals. They needed to be told when to begin a new line.

Well, that still exists in software today. The thing is, if a file was created on Windows it will have two characters denoting when a new line should begin while a file created on Linux will only have one character indicating when a new line should begin. Yay for compatibility issues!

Anyhow… This is why you will sometimes get errors with text files. For example, writing a shell script on Windows and then trying to use it on Linux may result in end of line errors. Windows uses CR (Carriage Return) and LF (Line Feed, you may know it as /n) while Linux (and Unix) just uses LF. This, of course, can cause some confusion for the operating system.

This is where dos2unix comes into play. This is why you’re getting an article about using dos2unix… So, with that in mind…

Using dos2unix:

This article requires an open terminal, like oh so many other articles. If you don’t know how to open the terminal, just press CTRL + ALT + T and your default terminal should open. Tada!

Now, you’ll need to install dos2unix. It probably isn’t installed by default. Just use your package manager’s standard install command and I’m like 99% certain it’s a package available to you by default. For example, in Debian, Ubuntu, and Ubuntu derivatives and flavors, it’s just a simple apt command:

Once you have dos2unix installed, you can convert Windows-created text files to Unix (and thus Linux) formatted text files by fixing the way they end a line and start a new line. That’s really easy. It’s just:

Yup…

Well, I suppose you could also do /path/to/filename.txt if you needed, or you can just navigate to the directory and use the command above. It really is that easy.

There’s more to the dos2unix application, but that’s about all you’re really going to need to know under normal circumstances. It really is that simple. Do check the man page (man dos2unix) for other options, but you’ll see that’s about all you’re gonna need.

Closure:

Like I said, this article is really about making you aware of the problem and solution, so that you can start using dos2unix if and when you need it. It turns out that dos2unix is more than just a contributing forum member on Linux.org, it’s actually a useful application for dealing with Windows files on a Linux box!

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 Root Around In The /proc Directory

Today, we’re going to root around in the /proc directory. Why? So we can learn about our Linux system. See, there’s quite a bit of information hidden in there and I’m going to show you how to get it out of there. You’ll have to root around for it, as I’m not going to document every possible combination, but you’ll have the tools to do so.

We will be using the terminal for this, but we’ll only be using a couple of tools. The first tool we’ll use is the ‘ls’ command. We’ve used it before to sort files by time and sort files by size and even to show hidden files and folders. So, as you can guess, it’s a pretty handy command.

The other application we’ll be using is ‘cat’. We’ve used that less often, but we’ve used it before, but here’s a brief overview of the ‘cat’ command. You might want to read that. But, basically, we use the cat command to read files in the terminal. 

The ‘cat’ command is also a pretty handy command. You can try it out yourself. If we assume you’re using bash and have history enabled (the vast majority of Linux users) you can do something like:

That command should spit out the history of commands you’ve typed into the terminal. Perhaps some of ’em will have been things you learned right here on Linux-Tips! Well, maybe… I mean, people tell me they learn stuff here, though I’m never quite sure how! 😉 Anyhow…

So, this will be a fairly informal article. It should also be quick and easy. You’re welcome!

Rooting Around In The /proc 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.

Like I said, this is a fairly informal article. Quick and easy, right? Well, I’m going to show you everything you need to know in one command. Ready?

You’ll see a whole lot of files. What you want to do is use ‘cat’ on those files. Like, if you want to read/check your CPU information, you’d use:

Do you want to see the information the system has for your memory?

Not all the files have useful data, but some of them do. That’s why you’ve gotta root around in there. You’ve gotta learn which files contain which information – but I’ve given you a head start with two of them. You’re on a path of discovery, ’cause I’m surely not going to go through all of ’em to tell you what they do. I give you the tools, you do the work. Or something like that…

Closure:

See? Nice and easy, and very much an informal article. You can now root around in the /proc directory to get some system information. You may need elevated permissions to read some files, and some of them contain what’s pure gibberish to me. They might make more sense to you!

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.

Disable Bluetooth From Automatically Starting At Boot

In today’s article, we’re going to learn how to disable Bluetooth from automatically starting at boot. It’s a handy thing to know, if you’re like me and have no real use for the service.

I suppose it’d even speed your system’s boot time a trivial amount and reduce the number of running services. So, it’ll make your system a trivial amount more efficient. I just don’t care for Bluetooth so I have a way to prevent it from automatically starting in my notes. These articles are generally based on my notes, so now you’ll know.

NOTE: I should probably also mention that this is really only useful for those of you who use systemd. If you still haven’t moved to systemd, or refuse to move to systemd, then this article isn’t going to be of much use to you. You can still do this, but you’ll have to do so with your particular init system’s commands. These commands are not gonna work for you.

Even if you don’t want to disable Bluetooth from automatically starting at boot, you may want to learn how to disable other services. The process for other services is pretty much the same as it is for Bluetooth. So, you can learn something from this article if you’re new to this whole thing.

This is a nice and easy article, it shouldn’t take much time to read and understand. So then, let’s get on with it!

Disable Bluetooth From Automatically Starting At Boot:

Yeah, that’s longer than it should be. Oh well… Blame the need to optimize for keywords! I try to keep ’em shorter, but here we are…

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.

With your terminal open, let’s first check the Bluetooth service status:

It may or may not be running. If it’s not running, odds are that Bluetooth isn’t set to automatically start at boot. You can ensure that it’s not set to automatically start with the following command:

Now, that’s the command you probably want. It’ll disable Bluetooth from automatically starting at boot – and it will still let the Bluetooth service start if you want it to later or if something else in the system calls for it to start. You can reboot and make sure the setting has changed, if you’d like.

On the other hand, if you ‘mask’ the service, like we did in the How To: Disable Sleep And Hibernation on Ubuntu Server article, you won’t be able to start the service at all. That’s the biggest difference between ‘disable’ and ‘mask’, in case you’re curious. Both of these options are better than manually deleting the services, ’cause you can undo the setting fairly easily. In fact, to do so with the Bluetooth service, you just:

After which, you should check the status again:

And all should be well. You can now reverse it after you’ve chosen to disable Bluetooth from automatically starting at boot. See? Pretty easy and handy information to have for other services. By the way, if you chose ‘mask’ then you’d ‘unmask’ the service, which seems like an obvious way to do it.

Closure:

See? I told you that this one would be pretty quick and easy. I’m kinda amazed that I haven’t run out of ideas for articles yet! I’m still chugging along, well after the initial year-long scope for the site. If I can do it, anyone can! I’m still very much open to guest articles, within reason.

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.