Article Categories
- All Categories
-
Data Structure
-
Networking
-
RDBMS
-
Operating System
-
Java
-
MS Excel
-
iOS
-
HTML
-
CSS
-
Android
-
Python
-
C Programming
-
C++
-
C#
-
MongoDB
-
MySQL
-
Javascript
-
PHP
-
Economics & Finance
How to clear console in MongoDB?
To clear the console in MongoDB shell, you can use either a keyboard shortcut or the cls command. Both methods instantly clear the terminal display, giving you a clean workspace.
Syntax
Method 1: Keyboard Shortcut
Ctrl + L
Method 2: Command
cls
Method 1: Using Ctrl + L (Recommended)
The fastest way to clear the MongoDB console is using the keyboard shortcut. Simply press Ctrl + L while in the MongoDB shell ?
This shortcut works on most operating systems and terminals.
Method 2: Using cls Command
Alternatively, type cls and press Enter to clear the console ?
> cls
After pressing Enter, the console screen will be cleared, leaving only a fresh prompt.
Key Points
-
Ctrl + Lis the fastest method and works across different platforms. -
clscommand provides the same result but requires typing. - Both methods only clear the display ? your command history remains intact.
- Use
historycommand to view previous commands even after clearing.
Conclusion
Use Ctrl + L for quick console clearing or type cls for the same result. Both methods provide a clean workspace while preserving your MongoDB session and command history.
