LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Networking
User Name
Password
Linux - Networking This forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.

Notices


Reply
  Search this Thread
Old 01-05-2011, 03:01 PM   #1
readydave
LQ Newbie
 
Registered: Dec 2008
Location: Florida
Distribution: Ubuntu 10.10
Posts: 6

Rep: Reputation: 0
How To: Create a Linux Script to display DNS and IP Address Information


So I have been playing with Linux consistently for a couple of months now. I've been a Windows sys. admin for most of my career, so Linux is pretty strange for me. I started off with computers way back with the TRS-80 and then eventually moved to DOS systems. So the command line interface (CLI) of Linux was not completely alien to me, yet my lack of knowledge on the syntax and commands is holding me back. I have come a long way.

Recently I needed to play around with some DNS settings and one of the commands I used frequently in Windows, IPCONFIG /ALL, doesn't have a direct relative that displayed the same information. If you run ifconfig, it doesn't return the DNS servers you are currently using. You have to run a separate command to retrieve that information.

What I have done is created a super simple script that displays the network information for my primary LAN adapter, which is ETH0 in my case. After that, it shows the domain and name server information. Then it pauses for 20 seconds before closing the terminal window.

Here are the contents of the script file:

ifconfig -a eth0
cat /etc/resolv.conf
sleep 20


I simply right-clicked the Linux desktop, choose Create Document, Empty File. I named it something like Network Info. Then I opened it and put this information in it, saved it, and closed it. I renamed the file and added a .sh extension to the end which makes it into a script file. Next, right-click the script and go to properties. In the Permissions tab, check the box next to Execute: Allow executing file as a program. Then click close.

To run the script, just double-click the icon and then click Run In Terminal at the prompt. The terminal window opens, displays the information, and exits after 20 seconds. If you need it longer than that or need a different interface (such as wlan0 for your wireless), you can change or even add that in.

This was all done in Ubuntu 10.10.

I know it is very simple and very straight forward and welcome thoughts and feedback about simpler ways to do this. For me, the old-school Windows admin, it's a baby step in the right direction. I am really enjoying learning the Linux OS.
Cheers!
 
Old 01-05-2011, 03:31 PM   #2
markush
Senior Member
 
Registered: Apr 2007
Location: Germany
Distribution: Slackware
Posts: 3,979

Rep: Reputation: Disabled
Quote:
Originally Posted by readydave View Post
I know it is very simple and very straight forward
No, this is not straight forward and not simple. Don't try to carry your Windows-knowledge to the Linux world.

One thing is: the Linux-commandline (here bash in a terminal) is much more powerful than the dosshell.

I'd recommend to read this: http://linux.oneandoneis2.org/LNW.htm
and this: http://tldp.org/LDP/abs/html/

Why don't you execute your script on the commandline?

Note: I'm a Windows-admin as well, but I would be lost without my Linux-laptop in a network where I can check many things from the commandline in a short amount of time.
When I write batchfiles for a Windows-server, I do it on a Linux-computer since here I have the powerful tools to get my work done.

About your script: it will not work in most cases! it depends on the Windowmanagers configuration (which options with rightclick you have).

Markus
 
Old 01-05-2011, 03:54 PM   #3
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,417

Rep: Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985
Sorry, but that's nuts. Last week someone else posted a similar 'ipconfig replacement' script, and as above... Why?? Just learn linux properly, and don't try to lie to yourself.

I'd also suggest that ipconfig is a stupid command in itself, a arbitrary assortment of slightly related data, with a few noddy actions tagged on for luck.

Last edited by acid_kewpie; 01-05-2011 at 04:02 PM.
 
Old 01-06-2011, 06:18 AM   #4
readydave
LQ Newbie
 
Registered: Dec 2008
Location: Florida
Distribution: Ubuntu 10.10
Posts: 6

Original Poster
Rep: Reputation: 0
Hi guys,

Thanks for the feedback and the links. Like I said, I am just getting to learn it. As I have time at work, I have been playing around and using it on my laptop. I haven't read any books or gone through any courses, but I do plan to learn it "properly". Just finding the time is hard right now. I think switching from Windows to Linux is akin to learning a foreign language. Take the word house for example. In Engligh, it's house. In Spanish, it is casa. If I were speaking Spanish, I wouldn't think what is the translated word for house and then speak it. I would just say casa, because it is a casa, not a house. Clear as mud I know, but I do understand what you mean by learn it properly.

In the meantime though, if I want to keep using Linux and getting used to the UI and all of that, I'll have to look things up online and find good reference to get information in a pinch. Sometimes scripts like that, though not very efficient, at least get me the information I need in a quick moment. It lets me keep myself in Linux rather that running to a Window box to get that same info. Would you guys rather I didn't try at all? Markus, I definitely want to get to the point where you are now. I manage an organization that has more than 20 locations in 8 states - all Windows based. I know the power that Linux has, especially with networking, hence my desire to learn. Thanks again for the comments guys. I'll keep learning, I promise.
Dave

Last edited by readydave; 01-06-2011 at 06:20 AM.
 
Old 01-06-2011, 09:03 AM   #5
markush
Senior Member
 
Registered: Apr 2007
Location: Germany
Distribution: Slackware
Posts: 3,979

Rep: Reputation: Disabled
Hello readydave,

if you really want to learn Linux, do yourself a favour and install Slackware instead of Ubuntu.

Slackware is a great distribution for learningpurposes and is the most "unixlike" distribution. You'll find a very knowledgeable and helpful community here in the forum: http://www.linuxquestions.org/questions/slackware-14/
Read this: http://www.linuxquestions.org/questi...ations-852376/ and this thread http://www.linuxquestions.org/questi...ckware-852890/

Good luck

Markus
 
Old 01-06-2011, 09:23 AM   #6
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,417

Rep: Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985
Quote:
Originally Posted by markush View Post
Hello readydave,

if you really want to learn Linux, do yourself a favour and install Slackware instead of Ubuntu.

Slackware is a great distribution for learningpurposes and is the most "unixlike" distribution. You'll find a very knowledgeable and helpful community here in the forum: http://www.linuxquestions.org/questions/slackware-14/
Read this: http://www.linuxquestions.org/questi...ations-852376/ and this thread http://www.linuxquestions.org/questi...ckware-852890/

Good luck

Markus
Ubuntu is fine and will teach you plenty. Also more likely to find Ubuntu in enterprise compared to Slackware. Personal preference doesn't equate to good advice always.
 
Old 01-06-2011, 09:51 AM   #7
markush
Senior Member
 
Registered: Apr 2007
Location: Germany
Distribution: Slackware
Posts: 3,979

Rep: Reputation: Disabled
Hello acid_kewpie,

I don't intend to say that Ubuntu is not a good distribution.
Quote:
Originally Posted by acid_kewpie View Post
... Personal preference doesn't equate to good advice always.
Well, personal preference maybe, but when I compare the knowledge of the people here in the forums I see that the most of the Slackware-users seem to have more the ability to understand their systems than Ubuntu-users do. I know that this is partially due to the fact that many newbies try Ubuntu as their first distribution, but I've also read the threads about Slackware-user's occupations and how they came to Slackware (the links in my post). And so I feel that Slackware is more suitable when it comes to learn the basics of Linux.

Quote:
more likely to find Ubuntu in enterprise compared to Slackware
you're right. But my experience is that I can easily transfer my Slackware-knowledge to other distributions which often is very helpful.

Markus
 
Old 01-06-2011, 10:02 AM   #8
lazlow
Senior Member
 
Registered: Jan 2006
Posts: 4,363

Rep: Reputation: 172Reputation: 172
readydave

You hit the nail on the head with your language analogy. You are just at that stage where you are still thinking Enlgish(windows) and trying to translate in your head to speak Spainish(Linux). As you well know, that does not work very well. Give it some time and practice and you will be thinking in Linux, after that life becomes much simpler. As far as the script goes, good job. Most new users never learn to write scripts at all.

If you are serious about eventually being in a Linux business environment you may(after six months or so) want to switch to one of the distros that a significant number of businesses run. People will probably scream about this, but RHEL(Red Hat Enterprise Linux) is pretty much the gold standard of the Linux business class. Unfortunately RHEL charges a subscription fee for support and access to updates. Fortunately Centos is RHEL with the proprietary bits(mostly logos) stripped out. It is free to install and update. With a five year plus support life you will not have to reinstall every year(like a lot of other distros). Any book, hardware, software, or information in gerneral about RHEL applies equally well to Centos.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Need to create script that gives me network computer information. rahilmaknojia Programming 4 10-28-2009 01:23 PM
Create a script to display file name, Inode, and size of any file. Has to be a script JaxsunApex Linux - Newbie 7 01-29-2007 08:15 PM
How to create Dial up connection with IP address in Linux? Nishant Desai Linux - Networking 3 11-24-2006 12:23 AM
How To Create DNS in LINUX saqib389 LinuxQuestions.org Member Intro 2 10-31-2006 03:08 PM
Linux DHCP information for DNS tisource Linux - Networking 5 10-31-2004 06:47 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Networking

All times are GMT -5. The time now is 10:10 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration