← All commands
Topic hub Terminal & Shell Scripting
Windows Linux Terminal & Shell Scripting Expanded guide Terminal

Windows exit equivalent in Linux

Closes the current shell session or exits a script, optionally with a numeric return code.

Windows exit
→
Linux equivalents
Debian/Ubuntu same command
exit
Fedora same command
exit
Arch same command
exit

Overview

What this command does

On Windows, "exit" is used to exit the shell or return an exit code. On Linux, the closest practical mapping shown here is "exit". Closes the current shell session or exits a script, optionally with a numeric return code. This reference is grouped under Terminal & Shell Scripting → Terminal.

Migration tip: Exit codes matter in Linux. <strong>0 = success</strong>, anything else = failure. Use <code>$?</code> to check the exit code of the last command. Scripts should always exit with a meaningful code.

Windows → Linux context

What changes when you use this on Linux?

Same name, different environment

The basic command name exit is familiar on both platforms, but Linux path rules, quoting, permissions and available options can still change the result.

Portable across the compared distros

The Debian/Ubuntu, Fedora and Arch rows use the same command in this mapping. Package availability or defaults can still vary, so check the installed tool version when an option behaves differently.

Practical tasks

Common use cases

Exit the shell or return an exit code

Closes the current shell session or exits a script, optionally with a numeric return code.

exit

Exit with code 0 (success)

exit 0

Explicit success

exit 1

Exit with error code

Ready to run

Copyable Linux commands

Review paths, device names, package names and permissions before running any command.

exit
exit 0
exit 1
ls /tmp
echo $?
set -euo pipefail

Walkthrough

Examples with explanations

# Windows: exit 0
exit        # close terminal / end script
exit 0      # success
exit 1      # failure

# Check if last command succeeded:
ls /tmp
echo $?     # 0 = success

# Error-safe script header:
#!/bin/bash
set -euo pipefail

Reference

Common options and variations

Command or optionUse
exitExit with code 0 (success)
exit 0Explicit success
exit 1Exit with error code
echo $?Check exit code of last command
set -eExit script automatically on any error

Distro differences

Debian/Ubuntu vs Fedora vs Arch

Debian/Ubuntu, Fedora and Arch all use "exit" for this mapping. The command syntax shown here is portable across the three rows, although installed versions and system defaults can still vary.

DistributionPackage manager / baseEquivalent commandDifference to notice
Debian/Ubuntu same command exit Same command on this distribution.
Fedora same command exit Same command on this distribution.
Arch same command exit Same command on this distribution.

Keep learning

Related Terminal & Shell Scripting commands