Remove Files By Extension

This should be a quick and easy article, easy enough for anyone to follow, as it covers how you can remove files by extension in Linux. There are a few tips and tricks you can use for this and we’ll be managing files in the Linux terminal. Read on to learn more!

As an aside, I’m thinking about doing some ‘shorts’, which would be short articles that cover a simple topic and do so concisely. If you have any thoughts on this, feel free to opine in a comment.

While Linux doesn’t necessarily care about file extensions, you’ll still often have file extensions. They’re useful for the user, as a way to visually determine a file’s usage quickly. If you see a .sh file, you can guess that it’s a script. When you see a .deb file, you can be reasonably sure it’s a package. You can assume a .png file is an image file.

Today, we’ll be using the ‘rm’ command and wildcards. We’ll be learning how to remove files by extension in the terminal. So, be prepared for that.

The ‘rm’ Command:

You won’t need to install anything for this article. You certainly won’t need to install the rm package. The rm package is a part of the core utilities. You can confirm that rm is available by entering rm --version in the terminal. (I do wish that was consistent, but it is not.)

If you don’t know, you can check the man page, to see the rm command is described like so:

rm – remove files or directories

As the goal is to remove files by extension, this seems like it’d be a good tool for the job at hand. Sure enough, it is!

Remove Files By Extension In Linux:

If you read the intro, and so few of you do, you’d know that we’re going to remove files by extension in Linux – with the terminal. So, open a terminal. More often than not, you can just press CTRL + ALT + T and your default terminal should open.

With your terminal open, the syntax is as follows:

Let’s use .deb as an example. If you want to remove all the .deb files in the folder you’re in, try this command:

The wildcard (the asterisk) means any characters can be there. You’ll remove foo.deb and bar.deb with the above command.

While that’s all there is to it, you can use wildcards for other things.

You can use a wildcard to match other patterns. If you had fle_1_foo and file_2_foo, you could remove them with this command:

If you had file_foo_1 and file_foo_2, you could remove them all with this command:

Pretty sweet, huh?

There’s more to the rm command. If you wanted to do this with folders, you’ll find that rm doesn’t do that by default. So, just add the -r flag to your command, like so:

If you’re having issues removing something with the rm command, there’s a flag you can use to force it. That flag is the -f flag and it’s used something like this:

I guess this article is more about the wildcard than it is about learning how to remove a file by extension. That’s just one way to introduce people to the concept, now that I look at it this way.

The wildcard is a pretty powerful tool in Linux, a tool that’s very useful in the terminal and while doing advanced file management. Knowing how (and when) to use a wildcard will do you well. If you have any questions, you can always ask and I’ll see if I have an answer.

Closure:

So, we’ve covered how to use a wildcard to remove a file by extension. You can do this with folders and other files, not just by extension. What you’d be doing would be pattern recognition and Linux is more than happy to help you along the way. It’s a pretty powerful tool and a tool that every Linux user should be familiar with.

Hmm… I guess 700+ words is short these days. Ah well…

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.

Meta: Happy New Year From Linux-Tips!

So, it’s the start of a new year from Linux-Tips! Hopefully, your life is going well and you have grand plans (that you’ll accomplish) in the coming year. Now is the time to make those promises to yourself, or so they say. I’ve never had much luck with New Year’s Resolutions, but you might.

Which makes me ask this:

What plans do you have for your Linux computing in the new year?

You could resolve to learn Bash scripting or spend more time in the terminal. If such is your goal, you could resolve to spend time helping your favorite project. Another goal could be learning something new throughout the year, specifically about Linux.

You could also resolve to read this site every other day by signing up for the newsletter! LOL! You could even donate to cover some of the bandwidth costs at Linux-Tips! If forums are your thing, you could head on over to Linux.org to sign up for an account. There are all sorts of things to get you started on a new year’s worth of Linux learning.

Me? I’m going to keep doing what I do. I’ll continue writing more material for Linux-Tips. I’ll continue working within the community, as I already do. I enjoy giving my time to the community and so I do.

This site? I don’t want to turn this into one of those meta articles, but we’ve experienced 61% growth in unique visitors and 69% in visits. That’s pretty sweet considering the number of people complaining about Google’s more recent updates. (I get the vast majority of my traffic from search engines, specifically Google.)

So, we’ve had a pretty good year. I’ve enjoyed watching the growth and I’ll soon be posting the 500th article (which will be a real meta article). That’s an exciting accomplishment, in my opinion. Feel free to share your opinion.

Let’s have some fun in the terminal to celebrate the new year!

Happy New Year In The Terminal:

First, we want to install Figlet (FIGlet, technically – I think). You’ll need an open terminal, but that’s often accomplished by pressing the CTRL + ALT + T buttons on your keyboard. 

With your terminal now open, follow the appropriate instructions:

Debian/Ubuntu/etc:

RHEL/CentOS/etc:

So, yeah, that’s all that I can be sure of. Your distro may have this as well.

But, when you get Figlet installed, type the following into your terminal:

You should get an output similar to this:

There… (Hit the expand button, if you must. And you probably must.)

A nice and easy way to celebrate New Year’s Day is with your Linux terminal and an application known as Figlet. You’ve learned nothing of importance. You’ve spent little time. And, well, you’ve got a holiday to celebrate or recover from. (Unless you’re on the other side of the planet, in which case this is a day late.)

HINT: Use man figlet to find the many other text formatting options. This should keep you amused for at least a few minutes. There’s more to the output than what I’ve demonstrated in a simple holiday article.

Closure:

Well, we’ve learned to use Figlet to celebrate the new year in the Linux terminal. It’s something so simple, that anyone can do it – assuming it’s in your default repositories. If it isn’t, you could try the Toilet application or you could compile the application. Both of those seem reasonably fun.

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 User Information In The Linux Terminal

There comes a time in many Linux journeys when you want to know how to show user information in the Linux terminal. Well, if you’ve been waiting for such an article, this article is for you. After all, knowing about the various users might be important information for you.

You may not realize this, but your Linux system has all sorts of users. They belong to varied groups, sometimes more than one group at a time. Unless you’re already familiar with this subject, you probably have more users than you realize. 

That’s perfectly okay. It’s entirely normal to have different users. Linux is a user-oriented operating system. Users have varied permissions and can perform different tasks based on those permissions. 

This actually shouldn’t be a complicated article. It’s just a couple of commands, though the command may not be well-known among the newer Linux users. New users should familiarize themselves with the concepts of a multi-user system and with groups.

Anyhow, you shouldn’t need to install anything. The tools we’ll be using should be installed by default. You will need an open terminal. So, you have been warned. After all, it was right there in the title!

lslogins:

The tool we’ll expose you to today is ‘lslogins‘, which should be installed by default. You can verify that lslogins is installed with this command:

And, if you check the man page (with man lslogins) you’ll see this:

lslogins – display information about known users in the system

So, sure enough, that looks like it’s the correct tool for the job. Our goal is to show user information in the Linux terminal. This looks like a good way to go about it.

Show User Information In The Linux Terminal:

Yes, we’re doing this in the terminal. You can frequently open your terminal by pressing CTRL + ALT + T. Otherwise, you’ll find a terminal emulator somewhere within your application menu. It’s likely to be in the admin section of said menu.

With your terminal open, you can start with the basics. That is, we’re going to show all the known users with the lslogins command. That syntax is so simple.

You’ve got a lot of users. You may not know it yet, but you do. Here’s an example output from my system:

Now, that’s all well and good.

But…

Let’s say you only want to show user information about one single user. That’s fine and you can do that in a variety of ways. You can also do it just as easily with the lslogins command, simply by using the -u flag. 

The syntax is as follows:

An example output might look like this:

And there’s the information about the root user. You can try with your username and get information about things like the groups you belong to and more. Go ahead and give it a shot, you won’t break anything. I promise you won’t break anything with this command!

Closure:

You never know when you’re going to want to show user information in the terminal. It is useful information, especially when debugging things like permission errors. You may find you need to add yourself to a group or things like that. So, store this command away in your mental bank and save it for when you need this information.

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.

Revisiting Christmas In The Terminal

Well, it’s the day before Christmas and a Linux Christmas can mean having Christmas in the terminal. If you do not celebrate the holiday, that’s fine. You can skip this article and move along. If you do celebrate this holiday, you might as well have a Merry Linux Christmas!

Last year, we had Christmas in the terminal. This year, we’ll be doing the same thing – but not in the same way. If you want an easier and quicker way to have Christmas in the terminal, you should follow along with the first article. This one is quite a bit more involved.

Let’s Have Christmas In The Terminal

That one is nice and easy! I’m also writing this article quite a ways ahead of time. I’ll schedule it for the nearest possible day. Due to my publication schedule, this won’t be published on the holiday itself.

NOTE: I did this on Linux Mint 21.2, Cinnamon Edition. That just happened to be the computer I was using. You may not need all of these steps if you’re using a different distro. You may already have things like Go and Git available.

We’ll be playing with all sorts of silliness and doing things we’d not normally do on this site. I’ll give clear directions, as much as I can. I won’t be diving into details like I have lately. This is a holiday article and ain’t nobody got time for that!

Linux Christmas In The Terminal:

You will need an open terminal. As I did this in Mint, I was able to open a terminal by just pressing CTRL + ALT + T which is something you too should be able to do in most distros.

With your terminal now open, let’s get into a good directory:

Next, we’ll install Git.

Then we’ll download some files with Git.

Now we move to the new directory:

This is in the language known as Go, so let’s get set up to compile that.

Now we’ll do some compilation magic.

Let that finish and run this command:

With any luck, you’ll see something like this in your terminal:

Tada! It even has blinking lights! That’s a rather festive terminal!

You can exit the program by pressing CTRL + C.

Of course, you can move the ctree file anywhere you want. If you want to just run it from the terminal, copy it to /usr/local/bin and you can do that. This being a temporary thing, I saw no reason to move the binary to a special location. If you do want to just run it anywhere in the terminal, you’d use this command:

Enjoy your holiday celebrations!

Closure:

I don’t think this can become a tradition or anything like that. There are only so many Christmas-themed things out there that you can do in the terminal. I didn’t create this and I have no idea what I’ll be able to find for the next Christmas. We’ll have to wait and see what next year brings. Until then, keep being 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 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.