 Today, we're going to quickly look how to get your IP address, both your local IP address on your local network and your public IP address that's out on the internet. Real quick, we want just the IP address, no other information, let's go ahead and give it a try. Okay, the simplest way to just, that I know of to just get your IP address, your local IP address, is to use the hostname command, hostname and then dash capital I. When you do that, it gives you your local IP address. The thing is, hostname is not on every system, where commands like ifconfig, which some will say is a little outdated, or the IP command are going to be on your system, you're going to have one of those two on pretty much every Linux system. So let's start with ifconfig, because I'm old school, we type that, it gives you a whole bunch of information about your network devices, so I have my physical ethernet which isn't plugged in right now, your loopback, which I'm going to do a video on what that is, but then right now I have my wireless adapter here, and you can see my IP address there, and that's great, but I want to get just this number, none of this other stuff. So how can I do that? And there's a whole bunch of different ways to do this. I'm going to just use a basic, some basic commands like rep and ox. So let's make this a little bit bigger so you can see it better. I'm going to say IP address, and then I'm going to grep, and if I grep for inet, it's going to narrow it down a little bit. So we have our loopback device, and then I have my IPv6 number here, and then I also have number I'm looking for. We can get rid of these IPv6's real easy, just by when I have the inet in quotation marks, adding a space here, we'll remove those ones that have the six there. So that's a simple way to do that. Next I'm going to add in an oc command, and what I'm going to say is I'm going to say print dollar sign two, oops, and then close my quotations there. That's saying print the second column. There I have my loopback and my wireless network IP address. If I wanted to get rid of the loopback, I can say grep-v, and I'm going to say get rid of that IP address, and I get just that number. That's kind of a long command, not a big deal though, because they're basic commands, grep-nock, I mean these are commands that I know off the top of my head. And if I did the same thing with IP command, I can do IPv4, so it's only going to show me IPv4, and I'm going to say A. Now I do that, and I'll get that, but it gives me the slash 24, which I may not want, so I could add in maybe a cut command. I'll cut it at the forward slash and say field one, and I get the IP address. There is another way to do it though, and I'm actually going to copy and paste this command. I'm going to, it's a grep command, but using some regular expressions, and the thing about regular expressions is it's going to make it a little bit shorter of a command. We do that, and then I can again add in this grep command here to get rid of that, actually you could probably do it all in one command, but there we go. A little bit shorter, less, definitely running less commands, but this is a lot harder to remember. But it doesn't matter whether you do it this way or this way. It seems long, but that's what aliases are for, and I need to do a whole video on aliases, but basically aliases are just shortcuts to commands. So what I would do is I would take, let's say this command right here, which is kind of long and complicated. And this is one of the great things about the shell. It doesn't matter. Computers are designed to do repetitive tasks in a simplified manner. So what I'm going to do is I'm going to say alias, and I'll give it a name. I'll just say myip, and I'm going to say equals, and then I'm going to paste in that command. Now, clear the screen, and any time I type in myip, it's going to run that series of commands. It's kind of like having a script that does it, but if the script isn't long, if it's just one line like that, an alias is super simple. Now, if you open up a new session and try to do that, it's not going to remember that alias. On your system, you have, if you're running bash, the bash rc file, or I'm running zshell. In your home directory, you're going to have a file called dot zshell rc. You go into that, it's basically a shell script. You're going to put in that line for the alias, and any time you start your shell, that alias will be there. And the same for bash, it would be bash rc. Again, I'm going to do a whole video on aliases one of these days. Okay, so we've seen the hostname command, which is short and simple. If you have hostname on there, we saw the longer commands that we aliased. What about, that's all our internal IP address. What if we want the external IP address for our modem, for our whole network? Well, there's a website there for you. And it's called ifconfigme forward slash ip. And if we just use the curl command, like so, it will give you your IP address, your external IP address. And you can do the same thing with wget, but you would want to do q for quiet capital O dash to get the output to the screen rather than a file. But it would output the same thing. So if you just remember that, and of course you can always alias that to something else, or maybe you can add it to your myip alias, where you get your both external and internal IP addresses. So again, there's lots of different ways that people would use ifconfig or the ip command and then grep or ock or use these different commands. But those are just a few options there. But my main point was to show you ways to do it and also show the importance of aliases that even though you have this long command, you can create an alias that is shorter. So that's it. I do thank you for watching. Please visit filmsbychrist.com. That's Chris of the K. There is a link in the description. And as always, I hope that you have a great day.