Both spark-shell and pyspark have different ways to exit or quit from a shell prompt. For spark-shell use :quit
and from pyspark use quit()
to exit from the shell. Alternatively, both also support Ctrl+z
to exit.
1. Exit or Quit from Spark Shell
Like any other shell, spark-shell also provides a way to exit from the shell. When you are in shell type :quit
to come out of the shell prompt.

Alternatively, you can also use Ctrl+z
to exit from the shell.
2. Exit or Quite from PySpark Shell
Similarly to exit or quit from pyspark shell, you can use either quit()
or exit()
from shell prompt. Let’s launch the shell, run some examples and finally exit from it.

Alternatively, you can also try Ctrl+z
to exit from the pyspark shell.
Conclusion
In this quick article, you have learned how to exit or quit from the Spark and pyspark shell. To quit from the spark-shell use :quit and to quit from the pyspark shell use quit()
Happy Learning !!