Open In App

agetty command in Linux with Examples

Last Updated : 15 Oct, 2024
Comments
Improve
Suggest changes
Like Article
Like
Report

agetty is a Linux version of getty. getty short for "get tty" is a Unix program running on a host computer that manages physical or virtual terminals to allow multi-user access. Linux provides a virtual terminal(tty) which is similar to the regular Linux terminal. agetty command opens a virtual terminal(tty port), prompts for a login name, and invokes the /bin/login command. 

Syntax

agetty [options] port [baud_rate...] [term]

where,

  • port: It is a pathname relative to the /dev directory. If a "-" is specified, then this command considers that its standard input is already connected to a tty port and that a connection to a remote user has already been established.
  • baud_rate, ...: It is a comma-separated list of one or more baud rates. It should be specified in the descending order.
  • term: It is the value to be used for the TERM environment variable.

Common Options used with the agetty command

OptionDescription
-8--8bitsAssume 8-bit tty, meaning full 8-bit data transmission.
-a--autologinAutomatically logs in the specified user without a password prompt.
-c--noresetDo not reset control mode upon start.
-E--remoteAllows passing a hostname to login for remote connections (e.g., via telnetd).
-h--flow-controlEnables hardware flow control using CTS/RTS handshaking for smoother communication.
-i--noissueDo not display the issue file (custom login message).
-J--noclearDo not clear the screen before displaying the login prompt.
-m--extract-baudExtract the baud rate from the terminal device during connection.
-n--skip-loginSkip the login prompt and go directly to session (useful for auto-login setups).
-p--login-pauseWait for the user to press any key before showing the login prompt.
-R--hangupPerform a virtual hangup (vhangup) to disconnect the specified terminal.
-s--keep-baudAttempt to keep the previously used baud rate for the terminal connection.
-t--timeoutSets a timeout (in seconds) to terminate the session if the login prompt is not completed in time.
-U--detect-caseDetect uppercase-only terminals and adjust login accordingly.
--helpDisplay a help message with a list of all available options.
--versionDisplay the current version of the agetty command.

For more details about the options you can run the following command on the terminal: 

agetty --help
agetty --help


Linux agetty command Examples

1. agetty -8 - linux 

  • -8 option for 8-bit tty.
  • '-' for specifies that standard input is already connected to a tty port.
  • baud rate is optional so not used here.
  • 'linux' is value of TERM environment variable.
agetty -8 - linux 


2. agetty -8 -t 5 - linux 

  • -t 5 is the login process timeout.
agetty -8 -t 5 - linux


3. agetty -h -t 60 tty 9600 vtxxx 

  • tty refers to the device /dev/tty.
  • 9600 is the bits per second bound rate.
  • vtxxx is the TERM environment variable to indicate that a VTxxx terminal is connecting, in the previous example 'linux' is used as TERM env.
  • -h activates CTS/RTS handshaking (flow control).
  • -t 60 allows 60 seconds for someone to attempt to log in before the modem is hung up.
agetty -h -t 60 tty 9600 vtxxx


4. agetty -a -h -t 60 tty 9600 vt102 

  • -a specifies autologin.
agetty -a -h -t 60 tty 9600 vt102 

5. agetty --version

To display the version information. 

agetty --version

6. agetty -a -h -t 60 -U -s -m tty 9600 vt100 

  • -U detects the uppercase terminal.
  • -s try to use existing baud rate.
  • -m use exact baud rate specified in the command.
agetty -a -h -t 60 -U -s -m tty 9600 vt100

Conclusion

The agetty command is an essential tool for managing terminal sessions in Linux, particularly for embedded systems, servers, and environments requiring serial connections. With its numerous options, such as autologin, flow control, timeout settings, and baud rate management, agetty provides robust control over terminal and user session management.


Next Article
Article Tags :

Similar Reads