I have a simple bash script which opens several terminals
#!/bin/bash
gnome-terminal -e "tail -5f /home/myuser/projects/logs/db.log" --window-with-profile=MyProfile --geometry=228x24+1920+0
gnome-terminal -e "mysql -uroot dbname" --window-with-profile=MyProfile --geometry=228x24+1920+415
gnome-terminal -e "sudo tail -5f /tmp/uwsgi.log" --window-with-profile=MyProfile --geometry=228x24+1920+835
and then I have an alias which runs the script as root:
alias openterminals='sudo /usr/local/bin/openterminals'
I do this because I want to be asked for my password only once at the beginning of the script, instead of inside every tabs, where it's required.
However, there is one problem with this approach -> if I open a new tab inside one of these terminals, it got opened as root. Is there any chance to prevent this?
PS. I know I can achieve this by removing sudo
from the alias, but I'm looking for a solution which will preserve it.
0 Answers