Telnet Command in Linux / Unix with Examples (How To)

Telnet Command in Linux / Unix with Examples (How To). In this post, we introduce Telnet, and its major advantages and then show you how to use the Telnet command examples in Linux.

Primarily, a Telnet server is a type of server application that allows users to connect and interact with the remote system from their local computer. The telnet client software enables the user to log into other computers on the same network or remotely, allowing them to access files, resources, and applications from those computers.

Let’s start with Telnet Command in Linux / Unix with Examples (How To). 

What is Telnet?

Telnet is a network protocol used to establish a two way interactive communication session between two computers. All in all, it is widely used for remote access and remote administration of network devices such as routers, switches, and firewalls. The protocol also enables users to run applications on remote computers that are connected to the same network.

With Telnet, users access resources on different networks or locations without having to physically travel to those places. Moreover, Telnet provides an easy way for users to manage their networks from any location.

It uses a virtual terminal connection and computer ports to establish a terminal connection between the local and remote machines. In turn, this enables users to access web servers, configure networks, transfer files, etc. from their local machine.

Unlike the web, Telnet allows its users to log on as regular users with access they are permitted to the specific apps and data on that computer. The user needs to provide a User ID and password to proceed further. Once the added credentials are accepted, the user gains access to the remote host.

While, Telnet is a client server application protocol that enables remote access to a server through a local computer. Then, a telnet server and client software use the telnet protocol for communication. 

It works by allowing one computer to connect to another and execute commands on it in a command line interface. This is useful for remotely managing computers anywhere in the world, providing users with access to files, programs, and configuration settings stored on a remote server.

 

Mostly programmers and individuals who need to use particular apps or data that are on a remote machine are most likely to use Telnet.

Features of Telnet

In truth, Telnet is a protocol that makes it an efficient way to communicate between two or more computers.

  • Allows users to ping a port and determine whether it is open.
  • Generates strong connections.
  • File Editing.
  • Network configuration.
  • Requires valid ID and password to access the remote host.

Advantages of Telnet

Interestingly, Telnet is used to transfer files between different computers, allowing users to share data quickly and securely. With its excellent features, Telnet enables users to access resources on remote networks with ease and confidence. Other benefits of Telnet include:

  • An important part of networking technology as it provides users with an easy way to control and manage servers across the globe.
  • Using Telnet requires no additional software or hardware installation. Only an active connection between two computers is required.
  • The greatest advantage of this software is Telnet supports itself a wide range of operating systems.
  • Some servers allow remote connections via Telnet so users access public data and play games or check the weather.
  • Allows achieving configuration components of networking hardware.
  • Facilitates task completion on various computers faster.
  • Helps to establish quick connectivity and saves the user time.
  • Used by network administrators to manage devices, machines, and other resources on a network.
  • Provides bidirectional communication capability, allowing users to interact with remote devices and applications in text format. Using plain text for transfer makes troubleshooting relatively simple.

We have reached the main part of article Telnet Command in Linux / Unix with Examples (How To).

Telnet Command in Linux / Unix with Examples (How To)

In this section, we show you how to install Telnet on Linux. We will also show you how to use the Telnet command with examples.

Install Telnet on Linux

By default, the Telnet package is included in the default repository of most Linux distributions.

For CentOS, RHEL and Fedora operating systems, you install the Telnet package using the following command.

				
					dnf install telnet telnet-server -y
				
			

After the installation, start and enable the Telnet service using the following command.

				
					systemctl start telnet.socket
systemctl enable telnet.socket
				
			

For Debian and Ubuntu operating systems, you install the Telnet package using the following command.

				
					apt install telnetd -y
				
			

After installing Telnet, start and enable the Telnet service with the following command.

				
					systemctl start inetd
systemctl enable inetd
				
			

By default, Telnet listens on port 23. Please verify it using the following command.

				
					ss -antpl | grep inetd
				
			

You should see the Telnet listening port on the following screen.

To start the Telnet session, run the following command.

				
					telnet
				
			

You should see the following shell.

				
					telnet>
				
			

Now, run the following command to get a list of all Telnet commands.

				
					telnet> h
				
			

You should see the following screen.

Verify Telnet Connection

After installing Telnet, you need to create a user for Telnet and connect it from the remote system. First, create a user for Telnet with the following command.

				
					adduser user1
				
			

Set a password as shown below:

Next, go to the remote machine and connect to the Telnet server using the following command.

				
					telnet telnet-server-ip
				
			

You will be asked to provide a username and password to connect to the Telnet server. After the successful connection, you should see the following screen.

Next, run the following command to check the memory usage of the remote server.

				
					free -m
				
			

You will get the following output.

				
					total used free shared buff/cache available
Mem: 1977 169 1305 2 503 1648
Swap: 0 0 0
				
			

Now, you can disconnect from the Telnet using the following command.

				
					exit
				
			

Check Open Port Using Telnet

The Telnet command is also used to check for an open port on the remote system. It is very useful for the network administrator to troubleshoot network or service related issues.

Suppose you want to check whether port 80 is open or not on the remote server then run the telnet command followed by server ip and port number.

				
					telnet remote-server-ip 80
				
			

If port 80 is open on the remote system, you will get the following screen.

If port 80 is closed then you will get the following screen.

To exit from the Telnet session, press Ctrl+] and type quit.

The Telnet command is also used to troubleshoot email server related issues. To connect to the email server using the Telnet server, run the following command.

				
					telnet smtp.example.com 25
				
			

You should see the following screen.

Now, type the following command to check the mail server status.

				
					EHLO smtp.example.com
				
			

If the connection is successful, you should see the following screen.

Now, type the following text to specify the sender’s email address.

				
					mail from: hitjethva@gmail.com
				
			

If your mail server functioning properly, you should see the status code 250 with the OK message on the following output.

				
					mail from: hitjethva@gmail.com
250 2.1.0 Ok
				
			

Now, type the following text to specify the recipient’s email address.

				
					rcpt to: user1@smtp.example.com
				
			

You should see the following output if the recipient’s email address is valid.

				
					rcpt to: user1@smtp.example.com
250 2.1.0 Ok

				
			

Next, you can exit from the Telnet session using the following command.

				
					quit
				
			

That is it! Thank you for reading Telnet Command in Linux / Unix with Examples (How To). We shall conclude. 

Telnet Command in Linux / Unix with Examples (How To) Conclusion

The Telnet is a networking command that allows users to access applications on remote machines through unencrypted protocols over the internet. It allows for the creation of a virtual terminal channel between two machines so they communicate with each other. This communication channel enables users to access remote computers in order to manage, configure or administer them.

Finally, the Telnet command is supported by most operating systems including the Windows platform, making it easy for regular users to use. It is used by programmers as well as network administrators to manage devices, machines, and other resources on a network. Its main advantages are its simplicity and widespread availability.

Please take a look at more Ubuntu Linux content in our blog over here.

Avatar for Hitesh Jethva
Hitesh Jethva

I am a fan of open source technology and have more than 10 years of experience working with Linux and Open Source technologies. I am one of the Linux technical writers for Cloud Infrastructure Services.

0 0 votes
Article Rating
Subscribe
Notify of
0 Comments
Most Voted
Newest Oldest
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x