A few Linux nuggets

In general, it’s a bad idea to start a file name with a dash (-). For example, a file named --help is going to give you all kinds of trouble. Say you want to rename the file. mv --help help.txt is going to show you the help for the mv command. You’ll have to give it a path name: mv ./--help help.txt.

Say you’re behind a router and you want to know your external IP address. If you have a Web browser, you can go to www.whatismyipaddress.com or one of the scads of similar sites returned by a Google search of “what is my ip address”. But from the Linux command line? The easiest one I found (i.e. the program was already installed) was using wget. The following will show you your external IP address:

wget -O - -q icanhazip.com

By the way, going to http://icanhazip.com from your browser will also tell you your IP address.

If you’re configuring a local DNS cache, you probably don’t want to include your ISP’s DNS servers in the forwarders section of named.conf.options. If you do that, then all DNS requests will be forwarded to your ISP’s DNS server. What you really want is to query the root name servers. Just leave the forwarders blank. You’ll get better performance and you won’t annoy your ISP. Here’s a properly configured forwarders section:

forwarders {
// to query the root name servers,
// don't put any IP addresses in here.
}

Running BIND on the latest Ubuntu release, the root hints file is at /etc/bind/db.root. The root servers change from time to time, so it’s a good idea to keep this file updated. You can get the latest file from ftp://ftp.internic.net/domain/. Three files appear to contain the same information: db.cache, named.cache, and named.root. You can download any one of them, copy it to your /etc/bind/ directory as db.root (after making a copy of the existing file), and then tell BIND to reload its database: sudo rndc reload.

3 comments to A few Linux nuggets

  • Steven Karp

    Many commandline tools also recognize “–” as a indicator that means “everything after this point is a filename to work on”. So your example above could also be done as
    mv — –help help.txt

  • Steven Karp

    Oh, bother. Changed my double-dashes to single.

    Should be mv -- --help help.txt

  • Jim

    Thanks, Steven. Now that you memtion it, I remember seeing that double dash thing. Too bad only “many” commandline tools recognize it. Still, it’s a handy thing to remember.

Categories

Archives

A sample text widget

Etiam pulvinar consectetur dolor sed malesuada. Ut convallis euismod dolor nec pretium. Nunc ut tristique massa.

Nam sodales mi vitae dolor ullamcorper et vulputate enim accumsan. Morbi orci magna, tincidunt vitae molestie nec, molestie at mi. Nulla nulla lorem, suscipit in posuere in, interdum non magna.