What is the Linux Equivalent to DOS Pause?

The Pause command in DOS is used to suspend execution of batch files and displays the message −

Strike a key when ready ...

Some versions of DOS also allow a comment to be entered on the same line as PAUSE.

DOS Pause Example

We can use the Pause command to suspend execution of a batch file and display a custom message like "Insert Code" −

pause Insert Code

Linux doesn't provide a built-in pause command utility by default. However, there are different approaches to achieve the same behavior as the DOS Pause command. The most common approach is using the read command.

Linux Read Command

The read command in Linux reads from a file descriptor and splits the input line into words. It can be configured to pause script execution and wait for user input.

Syntax

read [options] [name ...]

Common Read Options

Option Description
-a array Assign words read to sequential indices of the array variable
-d delim Continue until the first character of DELIM is read, rather than newline
-e Use Readline to obtain the line
-n nchars Return after reading NCHARS characters rather than waiting for newline
-p prompt Display prompt string before reading input
-r Raw mode − backslashes do not act as escape characters

Linux Equivalent to DOS Pause

The command that provides equivalent functionality to DOS Pause is −

read -n1 -r -p "Press any key to continue..." key

Flag Explanations

  • -n1 − Specifies that it only waits for a single character input

  • -r − Enables raw mode, ensuring special characters like backslash are handled properly

  • -p − Specifies the prompt message to display to the user

  • key − Variable name to store which key was pressed (optional if you don't need to know the specific key)

Alternative Methods

You can also use these simpler alternatives −

# Simple pause without storing the key
read -p "Press Enter to continue..."

# Using printf for more control
printf "Press any key to continue..." && read -n1 -s

Conclusion

While Linux doesn't have a built-in pause command like DOS, the read command with appropriate flags provides equivalent functionality. The read -n1 -r -p combination effectively pauses script execution and waits for user input, making it the perfect Linux equivalent to DOS Pause.

Updated on: 2026-03-17T09:01:38+05:30

326 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements