Thursday, May 2, 2024
 Popular · Latest · Hot · Upcoming
1
rated 0 times [  1] [ 0]  / answers: 1 / hits: 8004  / 2 Years ago, fri, july 8, 2022, 4:35:23

I want to open a folder in desktop as root and install .jar file in that folder.



I have a ".jar" file in desktop that I need to open it as root user but I want to copy that file into a folder in desktop and then open it as root user. How can I access .jar file in that folder via terminal?



How can I do that?


More From » root

 Answers
0

If I understand correctly this is what you have:



~/Desktop/freedom-folder:
freedom.jar
<other files>


And you want to run freedom.jar as root.






If you want to do it via the terminal



Just open the terminal (Ctrl+Alt+T) then



cd ~/Desktop/freedom-folder
sudo java -jar freedom.jar





If you want to have a launcher for yourfreedom in the Dash



1: Open a terminal



Run the following commands:



mkdir  ~/bin
cp ~/Desktop/freedom-folder/freedom.jar ~/bin
sudo apt-get install gksu


The first two lines will create a folder called bin in your home folder and
move your .jar file into it. The last line is to install gksu a GUI frontend for su.



2: Open GEdit Text Editor



Write the following script:



#!/bin/sh

gksudo java -jar ~/bin/freedom.jar


Save it to the bin folder you've created in your home folder. I will assume you've named this script as freedom-as-root without any file extensions.



Now, still in GEdit, click File -> Open... (or click the folder icon). In the file selection dialog, navigate to your home folder and type Ctrl+H to make the hidden files visible. Open .bashrc. Go to the last line of this file and add the following new line:



PATH="$PATH:$HOME/bin"


Save it. (This line in ~/.bashrc adds ~/bin to the search path for executables.)



Create a new file and add the following to it:



[Desktop Entry]
Name=Your Freedom (with root privileges)
Icon=/home/your-username/.icons/freedom.svg
Exec=/home/your-username/bin/freedom-as-root
Type=Application
Terminal=false
StartupNotify=true
Categories=Network;


Save it in your home folder as freedom-as-root.desktop. (Instead of your-username make sure to type your actual username!)



3: Open a terminal again



Before, opening the terminal download this icon, by clicking the image and Save as... or the like. Save it as freedom.svg to your home folder.



(If you wish you can get some other free/libre icon from the internet, Wikipedia is a good source for these.)



Go to a terminal again and type:



chmod  +x  ~/bin/freedom-as-root
mkdir ~/.icons
mv ~/freedom.svg ~/.icons
mkdir ~/.local/share/applications
mv ~/freedom-as-root.desktop ~/.local/share/applications


4: See if this worked



Just open the Dash and type your freedom to see if there were any problems.
The icon should appear in the Dash, and when you click it gksu should ask for your password.



Due to an extra step in part (2), now you can also type freedom-as-root in the terminal and it will be enough to run yourfreedom with privileges.



Hope it helps.


[#30538] Saturday, July 9, 2022, 2 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
nstitutencert

Total Points: 171
Total Questions: 126
Total Answers: 124

Location: Azerbaijan
Member since Fri, May 12, 2023
1 Year ago
;