You need to specify which OS you are using. I am assuming you are using Raspbian OS.
To open terminal automatically on start up, edit /home/user/.xinitrc and add the following line
exec gnome-terminal &
To run any program on starting terminal,(again, you need to specify which shell you are using. I am assuming 'bash' shell. you can know your shell by typing "echo $SHELL" in your terminal)
Bash and Its Start up File Execution Algorithm
When bash is invoked as an interactive login shell, or as a non-interactive shell with the --login option, it first reads and executes commands from the file /etc/profile, if that file exists.
After reading that file, it looks for ~/.bash_profile, ~/.bash_login, and ~/.profile, in that order, and reads and executes commands from the first one that exists and is readable. The first 2 files do not exist in my setup, so it runs ~/.profile.
When a login shell exits, bash reads and executes commands from the file ~/.bash_logout, if it exists.
When an interactive shell that is not a login shell is started, bash reads and executes commands from /etc/bash.bashrc and ~/.bashrc, if these files exist.
This may be inhibited by using the --norc option. The --rcfile file option will force bash to read and execute commands from file instead of /etc/bash.bashrc and ~/.bashrc.
Files run ... If ...
1st: /etc/profile Interactive login shell
3rd: ~/.bashrc Interactive non-login shell
Source for Bash start up execution order : http://savage.net.au/Linux/html/bash.files.html