Tech Junkie Blog - Real World Tutorials, Happy Coding!: Linux Commands

Latest Posts

Showing posts with label Linux Commands. Show all posts
Showing posts with label Linux Commands. Show all posts

Monday, June 28, 2021

 The dig and nslookup commands are useful commands that you can use to lookup information about a network.  The dig command gives you more information about a network.  For example for my network I have a DNS server setup in it, if I wanted to display the DNS information on my server I would simply type dig masterdns.acmebanking.com and I would get the following:













As you can see it gives you a lot of information about the DNS server like the IP that the server resolves to.  However, there are times when you just want something quick and brief on what the IP resolves to. For example you might know the IP address but not the hostname or vice versa and you want to lookup the information on the part that is know that's when nslookup comes in handy.  For example let's say you know the IP address 192.168.0.15 but you don't know the hostname.  You can lookup the hostname by typing nslookup 192.168.0.15 and you would get the hostname that resolves to the IP address




Or you can lookup the IP address with the hostname by typing nslookup apps.acmebanking.com




Obviously you can get more information with the dig command but sometimes it's nice to get less information with the nslookup command.  Although it is deprecated and might not be available for your Linux distribution. So if it's not available use the dig command instead.

Monday, June 21, 2021

 The chattr command in Linux is one of the more useful commands that you've probably used but have no idea what it's use is, it just works!  That's probably the most dangerous phrase in IT.  Well just from the command you can tell that controls the file modify attribute of the file.  Well not really I mean how is chattr related to file attributes.  I guess it's change attribute.  It's pretty easy to use + means to add an attribute, - means to remove an attribute, and = means you want to assign an attribute.  You can also add attributes with the -R option to reclusively on a directory.

One of the senario I used often is when I want to make a file immutable, I'll just type chattr +i filename.  For instance if I and setting a DNS server and I don't want the DHCP scripts to change the resolv.conf file every time I restart the NetworkManager.service I would just type chattr +i /etc/resolv.conf to make the file immutable.  If I try to modify the file I would get the following error message saying I can't modify the file.



It's just as easy to make it writable again, it would just be chattr -i /etc/resolv.conf

Search This Blog