LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This 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


Reply
  Search this Thread
Old 03-08-2021, 07:54 AM   #1
Bennemann
LQ Newbie
 
Registered: Mar 2021
Posts: 6

Rep: Reputation: Disabled
Terminal beim Start öffnen und befehle ausführen


Ich möchte das nach einem Start oder Restaurant ein terminal Fenster öffnet und nacheinander 3 Kommandos ausgeführt werden

crontab -e
@reboot /usr/sbin/openvpn......

Oder
https://www.raspberrypi.org/document...age/systemd.md

Hat auch nicht funktioniert

Was und wie muss ich da machen?
Mfg
 
Old 03-08-2021, 08:00 AM   #2
petelq
Member
 
Registered: Aug 2008
Location: Yorkshire
Distribution: openSUSE(Leap and Tumbleweed) and a (not so) regularly changing third and fourth
Posts: 627

Rep: Reputation: Disabled
Welcome to LQ Bennemann. This is an english only forum. I'm sure someone can translate your intro but you will need to use english for the future.
 
Old 03-08-2021, 08:05 AM   #3
Bennemann
LQ Newbie
 
Registered: Mar 2021
Posts: 6

Original Poster
Rep: Reputation: Disabled
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

crontab -e
@reboot / usr / sbin / openvpn ......

Or
https://www.raspberrypi.org/document...age/systemd.md

Didn't work either

What and how do I have to do there?
Kind regards
 
Old 03-08-2021, 08:17 AM   #4
Turbocapitalist
LQ Guru
 
Registered: Apr 2005
Distribution: Linux Mint, Devuan, OpenBSD
Posts: 7,307
Blog Entries: 3

Rep: Reputation: 3721Reputation: 3721Reputation: 3721Reputation: 3721Reputation: 3721Reputation: 3721Reputation: 3721Reputation: 3721Reputation: 3721Reputation: 3721Reputation: 3721
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.
 
Old 03-08-2021, 08:31 AM   #5
Bennemann
LQ Newbie
 
Registered: Mar 2021
Posts: 6

Original Poster
Rep: Reputation: Disabled
i have a raspberry pi Due to the ipv6 line, i have to access ipv4 via ovpn Thank you
 
Old 03-08-2021, 08:35 AM   #6
Bennemann
LQ Newbie
 
Registered: Mar 2021
Posts: 6

Original Poster
Rep: Reputation: Disabled
Thank you
 
Old 03-08-2021, 08:41 AM   #7
Turbocapitalist
LQ Guru
 
Registered: Apr 2005
Distribution: Linux Mint, Devuan, OpenBSD
Posts: 7,307
Blog Entries: 3

Rep: Reputation: 3721Reputation: 3721Reputation: 3721Reputation: 3721Reputation: 3721Reputation: 3721Reputation: 3721Reputation: 3721Reputation: 3721Reputation: 3721Reputation: 3721
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.

How familiar are you with shell scripts?

Code:
#!/bin/sh

PATH=/usr/local/bin:/usr/bin:/bin

command 1
command 2
. . .
command n

exit 0
That is the first step, if you wish to automatically run multiple commands. Then once the script is working you can look at making the .desktop file.
 
Old 03-08-2021, 08:46 AM   #8
Bennemann
LQ Newbie
 
Registered: Mar 2021
Posts: 6

Original Poster
Rep: Reputation: Disabled
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
 
Old 03-08-2021, 08:52 AM   #9
Turbocapitalist
LQ Guru
 
Registered: Apr 2005
Distribution: Linux Mint, Devuan, OpenBSD
Posts: 7,307
Blog Entries: 3

Rep: Reputation: 3721Reputation: 3721Reputation: 3721Reputation: 3721Reputation: 3721Reputation: 3721Reputation: 3721Reputation: 3721Reputation: 3721Reputation: 3721Reputation: 3721
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.
 
Old 03-08-2021, 08:53 AM   #10
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 21,842

Rep: Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308
probably you do not need a terminal, just a shell script.
 
Old 03-08-2021, 09:19 AM   #11
shruggy
Senior Member
 
Registered: Mar 2020
Posts: 3,670

Rep: Reputation: Disabled
Quote:
Originally Posted by Turbocapitalist View Post
My German language skills are weak so I am not able to find a corresponding page in German.
Here is a tutorial in German. (ubuntuusers.de)
 
Old 03-09-2021, 06:38 AM   #12
Bennemann
LQ Newbie
 
Registered: Mar 2021
Posts: 6

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by pan64 View Post
probably you do not need a terminal, just a shell script.
What must be written in the shell script?

Exec=lxterminal -e /usr/sbin/openvpn --daemon -- ???
 
Old 03-09-2021, 06:40 AM   #13
Turbocapitalist
LQ Guru
 
Registered: Apr 2005
Distribution: Linux Mint, Devuan, OpenBSD
Posts: 7,307
Blog Entries: 3

Rep: Reputation: 3721Reputation: 3721Reputation: 3721Reputation: 3721Reputation: 3721Reputation: 3721Reputation: 3721Reputation: 3721Reputation: 3721Reputation: 3721Reputation: 3721
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.
 
Old 03-10-2021, 12:54 AM   #14
MadeInGermany
Senior Member
 
Registered: Dec 2011
Location: Simplicity
Posts: 2,791

Rep: Reputation: 1201Reputation: 1201Reputation: 1201Reputation: 1201Reputation: 1201Reputation: 1201Reputation: 1201Reputation: 1201Reputation: 1201
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
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
LXer: 179 Color Schemes For Your Gtk-Based Linux Terminal (Gnome Terminal, Tilix, Xfce Terminal, More) LXer Syndicated Linux News 0 07-28-2019 04:50 AM
Compiz won't start + trying to start compiz from terminal gets errors Stevithen Linux - Desktop 7 04-03-2010 06:45 PM
Switching back to the Mandrake 9.1 desktop from terminal rdesktop terminal session marc218 Linux - General 6 02-08-2007 02:45 PM
Redirect terminal output to file AND terminal shan Linux - General 3 09-29-2006 08:36 AM
Input/output error beim Schreib-/Lesezugriff auf Streamer Tape RetroFX Linux - Hardware 2 09-16-2003 08:26 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 09:44 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration