Let’s Make An Animated GIF (With ImageMagick)

Today’s article is just for fun, where we learn how to make an animated gif in the terminal – with ImageMagick. It’s just for fun and not something you’ll likely need unless you’re some sort of content creator. (We don’t know any of those, do we?) Anyhow, let’s go ahead and make an animated .gif in the terminal.

Today, we’ll be using ‘ImageMagick’. As far as I know, imagemagick has one of the longest and most complicated man pages. It’s huge and a capable tool in the right hands. ImageMagick has all sorts of capabilities but a new user isn’t likely to use them because of the complexity involved.

And, ImageMagick is complex… In fact, it defines itself as:

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

That’s an accurate description, I think… Except, well, it does a whole lot more than that. We’ll be using the .gif format, while the man page description only mentions bitmap. So, there’s a lot to the application.

Thus, without further ado, we make an animated gif in the terminal…

How To Make An Animated GIF:

The ImageMagick application is terminal-based. So, you’re going to need an open terminal. If you want, you can just press CTRL + ALT + T and your default terminal should open.

If you don’t have ImageMagick installed, you’ll need to install it. If you’re using a mainstream distro, it’s possibly installed already. Otherwise, it’ll certainly be in your default repositories as it’s a pretty major tool. For example, an apt user would just use a command like this (adjust for your package manager):

With your terminal now open and imagemagick properly installed, let’s just see how long that man page is:

See? I wasn’t kidding!

Now, here’s what you need to make an animated gif:

  1. A dedicated folder, perhaps in your ~/Pictures directory.
  2. A few images of the same format, we’ll use .jpg in our example.
  3. A terminal opened in the above-mentioned dedicated folder.

The first thing to learn is that this command is going to take those images and turn them into an animated file with the .gif extension. It is going to organize them alphanumerically. So, you should rename the  .jpg files in the order you wish to see them (assuming the order matters to you).

All set? Have you done all those things? Are you 100% prepared? Good!

The command we’re looking for would be:

Alright, so the ‘delay 100’ is how long each image will be shown – in hundredths of a second. The ‘-loop 0’ tells it to loop infinitely, or you can pick your own number of times. The ‘*.jpg’ means use all the .jpg files in that directory. The ‘file_name’ is the name of the file you want to have as your output.

See? Pretty simple. An example command might be something like:

Let the command run, and it is a pretty speedy process unless you have a whole lot of images, and you’ll get an animated gif as a result. As these tend to have smaller file sizes, it’s sometimes a better option than sharing a larger video file. It depends on your circumstances, I suppose.

NOTE: This article has been edited to correct the time delay, the delay between changing images. Thanks @wizardfromoz!

Closure:

There you have it. You have an article that tells you how to make an animated gif with ImageMagick. The ImageMagick application has a ton of options, making it daunting for a new Linux user. So, this is just a tiny bite. This is just one of many ways to use ImageMagick. Instead of learning the whole application at once, you can do so in chunks – learning only what you need.

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 site. If you scroll down, you can sign up for the newsletter, vote for the article, and comment.

Let’s Play With Touch And Time

Today’s article is just a fun article where we get the chance to play with touch and time. This article won’t necessarily be something you rely on daily, but it should at least be informative. That and there’s surely a subset of users who use these commands. There’s bound to be! Otherwise, why would they make touch flags for adjusting the time?!?

We’ve used the ‘touch’ command before.

Some Useful Ways To Use The Touch Command In Linux

I’m pretty sure we’ve also used the touch command in at least another article. There are a lot of search results for the word and it’s not important enough to go looking. The key point is that touch is a command you use in the terminal and it describes itself as:

touch – change file timestamps

See, we (and perhaps most other sites) have used the touch command to *make* files, but it’s useful (and intended for) changing file timestamps. Like oh so many commands, there are all sorts of ways to use it and so many folks do things in their own way. The great thing about Linux is that we have so many choices.

This is why I figure I’ll cover touch and time in this article. It’s just a few commands that we’ll be using, so it’s not all that advanced. A beginner probably won’t need to know this sort of information, but it’s information worth sharing.

Playing With Touch And Time:

As we use touch in the terminal, you’re going to need to have an open terminal to play with touch and time. If you don’t know how to open a terminal, press CTRL + ALT + T and your default terminal should open.

With your terminal now open, let’s start by creating a file:

That command will create a file with a created timestamp from the time you ran the command. If you want, you can change the access time, that is the time stored with the file that says when it was last accessed. Run the following command with the -a flag:

That’ll change the ‘foo file’s access time to the time when you ran the command. All well and good? Alright… Let’s remove that file with:

Now, we’re going to create the foo file again, but we’re going to give it a specific timestamp. The format you want is:

Or, something like this:

That will give the file a timestamp from March 3rd at one minute and one second past midnight. Note the period denoting seconds as that’s the only modifier you need for this command.

NOTE: If you use a different time format, that command might be different for you. I don’t think it is, but I’m not set up to test that. If it does matter, please let us know in a comment, thanks!

Finally, let’s say you have a file named ‘bar’ and you want ‘foo’ to have the same timestamp that bar has. You can do that with the touch command. It’s relatively easy to do with the -r flag:

That command will give foo the same timestamp that bar has, should you be inclined to do so. It’s pretty easy to use the touch command to change a timestamp on files, which is why you might not want to rely too much on timestamps. They can be useful, but they are not immutable. 

You can run the command above to delete the foo file when you’re done playing around with the touch command:

Closure:

There you go, another article. This time, we’ve had an article about using touch and time, which is kinda why the touch command exists in the first place. It’s far more useful than just creating files. Be sure to run man touch (no inappropriate jokes) in the terminal to learn more about the touch command. There are other touch commands that you may find yourself interested in, I’ve just covered a few of them.

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 site. If you scroll down, you can sign up for the newsletter, vote for the article, and comment.

How To: Restart SSH

Today’s article will be a very short and easy article, where we learn how to restart SSH. This involves restarting the SSH service. It may not even require a second section, it’s that easy. No, it probably will, just to keep things uniform. So, to learn how to restart SSH read on!

This one is drawn from my own frustration. I recently have had to deal with this a couple of times and I’m not sure why. I’ll root through the logs to figure it out at some point, but the obvious issue here is that I had issues with SSH stopping. More specifically, the SSH daemon/service stopped running.

In my case, I was able to just use another remote connection to the device. I suppose I could have just walked across the house, but it was easier to just use TeamViewer.

Oddly, I’ve had TeamViewer cause problems before. I even have an article detailing how to restart TeamViewer from the terminal (via SSH, I suppose).

So, rather than rebooting the system, I just connected via an alternative method and restarted SSH. It’s easily done.

Restart SSH:

You’ll first need some way of connecting to the device with the stopped SSH service. In the opening section, I mentioned doing so with TeamViewer. It pays to have a backup method to connect to your servers, so you could use VNC or something else that works for you.

If you physically go to the device, or remotely connect to the device, you’ll need a terminal to work with. So, open a terminal. Depending on how you’re connected, you might have to find the terminal in the menu as not all keyboard shortcuts will be passed to the remote computer.

So, once you have a terminal open on the remote computer, try this command:

If that doesn’t work, try this command:

One of those should work for you. Make note of which one works and you, if you think you’ll be doing it often. You can also ‘stop‘ and ‘start‘ services, easily enough, but just a restart should do the trick.

Closure:

See? I told you that it’d be quick and easy. I could use a quick and easy article right now, and this subject just happens to be something I’m currently thinking of. So, you get this as an article, an article about how you restart SSH. Simple and easy…

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: Install Proprietary Drivers In Ubuntu

Today is going to be a very quick and easy article, where we learn how to install proprietary drivers in Ubuntu – in the terminal, of course. It’s easy enough for a new user, as it’s just a single command. It’s also not all that well known and not documented in the man pages or anything, so I might as well cover it here.

There are all sorts of reasons why you might want to install proprietary drivers in Ubuntu. Some of your hardware may not work at all until you do. Some of your hardware will only have partial functionality until you do install the proprietary drivers.

Of course, if everything is working just fine, you might not even need to worry about the proprietary drivers in Ubuntu. If everything is fine, there’s no reason to worry too much. You know what they say, “If it ain’t broke, don’t fix it.” 

Of course, a subset of you will say, “If it ain’t broke, tweak it!”

Anyhow, this article only applies to Ubuntu and official Ubuntu flavors. It likely also applies to Ubuntu derivatives. A quick check seems to indicate that Mint is one of those derivatives that support this command. We’ll only cover it from the Ubuntu-specific direction. If it also works for you, that’s a benefit. If it doesn’t work for your distro, the maintainers likely took it out for a reason.

So then, let’s get to work installing proprietary drivers on Ubuntu…

How To Install Proprietary Drivers In Ubuntu:

As mentioned above, we’ll be doing this in the terminal. So, you’re going to need an open terminal for this exercise. You can just press CTRL + ALT + T and your default terminal should open.

With the terminal now open, we need to ensure you have the “Restricted” repository enabled. As you already have a terminal open, we might as well do that while in the terminal. So, type the following command:

Now, you need to update your database of software that’s available and we might as well make sure all other software is up to date. You do that with this command:

There you go. You’re now ready to install proprietary drivers in Ubuntu. So, while it’s a single command, it may require some preparation for some users. If you’ve run the above commands, we should be on the same page. So, with that, you just run the following command:

If there are any prompts, just go ahead and press the Y button. Everything should go smoothly and you may need to reboot after installing the proprietary drivers. When you’ve done that, you should be using the newly installed drivers instead of the open-source (or no) drivers. 

That’s all there is to it…

Closure:

There you have it! You have another article. I know I told you that it was just a single command and then shared more than one command, but it is just one command so long as you’ve got the Restricted repository enabled already (and I think most of us do). Either way, there’s a quick and easy way to install proprietary drivers in Ubuntu, in the terminal even. ‘Snot all that difficult after all!

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 site. If you scroll down, you can sign up for the newsletter, vote for the article, and comment.

How To: Show File Sizes When Listing Files In A Directory

Today we’re going to have an easy article that shows you how to show file sizes when listing files in a directory. It’s a simple set of commands and easy enough for a newbie to learn. Though the title is unwieldy, read on to learn how to show file sizes when listing files in a directory…

We’ll be using the ‘ls’ command for this exercise. Like normal, I’ll go ahead and suggest you read this page about why you shouldn’t parse the output from the ‘ls’ command. There are better ways and that link will explain it, and what you should consider, far better than I can.

Anyhow, the ‘ls’ command defines itself as:

ls – list directory contents

Of course, regular readers will recognize the ls command as we’ve used it numerous times before. Even though you shouldn’t parse the output from the command doesn’t mean it’s not still useful for a variety of other tasks.

Today, we’ll be exploring one of those tasks. We’re going to show you how to show file sizes when listing files in a directory – specifically with the ls command. Don’t worry, you won’t need to install anything. If you’re using any desktop Linux distro, the ls command is certainly available to you by default.

For the record, you should probably view the ls man page (run man ls in the terminal) to learn more about the command. It’s still a useful command – and I do sometimes parse the output from the command, but only when nobody is looking and when the output isn’t all that vital. I use grep with the ls command almost every day! Shh!!!

Show File Sizes When Listing Files In A Directory:

(That’s an unwieldy title!)

Anyhow, it’s the ls command. That’s a terminal-based command. So, of course, you’re going to need an open terminal (like so many of these articles). Press CTRL + ALT + T and your default terminal should open. Tada!

With your terminal now open, we can just use your home folder. To run the basic ls command, it’s just that:

Now, to show file sizes when listing files in a directory, you’d start with the -s flag:

You may find the output from that command is relatively useless without doing a bit of math to go along with it. Fortunately, you can tell the command to show the file size in a ‘human-readable format’. To do that, you’d run this command with the -h flag:

Now, if you wanted to show all the files, including the hidden files in that directory, you’d just add the -a flag. The command would look like this:

And if I was a Linux newbie, that’s the command I’d commit to memory. It doesn’t make a mess. The output is still plenty clear. It’s easy to understand. It’s easy to remember and turn into a habit. This way, when you ran the ls command, you just default to using -ash flags.

If you don’t want columns (and some do not), and you want more information such as file permissions or ownership values, you can just add an -lflag to the above. That’d look like:

So, it’s up to you…

You can remember ‘ash’ or you can remember ‘lash’. You can also not remember either and ignore the flags completely, but I find developing a habit is a good way to remember things. It’s your device, you do what you want!

Closure:

There you have it! You have another article. This one was simple enough and I hope you found it useful. If you’re new and running the ls command is new to you, it’s worth learning some additional flags and gathering more information at a glance. That’s why there’s this relatively simple article that shows you how to show file sizes when listing files in a directory.

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.