How To: Show Your Network Interfaces

Today’s article will be fairly simple, where we learn a couple of ways how to show your network interfaces. It won’t be a very long article, nor will it be all that complicated. Like almost always, today’s article will involve the terminal. So, if you want to learn how to show your network interfaces, read on!

A network interface is what’s used to connect your computer to a network. Depending on your configuration, you may have both real and virtual network interfaces. The real network interfaces will be things like your ethernet (the wired connection to the network) and a wireless device (a radio-controlled network interface).

There are times when you’ll want to know your network interface, be it for debugging or monitoring. For example, you’ll probably want to know about your network interfaces if you’re playing around with VNStat.

We’ve probably touched on this subject in a few articles. However, we might as well have an article specifically answering the question of how to show your network interfaces. Well, then, that’s what this article will cover.

Show Your Network Interfaces:

As mentioned in the intro, we’re going to be using the terminal. If you’re a regular reader, you’re probably used to it and a little tired of the same old text. Not all my readers are going to be as proficient, so they should know that they can just press CTRL + ALT + T and your default terminal should open.

With your terminal now open, your next step mostly depends on your chosen distro and the age of the default installed tools. If you’re using an older distro, you can go with this command:

If you’re using a distro with more current tools, you will likely find that ‘ifconfig’ has been deprecated, that is no longer current and in use. For you folks, you’ll need a slightly longer command:

So, if you want to show your network interfaces, one of those two commands will likely get you there. You should check the information carefully, to make sure you’re using the correct information, such as when you want to use a network interface name for another command.

Closure:

There you have it… You have another article! This time, we’ve decided to spend some time learning how to show your network interfaces. It’s nothing complicated, but it’s still useful information. It is indeed a fairly short and simple article, but that means newer users can follow along – which is a good thing. I’m sure there are other ways to gather this information, but one of those two commands should do the trick!

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: Return To The Previous Working Directory In The Terminal

Today is another easy day, but one that should be productive, where we’ll learn how to return to the previous working directory. It will be a short article, but you might find it useful. If nothing else, we’re making the more terminal accessible to new users. 

These Linux tips needed to be shared some time, so it might as well be now. I don’t wish to air my medical issues, but my ailment has gone on long enough and I went to a medical professional this morning. I’m sure I’ll be fine. They say only the good die young, so I’m probably gonna live forever!

Anyhow, to learn how to return to the previous working directory (in the terminal, of course), read on! I promise, it’s easy. It’s one simple command and that’s all there is to it.

Return To The Previous Working 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.

This is probably more useful for very-nested directories with long names, but it won’t take that to demonstrate today’s subject. It’s not terribly complicated.

Let’s say that you’ve navigated to ~/foo and performed some functions there. Next, you’ve navigated to ~/bar and performed some functions there. Now, if you want to return to the ~/foo directory you can do so with just a simple – added to your cd command, like so:

If that’s confusing, I’ve made an image that explains it better than I can…

use cd - to return to the previous working directory
It’s a simple concept. It’s a simple article about how to return to the previous working directory.

See? It’s nice and simple! If you were in one directory and left to go to a new directory, then it’s trivial to return to the previous working directory. The image should help make it clear if my description is lacking.

You might also be interested in:

Let’s Learn About Absolute And Relative Paths
How To: Find Your Present Working Directory
How To: Make A Directory In Linux

(There are a whole lot of articles with the word ‘directory’ in them!)

Closure:

I know… I know… This is a lot of short articles in a row. I’ll feel better. I’m sure of it! Amusingly, I was asked if I had any stress in my life and it was comforting to answer that I do not. My life is pretty drama free, but I do need to get an article out every other day! This time, I’ve shown you a quick and easy way to return to the previous working directory. It’s quick, easy, and effective!

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.

Navigate To The Start Or End Of The Line (In The Terminal)

Today is going to be another simple article, where you learn to navigate to the start or end of the line – in the terminal, of course. I’ve had some abdominal issues, so it seems like a good day for yet another accessible article.

Even though it’s an easy article, there will be many Linux users who don’t know this information. I’m not even sure how to describe it, thus the unwieldy article headline. So, if you want to navigate to the start or end of the line in the terminal, I’ll show you how.

This being Linux, there are so many ways to do this sort of stuff…

Imagine this:

You’re using Ubuntu and you want to update from within the terminal. So, you’ve typed the following:

Well, as you can see, the first instance of ‘sudo’ was spelled wrong – it’s missing a letter. You can reach over there and find the arrow buttons, navigate back to the start of the line, and fix it. Or, you can do the following:

Navigate To The Start Or End Of The Line:

As the title indicates, this is in the terminal. As such, you’ll need an open terminal to try this out. Just press CTRL + ALT + T and your default terminal should open.

With your terminal now open, why don’t we just use that line from above:

Of course, you could just look at your keyboard and (probably) use the HOME button to navigate to the start of the line. Of course, you could then use the END button to navigate to the end of the line. If you’re on a laptop, those keys can be placed most anywhere, though it’s far more standardized with a regular keyboard.

But, you don’t have to reach for those lines. Nope. That is not necessary. You can keep your eyes right on the screen. How so?

Well, it’s this easy:

To navigate to the start of the line, press CTRL + A.

To navigate to the end of the line, press CTRL + E.

Tada! You don’t have to root around for the home or end buttons. You don’t have to fuss with the arrow buttons. You can quickly and easily navigate to the start and end of the line with just those two keyboard shortcuts. I told you that it’d be quick and easy!

Closure:

There you have it, you have another article. This one is pretty simple but that’s okay. So long as it’s sharing some knowledge and I managed to get an article out on schedule, it’s all good by me. This time, you’ve learned how to navigate to the start of end of the line – in the terminal and without taking your eyes off the screen.

You might as well memorize the shortcuts as they appear to be pretty universal from my testing. They’ll likely be faster for you than any of the other methods, so they’re worth learning and adding to your growing toolbox of Linux tools. Ideally, my ailments will go away soon… I’m hopeful…

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.

Clear The Terminal

Today’s article will be a nice and easy article, where we learn how to clear the terminal. That is, we will clear any typed text and returned information from the terminal. This will be a nice and quick article.

I am feeling like garbage today and I still need to edit the last article. Ugh… But, the show must go on!

This is what I get for not having scheduled a few articles ahead. Fortunately, I have short articles in mind. Today is a good day for just that.

It should be noted that clearing the screen doesn’t delete your scrollback history. Someone could come along and use the up arrow to see your previously typed commands. If you’re at your workstation then I guess you could consider this a privacy measure – but it certainly shouldn’t be considered much of a security measure.

So, as I said, it’ll be a short article. Let’s just jump into it…

Clear The Terminal:

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.

Now, let’s generate some content… Run the following:

That should fill up your terminal with stuff. Now, let’s clear the terminal. Type the following command:

Tada!

But wait, there’s more!

Run those commands again. This time, and this appears to be pretty universal, just use your keyboard and press CTRL + L.

See? It does the same thing as you get when you type clear. Those are two ways for you to use when you want to clear the terminal.

Closure:

Yup… You’ve learned how to clear the terminal. I told you that it’d be a short article. It’s even an easy article. Now I’m going to lie down and hope for a nap. 

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 Specific Terminal Commands

In today’s article, we’re going to learn how to disable specific terminal commands. It’ll be an interesting article because we get to explore some different tools. It might get a bit verbose, but I’ll do my best! It’s going to be a long article, but I’ll try to keep it at under 1500 words.

It should be noted that this is for people using the bash shell. As I don’t sway too far in that direction, I can’t vouch for it working with something like ZSH or similar. I simply haven’t tested. Feel free to try. I know some of the shell alternatives are compatible so you can check.

Read on to learn how to disable specific terminal commands!

Let’s say you don’t want your computer users (or you yourself)  to run a command in the terminal. Well, you can stop that command from being run easily enough. To do this, we’ll explore some new concepts and tools. One of those topics is ‘aliases’. Let’s just start there…

About Bash Aliases:

In short, bash aliases are alternate ways to enter in a terminal command. You type one thing and the system interprets it as an alias for another command. Let me explain this bit further.

Let’s say you want to run the following command:

Well, if you wanted to, you could assign an alias for those commands. If you wanted, you could even change your aliases so that all you had to type is:

You’ll run the full command when you’ve entered the alias. Aliases are basically little shortcuts to other commands, often used when you want to enter the command quickly and it’s a longer command. You can more or less alias anything with anything if you put enough effort into it.

Getting Ready For Aliases

Still with me? Alright, now you need 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 now open, let’s check to see if you already have the necessary file. I am aware that you can just add aliases to your ~/.bashrc file, but this way avoids clutter and is more easily portable.

So, we need to check to see if you have ~/.bash_aliases. You can run the following command (from your home directory) to see if you already have the file you need. Simply run:

Now, scan the output from that command. Do you see a .bash_aliases? If so, skip ahead. If not, you will need to create the file yourself. One way to do so is by using the following command:

That command will create a blank file (named .bash_aliases) in your ~/ directory. It is the only file we needed to create and will be the only file we need to edit. You’ll also use nano, which my readers should be familiar with already. Don’t close your terminal yet, we’re still going to need it in the following section.

With just a few tools, we’ll learn how to stop specific terminal commands.

So then…

Disable Specific Terminal Commands:

I had to write that giant intro just to get a newbie up to speed. I’ve been meaning to explain aliases for a while, but I suspect the topic will get its own dedicated article. It’s a pretty broad subject.

For this next session, we’ll use a harmless ‘uptime’ command. Let’s just run that in the terminal just once:

Now, for whatever reason, we will have to pretend that you have decided you want to disable specific terminal commands and uptime is one of those commands. To do that, you’ll start with the following, editing the file you just created:

You will want to start a new line and the command is formatted like so:

For example, you can have an alias like this one:

Save the file with nano. It’s not too daunting a task to save the file. To save a file in nano, all you need to do is press CTRL + X, then Y, and then ENTER

In the above example, if you were to type ‘myip’ into the terminal and run it, it’d almost run the command you told it to run.

You’re almost there. There’d be just another step.

You’ll have to reload the aliases before the system recognizes it as such. I’ll explain how to do that in a second.

Now, if you want to disable specific terminal commands all you need to do is fill the <command> section with a blank space or two. As it is our example, we don’t want the user running this uptime command, it’d look like this:

See? Not all that complicated and we’re almost reaching the end – just one step further and your new alias will work as you’d expect – or not work, as one would expect in this case.

Make Your Alias Permanent:

First, to make that alias stick around you need to have saved the updated ~/.bash_aliases file as was explained above. At this point, the alias will not work. The file you wrote isn’t loaded into memory. It takes a bit more than that.

From here, you could close all your open terminals, log out and back, or reboot – any of those will reload your bash aliases. Alternatively, you can run the following command, which will refresh your terminal’s list of aliases. Like so:

If you’ve done everything properly, you’ll find that this happens when you try to next run the uptime command:

the user is unable to run a specific command - in this case the uptime commnd
That’ll teach ’em from trying to run that pesky uptime command! Catastrophe averted!

But…

If you want to disable specific terminal commands, you might be wanting to do so for security reasons. The ~/.bash_aliases file is owned by the user, so the user can just edit the .bash_aliases file to remove your edit.

So, what can you do? You can make it permanent for everyone. You can add it to /etc/.bashrc, and a user with limited rights won’t be able to edit the file. If they can’t edit the file, they won’t be able to remove the alias. They won’t be able to use the terminal command(s) you’ve aliased to nothing. If you were to simply edit the /etc/bash.bashrc you’d just start a new line at the bottom and then insert the aliases using the same format. 

I haven’t tested it, but I’d wonder if /etc/.bash_aliases might also do the trick in preventing user edits to override your changes. Feel free to test and then let us know. It’d be interesting if you could do something with /etc/skel/ and changing the file permissions – effectively for new users created.

Closure:

There… I think I’ve covered everything. I’ve wanted to write about the bash aliases subject for a while, but it’s just a bit complicated to explain. So, I figured I’d write this article. It’s a long one, but there’s a whole lot to cover. This goes into it pretty heavily, but an aliases-specific article might be nice to have.

Either way, you can now disable specific terminal commands. You can probably temporarily lock yourself out of your own system, so be careful with what aliases you add as system-wide aliases.

If you do lock yourself out, you should be able to boot to a live Linux disk where you’ll mount the drive and just revert your changes. But, anyone with physical access to your computer owns your computer, which is worth keeping in mind.

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.