Showing posts sorted by date for query unix-command-to-find-ip-address-from-hostname. Sort by relevance Show all posts
Showing posts sorted by date for query unix-command-to-find-ip-address-from-hostname. Sort by relevance Show all posts

Sunday, March 29, 2020

Unix Dominance To Discovery Ip Address From Hostname - Linux Example

IP address from hostname inwards UNIX
In this Unix ascendency tutorial, nosotros volition encounter How to discovery IP address of whatever host inwards a UNIX based system e.g. Linux, Solaris or IBM AIX. In full general hostname as well as IP address are 2 of import things nearly whatever host inwards a UNIX based network.  You ever demand either hostname or IP address to connect to whatever host. Some fourth dimension you lot desire to discovery IP address of localhost, exactly about fourth dimension IP address of exactly about other host on network etc. We convey shown exactly about techniques to find IP address from hostname inwards UNIX as well as hither nosotros volition encounter is especial listing of UNIX commands to larn IP address of localhost or host on which you lot are working along amongst whatever other host for which nosotros know hostname. 


List of UNIX ascendency to discovery IP address from hostname

Here is listing of UNIX command which tin dismiss last used to discovery IP address :

ifconfig
nslookup
hostname

ifconfig ascendency example
Let's encounter event of ifconfig ascendency to find IP address of localhost on which you lot are working :
ifconfig ascendency shows lot of information nearly diverse NIC cards inwards system, you lot tin dismiss cheque either for "inet" or "inet addr" for seeing IP address to respective NIC cards :



# /usr/sbin/ifconfig -a
inet 192.52.32.15 netmask ffffff00 broadcast 192.52.32.255

As I said ifconfig ascendency shows lot of details but I convey solely included relevant inet one, if you lot convey to a greater extent than than ane network carte du jour attached to that host, you lot may encounter to a greater extent than than ane inet address corresponding to each of them. Main drawback of ifconfig ascendency inwards UNIX is that you lot tin dismiss solely larn IP address of localhost from this command, you lot tin dismiss non larn IP address of whatever other host.

grep as well as hostname example
You tin dismiss combine grep command as well as hostname to expect IP address from /etc/hosts file. hither `hostname` volition render output of hostname ascendency as well as non bad volition hence search for that give-and-take inwards /etc/hostname. practise goodness of using `hostname` is that you lot tin dismiss exactly re-create as well as run this ascendency on whatever host without typing hostname past times yourself. This is ane of many non bad usage of grep inwards UNIX, encounter 10 ways to purpose grep ascendency inwards UNIX to discovery out why grep is ane of the most useful ascendency inwards UNIX.

# grep `hostname` /etc/hosts
192.52.32.15     nyk4035        nyk4035.unix.com

ping ascendency example
How to discovery IP address of whatever host inwards a UNIX based organization Unix ascendency to discovery IP address from hostname - Linux exampleOur patently quondam ping ascendency tin dismiss too last used to discovery IP address of localhost or whatever other host provided you lot know the hostname. ping is used to cheque wither target server is last or non but piece using amongst selection -s it too display IP address of corresponding host every bit well. Ping is genuinely ane of the of 10 useful networking ascendency inwards UNIX , encounter that link for other commands.

# ping -s `hostname`
PING nyk4035: 56 information bytes
64 bytes from nyk4035 (192.52.32.15): icmp_seq=0. time=0.186 ms

nslookup ascendency example
nslookup is ane of the principal UNIX ascendency to find IP address from hostname as well as in ane trial again from hostname to IP address. Similar to ping you lot tin dismiss too purpose nslookup ascendency to discovery IP address of both local host as well as remote host inwards whatever UNIX based system. nslookup is by as well as large available inwards most of UNIX based organization e.g. Linux, Solaris, IBM AIX or whatever other UNIX system.

# nslookup `hostname`
nyk4035.unix.com       canonical mention = nyk4035.unix.com
Name:   nyk4035.unix.com
Address: 192.52.32.15

That's all on How to discovery IP address inwards UNIX , Linux as well as other UNIX based system e.g. Solaris, IBM AIX, BSD etc. We convey seen examples of getting IP address from hostname past times using ipconfig, ping, hostname as well as nslookup command. If ane ascendency is non working inwards your machine you lot tin dismiss ever purpose other ascendency or you lot tin dismiss only cross cheque IP address past times using multiple UNIX commands.

Further Learning
Linux Command Line Basics
10 chmod ascendency event inwards UNIX as well as Linux

Wednesday, December 11, 2019

What Is Deviation Betwixt Difficult Link As Well As Soft Link Inwards Unix?

There are 2 types of links inwards UNIX system, difficult link as well as soft links, too known equally symbolic link or symlink. Though both points to around other source, in that place are a lot of departure betwixt them. difficult link is conduct pointer to the inode of the master file. If you lot compare the master file amongst the difficult link in that place won't hold upwardly whatsoever differences betwixt them. On other hand, a soft link is a file that accept the information to indicate to around other file or inode. That inode points to the information inwards the disk. Hard links are much to a greater extent than restrictive than soft links as well as that's why they are used rarely. Also non all file systems supports difficult links precisely UNIX does. Earlier Windows file organisation doesn't back upwardly soft links precisely from Windows 2000 onward they are supporting it, both Windows Vista as well as Windows vii back upwardly links now. MS DOS operating organisation doesn't back upwardly neither difficult link nor soft link. You tin utilisation ln ascendence inwards UNIX to create, update as well as take away soft links. I frequently utilisation links for laid as well as unloosen administration operate e.g. our application never points to hard-coded file or directory instead it points to links which is updated on every release.



Difference betwixt Soft link as well as Hard link inwards UNIX

Here are duad of of import differences betwixt difficult link as well as soft link inwards UNIX :


1) The target of the the difficult link must exist, which is non mandatory inwards illustration of soft link. Influenza A virus subtype H5N1 soft link is said broken if target link doesn't exists.

2) Unlike soft link which are mostly created to reference directories e.g. electrical flow link pointing to latest release, Hard links are mostly non allowed on directories.

3) One to a greater extent than critical departure betwixt soft link as well as Hard link is that difficult links are non allowed to cross partitions or volumes. Therefore, they cannot be across file systems.

4) Influenza A virus subtype H5N1 difficult link looks, as well as behaves, similar a regular file, then they tin hold upwardly difficult to find. On the other mitt soft links are quite dissimilar than regular files.

5) Influenza A virus subtype H5N1 difficult link is, for all intents as well as purposes, the same entity equally the master file. They accept the same file permissions, fourth dimension stamps, as well as then on. All attributes are identical.


Difference betwixt difficult as well as soft link is too ane of the popular Linux as well as UNIX Interview question, then knowing departure volition too aid you lot on interviews.  BTW, A moving-picture present is worth a thou words as well as this is truthful inwards connectedness amongst this image. You tin encounter that how difficult link as well as soft link are dissimilar to each other, difficult link conduct indicate to file

 There are 2 types of links inwards UNIX organisation What is departure betwixt difficult link as well as soft link inwards UNIX?



That's all near difference betwixt difficult link as well as soft link inwards UNIX. Because of these restrictions, difficult links are non used equally frequently equally symbolic links. I accept withal to notice a adept argue to utilisation difficult link precisely I accept been using soft links from long fourth dimension for starting our Java application. It's much to a greater extent than flexible to refer links inwards compaction script than difficult coded files as well as directory names.

Here are duad of to a greater extent than UNIX Interview questions as well as articles from this spider web log :
  • How produce you lot notice symbolic links inwards a directory inwards UNIX? (answer)
  • How to notice hostname from IP address inwards UNIX? (answer)
  • How to notice swap infinite as well as usage inwards Solaris? (answer)
  • How to take away empty files as well as directory inwards UNIX? (answer)
  • How to notice size of a directory including all files as well as sub-directory? (answer)

Further Learning
Linux Command Line Basics
Linux Command Line Interface (CLI) Fundamentals
Learn Linux inwards v Days as well as Level Up Your Career

Friday, November 8, 2019

Grep Ascendence Example Inward Linux - How To Search All Files Matching Specific Text

One of the most mutual chore spell working inward programming projects is finding files containing only about specific text e.g. y'all bring your application deployed inward Linux server as well as y'all are migrating your database from 1 server to another. Now, y'all desire to file all config files as well as scripts which are referencing your onetime database using the hostname or IP address, therefore that y'all tin supersede them alongside an alias. Well, y'all should ever work an alias to connect to the database or whatever other system, but sometimes it happens y'all bring to work hostname. Anyway, how create y'all uncovering all those files containing hostname inward your Linux machine? Well, the grep ascendancy is hither to assist you.

The grep command allows y'all to scan files to uncovering whatever matching text as well as y'all tin work the recursive selection of grep ascendancy to uncovering all files containing a reference to your onetime database hostnames, or specific text inward general.

You tin combine recursive selection alongside ignore instance selection (-i) to uncovering a specific text similar hostname by ignoring instance inward your config files as well as scripts.

This is the ascendancy I often work to search all files inward dissimilar sub-directories for finding reference to a specific text e.g. a hostname which is going to decommission or needs to hold upward migrated:

$ grep -iR text *

The -R selection volition recursively search files inward sub-directories starting from the electrical flow directory as well as -i volition search for the text you're render ignoring case.

Btw, if y'all are non familiar alongside basic Linux commands similar grep, find, chmod etc therefore I propose y'all to root become through a primal course of written report like Linux Command Line Basics on Udemy. This volition assist y'all to acquire to a greater extent than inward a brusque time.




The grep ascendancy to uncovering all files containing specific text inward Linux

By default grep volition impress both the matching text every bit good every bit the advert of the file containing matching text, if y'all are only interested inward file names therefore y'all tin also work the grep ascendancy alongside selection -l every bit shown below:

$ grep -iRl text *

Here is an illustration of the recursive search alongside grep ascendancy which prints both file as well as matching text as well as alone file names:

 One of the most mutual chore spell working inward programming projects is finding files contai GREP Command Example inward Linux - How to Search All Files Matching Specific Text



If y'all also desire to search for the whole word, instead of only matching a role of the text, therefore y'all drive add together selection -w, which matches the whole give-and-take like

$grep -iRlw '-Xms' *

volition search for exact "-Xms" text inward all files, it is could to uncovering the scripts where y'all are specifying your JVM arguments.

You tin also work options similar --exclude, --include, --exclude-dir, as well as --include-dir for to a greater extent than efficient as well as fast searching. For example, the next ascendancy volition alone search for text inward Java files:

$ grep --include=\*.java -iRw text *

You tin fifty-fifty work the regular expression to render for a to a greater extent than sophisticated search similar the next ascendancy volition search for specified text on .c as well as .h files

$ grep --include=\*.{c,h} -iRw text *

This ascendancy volition exclude searching all the files ending alongside .svn extension:

$ grep --exclude=*.svn -iRw '/path/to/file/' -e "pattern"


As I bring said before, It's non only of import to acquire novel commands but also novel options of the ascendancy y'all are familiar alongside to brand the most of Linux power. If y'all desire to ameliorate your Linux skills I propose y'all become through 




Important Points to Remember

1) The grep -r or -R selection is used for recursive search

2) The grep -w is used for give-and-take search i.e. it volition check to the exact word

3) The grep -i is used for ignoring instance search e..g it volition check to "Java", "JAVA", "javA" as well as other variants.

4) The grep --include is used to search alone for sure enough types of files.

5) The grep --exclude is used to exclude non-interesting files e.g. log files or .svn files.


That's all close how to search for matching text inward all files inward UNIX as well as Linux. This ascendancy is really powerful as well as 1 of the useful tool to uncovering out files referencing straight hostnames instead of aliases. They are really useful for host migrations as well as database migration. You tin fifty-fifty work them spell troubleshooting issues.


Further Learning
Linux Command Line Basics
example)
  • 10 Example of tar commands inward Unix (example)
  • 5 Example of kill commands inward Unix as well as Linux (example)
  • VI Editor examples as well as tips for beginners (example)
  • How to work the netstat ascendancy to uncovering which procedure is listening on a port? (example)
  • How does nslookup ascendancy operate inward UNIX? (answer)
  • 10 examples of lsof ascendancy inward Linux? (examples)
  • 10 books to acquire essential commands of Linux or UNIX? (list)
  • How Linux works? What Every SuperUser should know? (book)
  • 10 Examples of cURL ascendancy inward Linux? (examples)
  • How to work the CUT ascendancy inward Linux (tutorial)
  • How to move out from the telnet ascendancy inward UNIX? (example)
  • How to mail HTTP asking to telephone telephone a spider web service from the ascendancy business inward Linux? (example)

  • Thanks for reading this article therefore far. If y'all similar this article therefore delight portion alongside your friends as well as colleagues. If y'all bring whatever interrogation or feedback therefore delight drib a comment.

    P. S. - If y'all are looking only about gratis courses to acquire or ameliorate your Linux skills y'all should depository fiscal establishment check out this listing of Free Linux Courses for Programmers as well as Developers.