Find Your Network Interface Name

There are all sorts of reasons why you might want to know your network interface name. It comes in handy with things like ‘vnstat‘, for example. In fact, I wrote an article about changing the network interface name. (There’s sometimes a reason why I write articles in the order I write ’em!)

Like I said, you may want to know this information for other purposes. In your general day-to-day computing, the network interface name is entirely unimportant. As you’ve seen from previous articles, it may come to pass that you need to know the name and this article will explain how to find that.

Anyhow, this one is quick and easy. I’m just going to show you some easy ways to find your network interface name. This should be pretty brief and simple enough.

Your Network Interface Name:

Like oh so many articles, this too requires an open terminal. Sure, there are GUI methods to find your network interface name, but we might as well do it in the terminal. So, use your keyboard and press CTRL + ALT + T. With your terminal open, you can start with:

With any luck, this should be enough. You’ll get something that looks like this:

network interface name
See the handy arrow? That’ll help! That’s the network interface that’s up and connected.

As you can see by the arrow, that’ll clue you into which connection is in use at the time. If that doesn’t work, you can also try this command:

The output from this will look similar to this:

lshw showing network interface names
A keen eye will note that there are multiple devices listed!

As you can see, that’s from a different device with a different operating system. It also relies on ‘lshw’ which you may or may not have access to.

You can also try:

Some of those commands will show the ‘lo’ connection, which is just a loopback connection and immaterial for this purpose. You can safely ignore that.

Anyhow, those will show you your network interface names. If you have more than one, it’ll happily show them all – and give you a clue as to which one is up. If you have both connected, say wireless and wired, then it will say both are up. This information isn’t very useful by itself, but it is useful for other purposes.

There are other ways, so feel free to leave a comment showing how you find your network interface name.

Closure:

See? I told you this one would be quick and easy. There’s not much to it, but it’s a useful bit of information to know and now you know that this is how you find your network interface name. It’s not much of an article, but it’s yet another in what’s hopefully a long list of ’em! They can’t all be huge pieces!

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.

Install ShellCheck So That You Can Use It Locally

If you’ve been writing shell scripts, or if you’re new to writing scripts, you may not know of ShellCheck – and you that can install ShellCheck for use locally. This means you don’t need to go online to check  your shell scripts, saving you time and effort – as well as being available offline.

If you don’t already know of ShellCheck, march your ass over there right this minute! It’s one of the greatest tools on the internet. If you’ve already read the whole linked page, you can pretty much skip this entire article! After all, it tells you how to install ShellCheck over there – and I’ll be duplicating a lot of that here.

Why am I duplicating it? Because so few people seem aware of it. So few people know this tool exists, even for online use. Time and time again, I see scripting questions that can be debugged/resolved using this wonderful ShellCheck tool.

So, like many of the articles on this site, it’s here so that we can link to this article and not have to repeat ourselves time and time again. Like much of the site, it’s meant to save time and to avoid duplicating effort!

There are other ways to use ShellCheck, such as directly in your editor. This article will not be covering those other ways, I’m simply going to tell you how to install it and use it from your terminal.

Install ShellCheck For Local Use:

Like so many of these things, you need to start with an open terminal. To do so, use your keyboard – just press CTRL + ALT + T and your default terminal should open. If it doesn’t, just open it from your application menu.

Once you have the terminal open, you can install ShellCheck. It’s available in most default repositories, so you shouldn’t have any issues installing it.

Debian/Ubuntu:

Arch/Manjaro:

Fedora:

OpenSUSE:

One of those ought to work. If not, follow the link in the second paragraph, poke around, and you’ll see that you can likely get ShellCheck installed with little or no difficulty. Worst case, you can grab the binaries and install it manually.

Using ShellCheck is even easier. You just use ‘shellcheck’ and then the path to the script. So, it’d look something like one of the following:

It’s really that easy. ShellCheck isn’t perfect and it doesn’t recognize every error, but it’ll catch a ton of beginner mistakes and typos. It’ll catch syntax issues and punctuation mistakes. It’s pretty handy and is absolutely a great tool for anyone that does any scripting at all.

Closure:

And there’s another article! This one will help you install ShellCheck, a fantastic tool for people who need to check their scripts. It’s right there in the application’s title! Really, more people need to be aware that it exists, and hopefully this article does a little something to help raise awareness.

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.

Don’t Let Applications Close When The Terminal Is Closed

You may have started an application from the terminal and noticed that those applications close when the terminal is closed. This article will help you stop that behavior. This should be a pretty basic and speedy article.

Let’s explain what I mean with a demonstration. First, open your terminal by pressing CTRL + ALT + T. Now, enter the following:

Change the ‘pcmanfm-qt’ to the file manager you use, like ‘nemo’, ‘spacefm‘, or whatever it is you use to manage files in a graphical way. Any one will do. 

Now, close the terminal that you used to open your file manager or application. When you do so, you’ll see that applications close when the terminal is closed. Well, it doesn’t have to be that way. 

Enter ‘nohup‘, a lovely tool that will let you open applications in the terminal and then make sure that those applications don’t close when the terminal is closed. The ‘nohup’ application should be installed by default on any major distro and the man page describes it like:

nohup – run a command immune to hangups, with output to a non-tty

If you check the man page, you’ll see that it has pretty much no useful flags other than help and version. So, straight away you’ll see that it’s a pretty easy application to work with.

And, with that ease in mind, I’m just gonna go straight into telling you how to use it.

Applications Close When The Terminal Is Closed:

Seeing as you already opened the terminal, let’s not mess about and just show you some uses of ‘nohup’. Let’s say you use ‘nemo’ as your file manager:

Now close the terminal. See? When you use ‘nohup’ you’ll not have applications close when the terminal is closed.

You may see the command used with an ampersand (“&”) symbol at various tutorial sites. What that does is it runs things in the background. This means it should immediately return to the command prompt after the application has opened. This only works if you’re using bash, by the way. If you use it, it looks something like this:

Anyhow, after you’ve used ‘nohup’ to open an application without the ampersand, you can also just press CTRL + C and disconnect the running application from the terminal while returning you to the command prompt. Later, when you close the terminal, you’ll find see that no longer do those applications close when the terminal is closed.

That’s about it, really. I don’t see any reason to stretch this article out by adding fluff. You’re welcome!

Closure:

There ya have it. Another article. This one will help you change the behavior, if you don’t want to have applications close when the terminal is closed. 

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: Use sudo Without A Password

It is possible to use sudo without a password. Doing so is probably a pretty bad idea for most people, but it can be done. Password-less sudo is an option that you have, but it’s one heck of a security risk.

I have pretty good physical security and the risks of someone physically accessing my devices are pretty minimal. There’s no neighbors that can access my WiFi, or anything like that. Because of this, I can, and sometimes do, set up my computers so that I don’t need to use a password when I use sudo.

I feel like I need to make this clear:

If you set it up to use sudo without a password, you’re removing a key security element. If you can use sudo without a password, so can’t someone who’d be doing so with malice aforethought. It’d be even more risky if you did this on a laptop that might get misplaced or stolen.

In short: DO NOT DO THIS (without considering the security implications).

By the way, if you don’t know what sudo is, it stands for “superuser do”. It’s what you use to temporarily elevate your permissions, to read, write, or execute administrative (or otherwise restricted) files. Basically, it turns you into an omnipotent administrator. 

Again, be careful before doing this. If it makes you an omnipotent user, it makes anyone that can access the device an omnipotent user. You have been warned. If you’re comfortable with your physical security, this is an option. It’s an option you should consider only with care and diligence. 

SUDO Without A Password:

     See Also: Generate Complex Passwords

Like so many things, this too starts in the terminal. As always, you can open your terminal with your keyboard, just press CTRL + ALT + T and your default terminal should open. Once it is open, enter the following to open the file with nano:

Arrow button yourself down to the bottom and add the following line:

Where it says “<your_username>” you change it to your username – without the brackets. So, if your username were the same as mine, you’d make a line that looks like:

The ‘kgiii’ is lowercase, and your username will be lowercase. If, for some reason, you don’t actually know your username, you can find it with:

Anyhow, after you’ve added that line, you can save the file. As we’re using nano, you save it by pressing CTRL + X, then Y, and then ENTER

That should get you sorted and you should now be able to use sudo without a password. If you are aware of the security implications, this may just be something you want to do. On the other hand, it’s not exactly taxing to type your password.

Closure:

And, once again, you have another article! I’ve reached the point where I have a small buffer. I could be offline for a few days and articles will still publish themselves. I’m hoping to get even further ahead, so we shall see how it goes.

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 Have Some Fun With Cowsay And Fortune

Today, we’ll be having fun with ‘cowsay’ and doing so while getting your fortune in your terminal. Why not? Linux doesn’t always have to be about work. Today’s article will be not even remotely useful for work and none of what you learn will greatly increase your Linux skills. We are doing this for fun, mostly.

Sometimes, it’s okay to be a little silly and to have some fun.

Besides, you’ll get to use the | (pipe) and that’s always fun! Seriously, the pipe is one of the best tools Linux has. It lets you take the output from one command and use it in another one. The man page helpfully describes it like this:

pipe – Postfix delivery to external command

We’ll just be scratching the surface with pipe, so be sure to run man pipe if you’re unfamiliar with it. Pipe hails from Unix and has been with us, in one form or another, since 1973. I dare say that the longevity is good evidence of the value.

I’m just going to give the directions for Debian/Ubuntu/derivatives. I haven’t checked across all the systems, so I’m not sure what distros this will work on. Probably all of the major distros, but it should work on anything with Debian in its lineage. If you’re not doing so, you should still be able to follow along and just adapt it to your package management systems. 

So, that being said and done, let’s look into this matter of a mad world with cows and fortunes.

Fun With Cowsay:

The first thing we have to do is open a terminal. Press CTRL + ALT + T on your keyboard and the default terminal emulator should open up. Once open, run the following command:

That should install both ‘cowsay‘ and ‘fortune‘, along with any dependencies that need to be satisfied. Those are the only two tools you need to install for this exercise, or at least they should be.

Fortune:

Fortune is a tool that outputs fortunes from a database. A normal use would be:

That should happily output a fortune for you.

Cowsay:

The cowsay application prints a graphic that looks vaguely cow-like and any text you tell it to print. The command would look a bit like this:

All of which is all well and good – but the magic is when you put them together. So, let’s try that. Let’s pipe fortune output to the cowsay application:

Which will have an output similar to this:

cowsay in action
See? You’ve got a cow spouting wisdom in the terminal! Just what you always wanted!

That’s not it! No, dear reader, that is not it! That’s not all you can do! See, you can change the cow to Tux, the Linux penguin mascot.

What the penguin has to do with a cow, I know not. But, I do know that you can use the command and output a penguin. 

The output from that command should look pretty similar to this:

cowsay goes tux
See? It’s Tux! I wouldn’t make this sort of stuff up. It’s too important!

And there you have it. You’ve successfully piped the output from fortune to cowsay and, as a bonus, morphed the cow into tux. Another productive day at the office, while having fun with cowsay!

Closure:

I’ve got a couple of articles ahead, which is nice. This one tells you how to have fun with cowsay, which is also nice. It’s pretty important business!

Now to write some that are scheduled years in the future (so that I don’t mistakenly post them and they’re out of the way) and not fret too much when Mother Nature comes to claim my internet… I’m not giving up on my publishing schedule yet!

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.