Linux open folder as root

How to access a folder as root?

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?

Why do you think you need root privileges for that? You can create the folder, write a script which runs something like java -jar file.jar (make the script executable), and then add the folder (which contaings your script) to your PATH in ~/.bashrc .

What you describe should not need root privileges. Please edit your question and explain why. What do you mean by install .jar file? What happens when you type java -jar file.jar or sudo java -jar file.jar ?

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.

3 Answers 3

cd your-directory cp path-to-jar/file.jar ./ sudo -k 

then you can do it graphically. That said, why do you think you need to be root to install a jar in you own home folder?

It makes sure that you have to type your password again next time you use sudo ( just to be safe actually).

I use this command to open .jar file in desktop:1) cd ~/Desktop 2)~/Desktop$ sudo java -jar freedom.jar. But I want to copy .jar file to folder in desktop, and then open it as root.

This is the proper answer to the original question. But you @Alex, may wish to reword your question in order to say what you mention in your last comment: You «want to copy .jar file to folder in desktop, and then open it as root». We must say that copying the file as root WON’T allow you to open it as root by simply double clicking on it. Your original question seems different than your actual needs.

Читайте также:  Linux file path php

ok. I have an antifilter program with Yourfreedom name (freedom.jar). I need to run freedom.jar file as root to enabling ECHO mode in the yourfreedom configuration. My .jar file is in desktop, but I have copied the .jar file into a folder in desktop and now I want to open .jar file via terminal as root.

If I understand correctly this is what you have:

~/Desktop/freedom-folder: freedom.jar

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:

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.

Читайте также:  Hp laserjet pro p1102 linux

(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.

Источник

How do I open a folder as root?

To open the folder as root in the grapical file manager, run the following command:

If you wish to do your operations from the command line, the following command enters the intended directory and makes you root. However, you would be better off using the first method above.

sudo -i is less typing and cleaner environmental variables ubuntuforums.org/showpost.php?p=6188826&postcount=4

I disagree with SirCharlo that first method is better than using command line. Command line is way more powerfull.

sudo apt-get install nautilus-admin 

Open Nautilus and you’ll see an option Open as Administrator option in the context menu of every directory.

Didn’t seem to work in 18.04.2, although I see the context menu I’m unable to delete locked folders. Back to terminal I go.

To install Open-as-Administrator in Ubuntu open Terminal (Press Ctrl+Alt+T) and copy the following commands in the terminal:

sudo add-apt-repository ppa:noobslab/apps sudo apt-get update sudo apt-get install open-as-administrator 

After installation type this command to restart Nautilus:

enter image description here

sudo apt-get install -y nautilus-admin 

Nah ! do a simple thing first. Create a custom file manager. Its easy.

First open gedit and paste all these:

[Desktop Entry] Name=Nautilus Comment=Browse the filesystem with administrator rights Exec=gksudo nautilus Icon=file-manager Terminal=false Type=Application Categories=Application;System; 

Now save the file as Nautilus.desktop on your desktop.

(desktop is the file extension).

 /home/your user name/.local/share/applications 

and cut/paste Nautilus.desktop file into there.

Now open dash and search for «Nautilus». It will open up the default file manager with root permission. Now you can navigate to any directory and delete anything you want.

Источник

How to open Ubuntu file manager as root user

By default, the File Manager in Ubuntu or in any other Linux distro uses a non-root user. I mean a user that doesn’t have Administrative rights can access them graphically. It improves overall system security. However, if you want to run File manager as the root user or want to open & edit files and folder with administrative rights that are possible as well. However, you have to use the command terminal to enable that. The following tutorial carried out on Ubuntu 20.04 LTS focal fossa. However, the steps will be the same for earlier versions such as Ubuntu 19.10/19.04; 18.10/18.04 including Debian, Linux Mint, or any similar OS running Nautilus File manager.

Читайте также:  What is linux slab

Open Ubuntu Nautilus File Manager as root

Open command terminal in Ubuntu -min

  1. Open command terminal either from Applications or using keyboard shortcut- Ctrl+Alt+T.

  2. Run Nautilus file manager with sudo. Here is the syntax:
  • It will ask for your current non-root user’s password that is present in the sudo group.
    Run Nautilus as root-min
  • Ubuntu File manager will open under administrative rights. Now you can navigate to any folder and files that can only be accessed by the root user via the graphical user interface.Using File Manager as administrative -min
  • Edit or Open Ubuntu Files and Folders as root Administrative

    If you want to edit any file or open folder as root user directly from the Nautilus file manager’s graphical user interface. Then, we can embed an option “Edit as Administrator” or “Open as Administrator” privileges in its contextual menu.

    1. Again open command terminal, if you already have not.
    2. Install the Nautilus Admin package.
    sudo apt install nautilus-admin
  • Type exit and hit the Enter key to close the Terminal window.Install Nautilus Admin to access file manager as root-min
  • Now, to edit any file as the root user, open file manager, or right-click on that particular wherever it resides. And select the option “Edit as Administrator”.Edit File as root in Ubuntu Nautilus File manager-min
  • To open folders as root, same just like above right click on that and select “Open as Administrator’.Open Folder as root in Ubuntu file manager-min
  • Warning: Running File Manager as Admin

    Although, the above tutorial is useful in case you are not a well-experienced command terminal user, however, be cautious. Make sure you wouldn’t alter or edit some core configuration files that could leave your Ubuntu unstable or un-bootable.

    Источник

    Оцените статью
    Adblock
    detector