Here am I again after successfully installing Ubuntu MATE 14.04 with the help of AskUbuntu (thanks a bunch!)
What am I trying to achieve now is the following:
- Launch a Terminal with root privileges at startup
- Change the working directory to Desktop
- Execute Jar file with the "java -jar filename.jar" command
What is the easiest way to do this, preferably without installing any third parties?
EDIT: I am not only looking how to run a script at startup, but also launching a command line and executing a command.
You can spawn a bash
root shell inside a mate-terminal
instance, change the mate-terminal
's working directory to ~/Desktop
and execute your jar file inside it at startup by adding this command to Startup Applications:
mate-terminal -e "sudo -H /bin/bash -c \"cd ~/Desktop && java -jar executable.jar; /bin/bash\""
- Hit the Super key, type "Startup Applications" and hit Enter
- Name you command, type the name in the "Name" field and type the command in the "Command" field
- Click on "Save" and click on "Close"
Command breakdown:
mate-terminal -e "
: opens a" mate-terminal
instance and runs
in itsudo -H /bin/bash -c \"
: spawns a\" bash
root shell and runs
in itcd ~/Desktop && java -jar executable.jar; /bin/bash
: changes themate-terminal
's working directory to~/Desktop
, executesjava -jar executable.jar
and spawns anotherbash
root shell which will be available for further uses
No comments:
Post a Comment