Netbeans将root设置为作者

时间:2018-09-16 01:21:19

标签: java linux netbeans linuxmint

我正在运行Linux Mint 18.3肉桂64位

我刚刚下载了Apache NetBeans IDE 9.0

不需要运行任何脚本来安装它,我只需要运行以下命令来启动它:sudo /opt/netbeans/bin/netbeans 然后输入我的密码,netbeans打开。 然后,我为该程序启动了一个启动器,因为我不想每次打开netbeans时都键入命令和密码。 但是发射器没有工作。 我意识到我没有在启动程序要执行的命令中放入“ sudo”,所以我将其放入。而且没有用。

我认为它不起作用,因为启动器执行了sudo /opt/netbeans/bin/netbeans,但是没有输入密码。 经过一番研究,我最终在star_man ALL=(ALL) NOPASSWD: /opt/netbeans/bin/netbeans的末尾添加了/etc/sudoers,终于可以了。但是当我创建一个新项目时,Netbeans将root设置为它创建的每个文件的作者。

例如,当我在项目目录中键入ls -l时,将输出以下内容:

-rw-r--r-- 1 root root 3527 sep 15 20:01 build.xml
-rw-r--r-- 1 root root   82 sep 15 20:01 manifest.mf
drwxr-xr-x 3 root root 4096 sep 15 20:01 nbproject
drwxr-xr-x 3 root root 4096 sep 15 20:01 src

根是组,每个文件的所有者是目录。

这导致Netbeans生成文档文件时,将“ root”代替我的用户名。

更新: 我只能以根用户身份启动neatbeans(sudo ./netbeans)。

当我在终端上没有sudo的情况下运行neatbean时,它看起来像是在开始:screen shot

但随后关闭。

这是输出:

>Log Session: Sunday, September 16, 2018 at 12:58:20 PM Eastern Daylight Time
>System Info: 
  Product Version         = Apache NetBeans IDE 9.0 (Build incubator-netbeans-release-334-on-20180708)
  Operating System        = Linux version 4.15.0-34-generic running on amd64
  Java; VM; Vendor        = 10.0.1; Java HotSpot(TM) 64-Bit Server VM 10.0.1+10; Oracle Corporation
  Runtime                 = Java(TM) SE Runtime Environment 10.0.1+10
  Java Home               = /opt/java/jdk-10.0.1
  System Locale; Encoding = es_DO (nb); UTF-8
  Home Directory          = /home/star_man
  Current Directory       = /opt/netbeans
  User Directory          = /home/star_man/.netbeans/9.0
  Cache Directory         = /home/star_man/.cache/netbeans/9.0
  Installation            = /opt/netbeans/nb
                            /opt/netbeans/ide
                            /opt/netbeans/extide
                            /opt/netbeans/java
                            /opt/netbeans/apisupport
                            /opt/netbeans/websvccommon
                            /opt/netbeans/profiler
                            /opt/netbeans/harness
                            /opt/netbeans/javafx
                            /opt/netbeans/platform
  Boot & Ext. Classpath   = 
  Application Classpath   = /opt/netbeans/platform/lib/boot.jar:/opt/netbeans/platform/lib/org-openide-modules.jar:/opt/netbeans/platform/lib/org-openide-util.jar:/opt/netbeans/platform/lib/org-openide-util-lookup.jar:/opt/netbeans/platform/lib/org-openide-util-ui.jar
  Startup Classpath       = /opt/netbeans/platform/core/core-base.jar:/opt/netbeans/platform/core/org-netbeans-libs-asm.jar:/opt/netbeans/platform/core/asm-all-5.0.1.jar:/opt/netbeans/platform/core/org-openide-filesystems.jar:/opt/netbeans/platform/core/org-openide-filesystems-compat8.jar:/opt/netbeans/platform/core/core.jar:/opt/netbeans/nb/core/org-netbeans-upgrader.jar:/opt/netbeans/nb/core/locale/core_nb.jar
-------------------------------------------------------------------------------
INFO [org.netbeans.modules.netbinox]: Install area set to file:/opt/netbeans/
!SESSION 2018-09-16 12:58:21.698 -----------------------------------------------
eclipse.buildId=unknown
java.version=10.0.1
java.vendor=Oracle Corporation
BootLoader constants: OS=linux, ARCH=x86_64, WS=gtk, NL=es_DO

!ENTRY org.eclipse.osgi 4 0 2018-09-16 12:58:21.706
!MESSAGE Error reading configuration: Permission denied
!STACK 0
java.io.IOException: Permission denied
    at java.base/java.io.UnixFileSystem.createFileExclusively(Native Method)
    at java.base/java.io.File.createTempFile(File.java:2090)
    at org.eclipse.osgi.storagemanager.StorageManager.initializeInstanceFile(StorageManager.java:188)
    at org.eclipse.osgi.storagemanager.StorageManager.open(StorageManager.java:708)
    at org.eclipse.osgi.internal.baseadaptor.BaseStorage.initFileManager(BaseStorage.java:226)
    at org.eclipse.osgi.internal.baseadaptor.BaseStorage.initialize(BaseStorage.java:160)
    at org.eclipse.osgi.baseadaptor.BaseAdaptor.initializeStorage(BaseAdaptor.java:123)
    at org.eclipse.osgi.framework.internal.core.Framework.<init>(Framework.java:192)
    at org.eclipse.osgi.framework.internal.core.EquinoxLauncher.internalInit(EquinoxLauncher.java:67)
    at org.eclipse.osgi.framework.internal.core.EquinoxLauncher.init(EquinoxLauncher.java:37)
    at org.eclipse.osgi.launch.Equinox.init(Equinox.java:178)
    at org.netbeans.modules.netbinox.Netbinox.init(Netbinox.java:61)
    at org.netbeans.core.netigso.Netigso.prepare(Netigso.java:145)
    at org.netbeans.NetigsoHandle.turnOn(NetigsoHandle.java:115)
    at org.netbeans.ModuleManager.enable(ModuleManager.java:1331)
    at org.netbeans.ModuleManager.enable(ModuleManager.java:1148)
    at org.netbeans.core.startup.ModuleList.installNew(ModuleList.java:315)
    at org.netbeans.core.startup.ModuleList.trigger(ModuleList.java:251)
    at org.netbeans.core.startup.ModuleSystem.restore(ModuleSystem.java:276)
    at org.netbeans.core.startup.Main.getModuleSystem(Main.java:156)
    at org.netbeans.core.startup.Main.getModuleSystem(Main.java:125)
    at org.netbeans.core.startup.Main.start(Main.java:282)
    at org.netbeans.core.startup.TopThreadGroup.run(TopThreadGroup.java:98)
    at java.base/java.lang.Thread.run(Thread.java:844)
java.lang.RuntimeException: Permission denied
    at org.eclipse.osgi.framework.internal.core.Framework.<init>(Framework.java:194)
    at org.eclipse.osgi.framework.internal.core.EquinoxLauncher.internalInit(EquinoxLauncher.java:67)
    at org.eclipse.osgi.framework.internal.core.EquinoxLauncher.init(EquinoxLauncher.java:37)
    at org.eclipse.osgi.launch.Equinox.init(Equinox.java:178)
    at org.netbeans.modules.netbinox.Netbinox.init(Netbinox.java:61)
    at org.netbeans.core.netigso.Netigso.prepare(Netigso.java:145)
    at org.netbeans.NetigsoHandle.turnOn(NetigsoHandle.java:115)
    at org.netbeans.ModuleManager.enable(ModuleManager.java:1331)
    at org.netbeans.ModuleManager.enable(ModuleManager.java:1148)
    at org.netbeans.core.startup.ModuleList.installNew(ModuleList.java:315)
    at org.netbeans.core.startup.ModuleList.trigger(ModuleList.java:251)
    at org.netbeans.core.startup.ModuleSystem.restore(ModuleSystem.java:276)
    at org.netbeans.core.startup.Main.getModuleSystem(Main.java:156)
    at org.netbeans.core.startup.Main.getModuleSystem(Main.java:125)
    at org.netbeans.core.startup.Main.start(Main.java:282)
    at org.netbeans.core.startup.TopThreadGroup.run(TopThreadGroup.java:98)
    at java.base/java.lang.Thread.run(Thread.java:844)
Caused by: java.io.IOException: Permission denied
    at java.base/java.io.UnixFileSystem.createFileExclusively(Native Method)
    at java.base/java.io.File.createTempFile(File.java:2090)
    at org.eclipse.osgi.storagemanager.StorageManager.initializeInstanceFile(StorageManager.java:188)
    at org.eclipse.osgi.storagemanager.StorageManager.open(StorageManager.java:708)
    at org.eclipse.osgi.internal.baseadaptor.BaseStorage.initFileManager(BaseStorage.java:226)
    at org.eclipse.osgi.internal.baseadaptor.BaseStorage.initialize(BaseStorage.java:160)
    at org.eclipse.osgi.baseadaptor.BaseAdaptor.initializeStorage(BaseAdaptor.java:123)
    at org.eclipse.osgi.framework.internal.core.Framework.<init>(Framework.java:192)
    ... 16 more

我发现~/.netbeans下的每个文件和目录都具有root作为所有者和组。我以为可能是问题所在,所以我用~/.netbeans $ sudo chown -R myusername: .netbeans/更改了所有者和群组。而且我仍然只能以root身份运行netbeans。

1 个答案:

答案 0 :(得分:0)

这是一个基本的Unix权限问题。

出于逃避我的原因,您使用sudo启动了netbeans IDE。
  -你不应该那样做的。
  -您不必需要来做到这一点!

使用sudo运行某些程序时,通常以root用户身份运行。 (sudo就是这样做的!)

因此,自然地,某些东西(在这种情况下,使用netbeans运行的sudo应用程序)将创建“ root”用户拥有的文件和目录。因此,当您尝试以普通用户身份对其进行更新时,操作系统会显示“不,您不拥有这些文件/目录,因此无法对其进行修改。”

解决方案:使用chown命令根据需要更改文件和目录的所有权。

如何?阅读man chown,或寻找有关如何更改文件所有权的教程。

  • 提示:进行加...时,您将需要使用sudo
  • 提示2:使用sudo时要非常小心,因为如果发生错误,sudo会破坏系统。