Slackware Linux Essentials - Chapter 13 Basic Network Commands
Warning: file_get_contents(http://ecs.amazonaws.com/onca/xml?Service=AWSECommerceService&AWSAccessKeyId=1TJ8QTQ6ZFCVAJ3X1T02&AssociateTag=ii0c3-20&Operation=ItemSearch&SearchIndex=Books&ResponseGroup=Small,Images&Keywords=account) [function.file-get-contents]: failed to open stream: HTTP request failed! HTTP/1.1 400 Bad Request in /home/manusia2/public_html/wp-content/plugins/amazonfeed/php/amazonfeed.class.php on line 271
A network consists of several computers connected together. The network can be as simple as a few computers connected in your home or office, or as complicated as a large university network or even the entire Internet. When your computer is part of a network, you have access to those systems either directly or through services like mail and the web.
There are a variety of networking programs that you can use. Some are handy for performing diagnostics to see if everything is working properly. Others (like mail readers and web browsers) are useful for getting your work done and staying in contact with other people.
13.1 ping
ping(8) sends an ICMP ECHO_REQUEST packet to the specified host. If the host responds, you get an ICMP packet back. Sound strange? Well, you can “ping” an IP address to see if a machine is alive. If there is no response, you know something is wrong. Here is an example conversation between two Linux users:
User A: Loki’s down again.
User B: Are you sure?
User A: Yeah, I tried pinging it, but there’s no response.
It’s instances like these that make ping a very useful day-to-day command. It provides a very quick way to see if a machine is up and connected to the network. The basic syntax is:
% ping www.slackware.com
There are, of course, several options that can be specified. Check the ping(1) man page for more information.
13.2 traceroute
Slackware’s traceroute(8) command is a very useful network diagnostic tool. traceroute displays each host that a packet travels through as it tries to reach its destination. You can see how many “hops” from the Slackware web site you are with this command:
% traceroute www.slackware.com
Each host will be displayed, along with the response times at each host. Here is an example output:
% traceroute www.slackware.com traceroute to www.slackware.com (204.216.27.13), 30 hops max, 40 byte packets 1 zuul.tdn (192.168.1.1) 0.409 ms 1.032 ms 0.303 ms 2 207.171.227.254 (207.171.227.254) 18.218 ms 32.873 ms 32.433 ms 3 border-sf-2-0-4.sirius.com (205.134.230.254) 15.662 ms 15.731 ms 16.142 ms 4 pb-nap.crl.net (198.32.128.20) 20.741 ms 23.672 ms 21.378 ms 5 E0-CRL-SFO-03-E0X0.US.CRL.NET (165.113.55.3) 22.293 ms 21.532 ms 21.29 ms 6 T1-CDROM-00-EX.US.CRL.NET (165.113.118.2) 24.544 ms 42.955 ms 58.443 ms 7 www.slackware.com (204.216.27.13) 38.115 ms 53.033 ms 48.328 ms
traceroute is similar to ping in that it uses ICMP packets. There are several options that you can specify with traceroute. These options are explained in detail in the man page.
13.3 DNS Tools
Domain Name Service (DNS for short) is that magical protocol that allows your computer to turn meaningless domain names like www.slackware.com into meaningful IP address like 64.57.102.34. Computers can’t route packets to www.slackware.com, but they can route packets to that domain name’s IP address. This gives us a convenient way to remember machines. Without DNS we’d have to keep a mental database of just what IP address belongs to what computer, and that’s assuming the IP address doesn’t change. Clearly using names for computers is better, but how do we map names to IP addresses?
13.3.1 host
host(1) can do this for us. host is used to map names to IP addresses. It is a very quick and simple utility without a lot of functions.
% host www.slackware.com www.slackware.com is an alias for slackware.com. slackware.com has address 64.57.102.34
But let’s say for some reason we want to map an IP address to a domain name; what then?
13.3.2 nslookup
nslookup is a tried and true program that has weathered the ages. nslookup has been deprecated and may be removed from future releases. There is not even a man page for this program.
% nslookup 64.57.102.34 Note: nslookup is deprecated and may be removed from future releases. Consider using the `dig' or `host' programs instead. Run nslookup with the `-sil[ent]' option to prevent this message from appearing. Server: 192.168.1.254 Address: 192.168.1.254#53 Non-authoritative answer: www.slackware.com canonical name = slackware.com. Name: slackware.com Address: 64.57.102.34
13.3.3 dig
The meanest dog in the pound, the domain information groper, dig(1) for short, is the go-to program for finding DNS information. dig can grab just about anything from a DNS server including reverse lookups, A, CNAME, MX, SP, and TXT records. dig has many command line options and if you’re not familiar with it you should read through it’s extensive man page.
% dig @192.168.1.254 www.slackware.com mx ; <<>> DiG 9.2.2 <<>> @192.168.1.254 www.slackware.com mx ;; global options: printcmd ;; Got answer: ;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 26362 ;; flags: qr rd ra; QUERY: 1, ANSWER: 2, AUTHORITY: 2, ADDITIONAL: 2 ;; QUESTION SECTION: ;www.slackware.com. IN MX ;; ANSWER SECTION: www.slackware.com. 76634 IN CNAME slackware.com. slackware.com. 86400 IN MX 1 mail.slackware.com. ;; AUTHORITY SECTION: slackware.com. 86400 IN NS ns1.cwo.com. slackware.com. 86400 IN NS ns2.cwo.com. ;; ADDITIONAL SECTION: ns1.cwo.com. 163033 IN A 64.57.100.2 ns2.cwo.com. 163033 IN A 64.57.100.3 ;; Query time: 149 msec ;; SERVER: 192.168.1.254#53(192.168.1.254) ;; WHEN: Sat Nov 6 16:59:31 2004 ;; MSG SIZE rcvd: 159
This should give you an idea how dig works. “@192.168.1.254” specifies the dns server to use. “www.slackware.com” is the domain name I am performing a lookup on, and “mx” is the type of lookup I am performing. The above query tells me that e-mail to www.slackware.com will instead be sent to mail.slackware.com for delivery.
13.4 finger
finger(1) will retrieve information about the specified user. You give finger a username or an email address and it will try to contact the necessary server and retrieve the username, office, telephone number, and other pieces of information. Here is an example:
% finger johnc@idsoftware.com
finger can return the username, mail status, phone numbers, and files referred to as “dot plan” and “dot project”. Of course, the information returned varies with each finger server. The one included with Slackware returns the following information by default:
-
Username
-
Room number
-
Home phone number
-
Work phone number
-
Login status
-
Email status
-
Contents of the .plan file in the user’s home directory
-
Contents of the .project file in the user’s home directory
The first four items can be set with the chfn command. It stores those values in the /etc/passwd file. To change the information in your .plan or .project file, just edit them with your favorite text editor. They must reside in your home directory and must be called .plan and .project.
Many users finger their own account from a remote machine to quickly see if they have new email. Or, you can see a user’s plan or current project.
Like many commands, finger has options. Check the man page for more information on what special options you can use.
13.5 telnet
Someone once stated that telnet(1) was the coolest thing he had ever seen on computers. The ability to remotely log in and do stuff on another computer is what separates Unix and Unix-like operating systems from other operating systems.
telnet allows you to log in to a computer, just as if you were sitting at the terminal. Once your username and password are verified, you are given a shell prompt. From here, you can do anything requiring a text console. Compose email, read newsgroups, move files around, and so on. If you are running X and you telnet to another machine, you can run X programs on the remote computer and display them on yours.
To login to a remote machine, use this syntax:
% telnet <hostname>
If the host responds, you will receive a login prompt. Give it your username and password. That’s it. You are now at a shell. To quit your telnet session, use either the exit command or the logout command.

telnet does not encrypt the information it sends. Everything is sent in plain text, even passwords. It is not advisable to use telnet over the Internet. Instead, consider the Secure Shell. It encrypts all traffic and is available for free.
13.5.1 The other use of telnet
Now that we have convinced you not to use the telnet protocol anymore to log into a remote machine, we’ll show you a couple of useful ways to use telnet.
You can also use the telnet command to connect to a host on a certain port.
% telnet <hostname> [port]
This can be quite handy when you quickly need to test a certain service, and you need full control over the commands, and you need to see what exactly is going on. You can interactively test or use an SMTP server, a POP3 server, an HTTP server, etc. this way.
In the next figure you’ll see how you can telnet to a HTTP server on port 80, and get some basic information from it.
Figure 13-1. Telnetting to a webserver
% telnet store.slackware.com 80 Trying 69.50.233.153... Connected to store.slackware.com. Escape character is '^]'. HEAD / HTTP/1.0 HTTP/1.1 200 OK Date: Mon, 25 Apr 2005 20:47:01 GMT Server: Apache/1.3.33 (Unix) mod_ssl/2.8.22 OpenSSL/0.9.7d Last-Modified: Fri, 18 Apr 2003 10:58:54 GMT ETag: "193424-c0-3e9fda6e" Accept-Ranges: bytes Content-Length: 192 Connection: close Content-Type: text/html Connection closed by foreign host. %
You can do the same for other plain-text protocols, as long as you know what port to connect to, and what the commands are.
13.6 The Secure shell
Today, secure shell basks in the adoration that telnet once enjoyed. ssh(1) allows one to make a connection to a remote machine and execute programs as if one were physically present; however, ssh encrypts all the data travelling between the two computers so even if others intercept the conversation, they are unable to understand it. A typical secure shell connection follows.
% ssh carrier.lizella.net -l alan The authenticity of host 'carrier.lizella.net (192.168.1.253)' can't be established. RSA key fingerprint is 0b:e2:5d:43:4c:39:4f:8c:b9:85:db:b2:fa:25:e9:9d. Are you sure you want to continue connecting (yes/no)? yes Warning: Permanently added 'carrier.lizella.net' (RSA) to the list of known hosts. Password: password Last login: Sat Nov 6 16:32:19 2004 from 192.168.1.102 Linux 2.4.26-smp. alan@carrier:~$ ls -l MANIFEST -rw-r--r-- 1 alan users 23545276 2004-10-28 20:04 MANIFEST alan@carrier:~$ exit logout Connection to carrier.lizella.net closed.
There you see me making an ssh connection to carrier.lizella.net, and checking the permissions on the MANIFEST file.
13.7 email
Electronic mail is one of the most popular things one can do on the Internet. In 1998, it was reported that more electronic mail was sent than regular mail. It is indeed common and useful.
Under Slackware, we provide a standard mail server, and several mail clients. All of the clients discussed below are text-based. A lot of Windows users may be against this, but you will find that a text based client is very convenient, especially when checking mail remotely. Fear not, there are many graphical e-mail clients such as KDE’s Kmail. If you wish to use one of those check its help menu.
13.7.1 pine
pine(1) is not elm. Or so the saying goes. The University of Washington created their program for Internet news and email out of a need for an easy mail reader for their students. pine is one of the most popular email clients in use today and is available for nearly every flavor of Unix and even Windows.
Figure 13-2. The Pine main menu

You will see a menu of commands and a row of command keys at the bottom. pine is indeed a complex program, so we will not discuss every feature about it here.
To see what’s in your inbox, type i. Your messages are listed with their date, author, and subject. Highlight the message you want and press enter to view it. Pressing r will start a reply to the message. Once you have written the response, type Ctrl+X to send it. You can press i to get back to the message listing.
If you want to delete a message, press d. It will mark the highlighted message for deletion. pine deletes the mail when you exit the program. pine also lets you store your mail in folders. You can get a listing of folders by pressing l. At the message listing, press s to save it to another folder. It will ask for the folder name to write the message to.
pine offers many, many features; you should definitely have a look at the man page for more information. It will contain the latest information about the program.
13.7.2 elm
elm(1) is another popular text-based email client. Though not quite as user friendly as pine, it’s definitely been around a lot longer.
Figure 13-3. Elm main screen

By default, you are placed in your inbox. The messages are listed with the message number, date, sender, and subject. Use the arrow keys to highlight the message you want. Press Enter to read the message.
To compose a new message, type m at the main screen. The d key will flag a message for deletion. And the r key will reply to the current message you are reading. All of these keys are displayed at the bottom of the screen with a prompt.
The man page discusses elm in more detail, so you will probably want to consult that before using elm.
13.7.3 mutt
“All mail clients suck. This one just sucks less.” mutt’s original interface was based on elm with added features found in other popular mailclients, resulting in a hybrid mutt.
Some of mutt’s features include:
-
color support
-
message threading
-
MIME and PGP/MIME support
-
pop3 and imap support
-
support for multiple mailbox formats (mbox, MMDF, MH, maildir)
-
highly customizable
Figure 13-4. Mutt main screen

if you’re looking for a mail client that will let you be in total control over everything, then you will like mutt. all the default settings can be customized, keybindings can be changed. if you like to add a macro, you can.
you probably want to take a look at the muttrc manpage, which will tell you how to configure everything. or take a look at the included example muttrc file.
13.7.4 nail
nail(1) is a command line driven mail client. It is very primitive and offers pretty much nothing in the way of user interfaces. However, mailx is handy for times when you need to quickly mail something, scripting a bulk mailer, testing your MTA installation or something similar. Note that Slackware creates symbolic links to nail at /usr/bin/mail and /usr/bin/mailx. Any of these three commands executes the same program. In fact, you will most likely see nail referred to as mail.
The basic command line is:
% mailx <subject> <to-addr>
mailx reads the message body from standard input. So you can cat a file into this command to mail it, or you can just type text and hit Ctrl+D when finished with the message.
Here is an example of mailing a program source file to another person.
% cat randomfunc.c | mail -s "Here's that function" asdf@example.net
The man page explains more of what nail can do, so you will probably want to have a look at that before using it.
13.8 Browsers
The first thing that people think about when they hear the word Internet is “surfing the net”. Or looking at websites using a web browser. This is probably by far the most popular use of the Internet for the average user.
Slackware provides popular graphical web browsers in the “XAP” series, as well as text mode browsers in the “N” series. We’ll take a quick look at some of the most common options below.
13.8.1 lynx
lynx(1) is a text-based web browser. It is a very quick way of looking up something on the Internet. Sometimes graphics just get in the way if you know exactly what you’re after.
To start lynx, just type lynx at the prompt:
% lynx
Figure 13-5. Lynx default start page

You may want to specify a site for lynx to open to:
% lynx http://www.slackware.com
lynx prints the command keys and what they do at the bottom of the screen. The up and down arrow keys move around the document, Enter selects the highlighted link, and the left arrow goes back to the previous page. Typing d will download the currently selected file. The g command brings up the Go prompt, where you can give lynx a URL to open.
There are many other commands in lynx. You can either consult the man page, or type h to get the help screen for more information.
13.8.2 links
Just like lynx, links is a textmode web browser, where you do all the navigation using the keyboard. However, when you press the Esc key, it will activate a very convenient pulldown menu on the top of the screen. This makes it very easy to use, without having to learn all the keyboard shortcuts. People who do not use a text browser every day will appreciate this feature.
links seems to have better support for both frames and tables, when compared to lynx.
Figure 13-6. Links, with the file menu open

13.8.3 wget
wget(1) is a command line utility that will download files from a specified URL. While not an actual web-browser, wget is used primarily to grab whole or partial web sites for offline viewing, or for fast download of single files from HTTP or FTP servers instead. The basic syntax is:
% wget <url>
You can also pass options. For example, this will download the Slackware web site:
% wget --recursive http://www.slackware.com
wget will create a www.slackware.com directory and store the files in there, just as the site does.
wget can also download files from FTP sites; just specify an FTP URL instead of an HTTP one.
% wget ftp://ftp.gnu.org/gnu/wget/wget-1.8.2.tar.gz --12:18:16-- ftp://ftp.gnu.org/gnu/wget/wget-1.8.2.tar.gz => `wget-1.8.2.tar.gz' Resolving ftp.gnu.org... done. Connecting to ftp.gnu.org[199.232.41.7]:21... connected. Logging in as anonymous ... Logged in! ==> SYST ... done. ==> PWD ... done. ==> TYPE I ... done. ==> CWD /gnu/wget ... done. ==> PORT ... done. ==> RETR wget-1.8.2.tar.gz ... done. Length: 1,154,648 (unauthoritative) 100%[==================================>] 1,154,648 209.55K/s ETA 00:00 12:18:23 (209.55KB/s) - `wget-1.8.2.tar.gz' saved [1154648]
wget has many more options, which make it nice for site specific scripts (web site mirroring and so forth). The man page should be consulted for more information.
13.9 FTP Clients
FTP stands for the File Transfer Protocol. It allows you to send and receive files between two computers. There is the FTP server and the FTP client. We discuss the client in this section.
For the curious, the “client” is you. The “server” is the computer that answers your FTP request and lets you login. You will download files from and upload files to the server. The client cannot accept FTP connections, it can only connect to servers.
13.9.1 ftp
To connect to an FTP server, simply run the ftp(1) command and specify the host:
% ftp <hostname> [port]
If the host is running an FTP server, it will ask for a username and password. You can log in as yourself or as “anonymous”. Anonymous FTP sites are very popular for software archives. For example, to get Slackware Linux via FTP, you must use anonymous FTP.
Once connected, you will be at the ftp> prompt. There are special commands for FTP, but they are similar to other standard commands. The following shows some of the basic commands and what they do:
Table 13-1. ftp commands
Command
Purpose
ls
List files
cd <dirname>
Change directory
bin
Set binary transfer mode
ascii
Set ASCII transfer mode
get <filename>
Download a file
put <filename>
Upload a file
hash
Toggle hash mark stats indicator
tick
Toggle byte counter indicator
prom
Toggle interactive mode for downloads
mget <mask>
Download a file or group of files; wildcards are allowed
mput <mask>
Upload a file or group of files; wildcards are allowed
quit
Log off the FTP server
You can also use some of the following commands which are quite self-explanatory: chmod, delete, rename, rmdir. For a complete list of all commands and their meaning, just type help or ? and you’ll see a complete listing on screen.
FTP is a fairly simple program to use, but lacks the user interface that many of us are used to nowadays. The man page discusses some of the command line options for ftp(1).
ftp> ls *.TXT 200 PORT command successful. 150 Opening ASCII mode data connection for /bin/ls. -rw-r--r-- 1 root 100 18606 Apr 6 2002 BOOTING.TXT -rw-r--r-- 1 root 100 10518 Jun 13 2002 COPYRIGHT.TXT -rw-r--r-- 1 root 100 602 Apr 6 2002 CRYPTO_NOTICE.TXT -rw-r--r-- 1 root 100 32431 Sep 29 02:56 FAQ.TXT -rw-r--r-- 1 root 100 499784 Mar 3 19:29 FILELIST.TXT -rw-r--r-- 1 root 100 241099 Mar 3 19:12 PACKAGES.TXT -rw-r--r-- 1 root 100 12339 Jun 19 2002 README81.TXT -rw-r--r-- 1 root 100 14826 Jun 17 2002 SPEAKUP_DOCS.TXT -rw-r--r-- 1 root 100 15434 Jun 17 2002 SPEAK_INSTALL.TXT -rw-r--r-- 1 root 100 2876 Jun 17 2002 UPGRADE.TXT 226 Transfer complete. ftp> tick Tick counter printing on (10240 bytes/tick increment). ftp> get README81.TXT local: README81.TXT remote: README81.TXT 200 PORT command successful. 150 Opening BINARY mode data connection for README81.TXT (12339 bytes). Bytes transferred: 12339 226 Transfer complete. 12339 bytes received in 0.208 secs (58 Kbytes/sec)
13.9.2 ncftp
ncftp(1) (pronounced "Nik-F-T-P") is an alternative to the traditional ftp client that comes with Slackware. It is still a text-based program, but offers many advantages over ftp, including:
-
Tab completion
-
Bookmarks file
-
More liberal wildcard uses
-
Command history
By default, ncftp will try to log in anonymously to the server you specify. You can force ncftp to present a login prompt with the “-u” option. Once logged in, you can use the same commands as in ftp, only you’ll notice a nicer interface, one that works more like bash.
ncftp /pub/linux/slackware > cd slackware-current/ Please read the file README81.TXT it was last modified on Wed Jun 19 16:24:21 2002 - 258 days ago CWD command successful. ncftp ...ware/slackware-current > ls BOOTING.TXT FAQ.TXT bootdisks/ CHECKSUMS FILELIST.TXT extra/ CHECKSUMS.asc GPG-KEY isolinux/ CHECKSUMS.md5 PACKAGES.TXT kernels/ CHECKSUMS.md5.asc PRERELEASE_NOTES pasture/ COPYING README81.TXT rootdisks/ COPYRIGHT.TXT SPEEKUP_DOCS.TXT slackware/ CRYPTO_NOTICE.TXT SPEEK_INSTALL.TXT source/ CURRENT.WARNING Slackware-HOWTO ChangeLog.txt UPGRADE.TXT ncftp ...ware/slackware-current > get README81.TXT README81.TXT: 12.29 kB 307.07 kB/s
13.10 Talking to Other People
13.10.1 wall
wall(1) is a quick way to write a message to the users on a system. The basic syntax is:
% wall [file]
This will result in the contents of [file] being displayed on the terminals of all currently logged in users. If you don’t specify a file, wall will read from standard input, so you can just type your message, and end with Ctrl+d.
wall doesn’t have many features, and apart from letting your users know that you’re about to do some serious maintenance to the system, or even reboot it, so they have time to save their work and log off
13.10.2 talk
talk(1) allows two users to chat. It splits the screen in half, horizontally. To request a chat with another user, use this command:
% talk <person> [ttyname]
Figure 13-7. Two users in a talk session

If you specify just a username, the chat request is assumed to be local, so only local users are queried. The ttyname is required if you want to ring a user on a specific terminal (if the user is logged in more than once). The required information for talk can be obtained from the w(1) command.
talk can also ring users on remote hosts. For the username you simply specify an email address. talk will try to contact that remote user on that host.
talk is somewhat limited. It only supports two users and is half-duplex.
13.10.3 ytalk
ytalk(1) is a backwards compatible replacement for talk. It comes with Slackware as the ytalk command. The syntax is similar, but has a few differences:
% ytalk <username>[#ttyname]
Figure 13-8. Two users in a ytalk session

The username and terminal are specified the same as under talk, except you must put them together with the hash mark (#).
ytalk offers several advantages:
-
It supports more than two users.
-
A menu of options that can be brought up anytime with Esc.
-
You can shell out while still in the talk session.
-
Plus more…
If you’re a server administrator, you’ll want to make sure that the ntalk port is enabled in /etc/inetd.conf. ytalk needs that to work properly.
Tags: account, Apache, archive, database, domain, domain name, email, ftp, gpg, imap, inetd, password, pop, slackware, Slackware Linux Essentials, smtp, software, ssh, ssl, telnet