gpt4 book ai didi

java - Netbeans 将 root 设置为作者

转载 作者:太空宇宙 更新时间:2023-11-04 05:13:33 25 4
gpt4 key购买 nike

我正在运行 Linux Mint 18.3 cinnamon 64 位

我刚刚下载了 Apache NetBeans IDE 9.0

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

我认为它不起作用,因为启动器执行 sudo/opt/netbeans/bin/netbeans 但不输入密码。经过一番研究,我最终在 /etc/sudoers 末尾添加 star_man ALL=(ALL) NOPASSWD:/opt/netbeans/bin/netbeans ,它终于起作用了。但是当我创建一个新项目时,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”代替我的用户名。

更新:我只能以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。

最佳答案

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

由于我不明白的原因,您使用 sudo 启动 netbeans IDE。
- 你不应该那样做。
- 你不应该需要这样做!

当您使用 sudo 运行某些内容时,您通常以 root 用户身份运行。 (这就是 sudo 的作用!)

因此,自然地,某些东西(在本例中,使用 sudo 运行的 netbeans 应用程序)将创建“root”用户拥有的文件和目录。因此,当您尝试以普通用户身份更新它们时,操作系统会说“不:您不拥有这些文件/目录,因此您无法修改它们。”。

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

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

  • 提示:当 chowning 时,您需要使用 sudo ...
  • 提示 2:使用 sudo 时要非常非常小心,因为如果您犯了错误,sudo 有能力毁掉您的系统。

关于java - Netbeans 将 root 设置为作者,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52350187/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com