Does anyone remember Internet Explorer and Outlook Express on Solaris Sparc around 1998 or so? It was neat running IE on a Sparc workstation and OE was great for reading USENET. It’s too bad Microsoft discontinued support for it. Fortunately, we now have a great browser called Firefox.
Versions of Firefox 3.0.7 for Linux and OSX can be found here.
Computer world reports that the domain Linux.com has been sold by SourceForge to the Linux Foundation. The Linux Foundation has posted a press release with their intentions.
I’m still kicking myself for not going domain-registering-overboard back in the early 90’s registering all the big company domains before the big companies did.
Back in those days you could register a domain name simply by e-mailing a text file to the Internic and receive an invoice a month or two later. Wow, have times changed.
Have you ever wanted to redirect the output of a script or program to a file, but be able to view it right away? Without putting the file in the background, and then tailing the file?
The tee command allows you to do just that.
Here is how we could use it:
$ nmap 192.168.123.0/24 | tee nmap.out
Starting Nmap 4.62 ( http://nmap.org ) at 2009-03-03 21:51 CST
Interesting ports on firewall.domain.com (192.168.123.1):
Not shown: 1687 closed ports
PORT STATE SERVICE
1/tcp open tcpmux
11/tcp open systat
15/tcp open netstat
22/tcp open ssh
23/tcp open telnet
79/tcp open finger
.
.
.
Nmap done: 256 IP addresses (14 hosts up) scanned in 147.576 seconds
$ ls -l
total 6231
-rw-r–r– 1 root root 5756 2009-03-03 21:55 nmap.out
Here we tell the shell to run the nmap command, send the output to the tee command, which then displays it and writes it to a file. Tee also supports the “-a” option which will tell it to append to the filename specified if it already exists, otherwise, it will overwrite the file each time.
It’s important to note that tee only works with “stdin” and “stdout”. It does not process “stderr”. Stderr will still go to your terminal, but will not be captured in the file that tee is writing to.
Todays COTD (Command Of The Day) is the “touch” command.
The touch command is used to update the access and modification times of files. However, I see it more commonly used to create a new file. There are many times when you want to create a new file, but not actually put anything in it. For example, if you have a script that checks for the presence of a file to control some logic. In Solaris, if you “touch” a file called “/reconfigure”, it will perform a reconfiguration boot the next time you reboot the system.
Touch can also be used to update the access, or modification times, of a file. This might be useful if you are using a file’s access or modification time to see if other files are newer than this reference file.
For example:
$ touch file1
$ touch file2
$ ls -l
total 0
-rw-r–r– 1 tuz tuz 0 2009-03-02 05:07 file1
-rw-r–r– 1 tuz tuz 0 2009-03-02 05:07 file2
Here we have created two files called file1 and file2.
$ touch timestamp
$ ls -l
total 0
-rw-r–r– 1 tuz tuz 0 2009-03-02 05:07 file1
-rw-r–r– 1 tuz tuz 0 2009-03-02 05:07 file2
-rw-r–r– 1 tuz tuz 0 2009-03-02 05:09 timestamp
We now have three files. Now, lets run a find command and look for files that are newer than our timestamp file.
$ find . -cnewer timestamp
There are none found. This is no surprise. Now, lets create another new file, and then run the same find command again.
This time, find shows us the new file that is newer than the reference file. This could be handy for a number of uses. For example, you could use this to quickly find out what files have changed since the last time you created a backup of your home directory, among many other uses.
Find also has the ability to search files files that have been accessed more recently than a reference file. Please check the man page out for your local version of touch.
Some other options for touch include:
Change only the access time
Set the date/time to a user defined date/time
Change only modification time
Please check the man page for your local version of touch as some versions may be different.
The netstat command prints network connections, routing tables, interface statistics, and a bunch of other goodies that are helpful in managing any UNIX box.
One of the common uses of netstat is to show the systems routing table. This is done by the “netstat -r” command.
I add the -n on to the command as well. This tells it to not try to reverse-lookup the hostnames that go with each address. When I’m looking at a routing table, it makes more sense to see numbers anyways.
The output of this command shows that, in a general sense, there are two routes configured. One, a route for the network that this host is connected to, which says that all traffic for this network can just go out on the ethernet interface that it is connected to, and a default route. The default route is where this host should send traffic for any destination that is NOT on the network that this host is connected to. This is generally traffic going our to the Internet, but could also be another one of your networks which is behind a router.
Another use of the netstat command is the “netstat -a” command. The netstat -a command shows all listening, and non-listening sockets. This will show you TCP/IP ports that are listening on your server for incoming connections, and will also show connections that are already established.
For example:
$ netstat -an
Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address Foreign Address State
tcp 0 0 0.0.0.0:8080 0.0.0.0:* LISTEN
tcp 0 0 0.0.0.0:21 0.0.0.0:* LISTEN
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN
tcp 0 0 0.0.0.0:23 0.0.0.0:* LISTEN
tcp 0 0 0.0.0.0:25 0.0.0.0:* LISTEN
tcp 0 0 192.168.123.30:22 192.168.123.56:1558 ESTABLISHED
tcp 0 2304 192.168.123.30:22 192.168.123.51:58528 ESTABLISHED
.
In the first part of this output, we see that we have the following TCP/IP ports listening; 8080, 21, 22, 23, and 25. Also, there are two connections established from two other hosts on the network, to port 22. Port 22, as you know, is SSH. If you noticed that I also included the -n option here as well. If I you omit the -n, it will reverse-lookup the DNS hostname for the IP address as well as show you what the port is defined as being used for in the /etc/services file. For example:
$ netstat -a
Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address Foreign Address State
tcp 0 0 *:webcache *:* LISTEN
tcp 0 0 *:ftp *:* LISTEN
tcp 0 0 *:ssh *:* LISTEN
tcp 0 0 *:telnet *:* LISTEN
tcp 0 0 *:smtp *:* LISTEN
tcp 0 0 host.domain.com:ssh host.domain.com:1558 ESTABLISHED
tcp 0 832 host.domain.com:ssh host.domain.com:58528 ESTABLISHED
Keep in mind, that in the case of the ports, what name that shows up here, may not be important. Like hostnames, they reference to the /etc/services file is done for <!– @page { size: 8.5in 11in; margin: 0.79in } P { margin-bottom: 0.08in } –>convenience. This is why I generally always include the -n option with netstat.
The bottom part of this output shows Active UNIX domain sockets which we will cover in more detail later.
One other feature of netstat I use, is the “netstat -i” option. netstat -i shows you the interface statistics for all of your networking ports such as Ethernet, PPP, etc.
For example, take a look at the output from one of my firewalls:
This output shows, for each interface, statistics about the packets sent, and received. This is useful for locating collisions, and other errors that could lead to troubleshooting many things — like duplex/speed settings, etc.
Netstat has many options. I’d recommend reading the man page for your particular version of netstat. Questions? Feel free to ask via the comments page.
Welcome to COTD. Each day I am going to pick a UNIX command and spend a little time sharing a little bit about that command. I am going to call this “COTD” for “Command Of The Day”.
I may not get into every possible use of the selected command, but I am hoping to raise some awareness to some of the commands that are often forgotten about, or known about in the first place.
If you have a UNIX/Linux command you’d like to see featured here, please let me know by leaving a comment on this page.
If you work with UNIX servers that have serial consoles, and have terminals attached to each one, free up some space with a console server.
I’ve worked at companies with several hundred UNIX servers with each having their own serial attached terminal. However, there is a better solution which many companies are utilizing.
Enter the console server. Whether you have one server, or several thousand, a console server can make your life better.
There are two main uses for a serial console server.
Eliminate the need to have one serial terminal connected to each system
Provide the ability to access the console over the network (from your desk, from home at 2am, or from a beach in Cancun).
How does this work? A serial console server is a hardware device that, with the very basic configuration, has one or more serial ports as well as a network connection. The UNIX servers are connected to the serial ports, the network connection to your network, and then from any computer on the network, you can then access the console of any of your UNIX servers. Typically this is with Telnet, SSH, or via a Web Browser.
Optionally, you can also add a few serial terminals to the console server so you can just hop on a terminal, select the port (server) you want to connect to, so you don’t have to run back to your desk. You can also attach modems so you can dial-in (if everything else fails) to your console server to gain access to your consoles.
There are many more things you can do with console servers, and their usage is not limited ot just UNIX servers. Network equipment such as routers, firewalls, load-balancers, or anything with a serial console port, can also be used.
Personally, I have an older Cyclads TS-1000 (16 port serial console server) that I purchased on eBay several years ago. I use it in my lab to connect to the consoles of my servers and network gear.
Some companies that I would recommend, based on my past use, include:
Since these are serial console servers, they are best suited for UNIX hardware that have serial consoles. For PC-Based UNIX/Linux servers, that have a standard Video/Keyboard/Mouse console, a KVM is best suited for these. However, a few servers allow the console to be redirected to serial, which could allow a serial console server to be used for them as well.
O.K., this is now on my wishlist! I absolutely love seeing Linux embedded in just about everything. I just ran across this $99 Development Kit for a Linux based computer in a package about the size of a Wall-Wart.
It’s called the SheevaPlug and comes with a 1.2GHz processing, 512MB of DDR2 memory, 512MB of NAND based FLASH memory, USB, and Gigabit Ethernet.
The only thing that would be really cool, would be built-in 802.11 WIFI.
Laptop Magazine reports that one third of Dell’s Inspiron Mini 9s that have been sold are running Linux. I’m still up in the air about what netbook I’m going to go with — but it will definitely be running Linux/UNIX.
I’d really like to see a Dell Latitude line of netbooks. Inspiron, to me, just screams “consumer grade”.