The Mysterious Startup Commands
When you open the GNOME Terminal in Ubuntu and start a new session, the shell executes a series of startup scripts before presenting you with the command prompt. These scripts — primarily ~/.bashrc, ~/.profile, and /etc/bash.bashrc — can contain commands that print welcome messages, set environment variables, start background processes, or even launch graphical applications. If you have unknowingly added commands to these files (or if a software installer modified them), you may experience unexpected behaviour every time you open a terminal: a random application window appearing, a lengthy output scroll you must wait through, or environment variables being overwritten from a previous session’s debugging.
Cleaning Up Shell Startup Scripts
To stop Ubuntu from automatically executing unwanted commands every time you open a new terminal session, you must audit and edit your shell initialisation files.
Open a terminal (Ctrl + Alt + T). The primary file to inspect is ~/.bashrc. Open it with nano ~/.bashrc. Scroll through the file carefully. Look for any lines that you did not add yourself or that appear to launch applications, print excessive output, or modify environment variables in unwanted ways. Comment out suspicious lines by adding a # at the beginning of the line. Save with Ctrl + O and exit with Ctrl + X. Next, inspect ~/.profile with nano ~/.profile and apply the same review process. For system-wide startup commands, check /etc/bash.bashrc with sudo nano /etc/bash.bashrc and /etc/profile with sudo nano /etc/profile. After making changes, open a new terminal window (or run source ~/.bashrc) to test that the unwanted behaviour has stopped. If you are using Zsh instead of Bash, the equivalent file is ~/.zshrc.