Linux - NewbieThis Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place!
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Rep: Reputation: Disabled
Open terminal at startup and execute commands
I want a terminal window to open after a start or restaurant and 3 commands to be executed one after the other
There are several ways to start a terminal automatically after logging in. Perhaps the easiest is to put the three commands you wish to run into a shell script. Then make a .desktop file to launch that script in the terminal. See the -x or -e option for your terminal utility. Then once that works, put it in the directory ~/.config/autostart/ and log out and back in again.
Which distro is this for? There are some trivial differences between the default terminal utilities in the different distros, but although trivial there are more advantages to some than others.
Ok, then if you have the default distro, it is Raspberry Pi OS and that has xterm. That info will come in handy during the second step. The first step is making a shell script.
Yesterday I dealt with linux for the first time because I need the raspberry for an online game and after every restart I have to manually enter everything into the terminal.
try to read everything in google
Yes, each line you enter into the terminal manually can be saved in a file as script. Then once the script is made, it can be turned into a clickable icon. Once that happens it can made to run when you login even if the login is automatic like it often is on the Raspberry Pi.
The link in my previous post goes to a tutorial in English and here is another shell script tutorial. My German language skills are weak so I am not able to find a corresponding page in German.
Write the commands that you would have entered in the terminal in the file you will make into the shell script. For the details of how to then turn that into a script, see the link posted by shruggy in #11 above and the template in #4 above.
Yes, step 1 is to enter the commands in a shell script.
Make it executable (chmod 755 /path/to/scriptname) then you can directly run it.
Test it.
The last step is to make the crontab entry (crontab -e)
@reboot /path/to/scriptname
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.