如何创建新文件并以 root 身份编辑它?

如何创建新文件并以 root 身份编辑它?

我已经尝试过:(gksudo gedit /etc/xinetd.d/tftp这是我需要的路径)。我收到一条错误消息:

couldn't find the file /etc/xinetd.d/tftp
please check that you typed the location correctly and try again

我需要做什么?

答案1

我的 gedit 版本(2.22.3)确实会创建该文件(如果该文件不存在)。如果您没有,您可以先使用sudo touch /etc/xinetd.d/tftp.

我建议使用sudoedit /etc/xinetd.d/tftp。这使用您最喜欢的编辑器,取自EDITOR 环境变量,或者如果您没有表达您的偏好,则为系统默认值。如果需要的话添加export EDITOR=/usr/bin/gedit到您的~/.profile

也可以看看如何以系统管理员 (root) 身份运行命令

答案2

我通过 gnome-desktop-item-edit --create-new ~/Desktop 为我的桌面制作了一个新的启动器(我安装了 gnome 桌面后备)。然后输入运行命令:gksu nautilus 以 root 身份运行。

导航到我的常规主页,登录显示隐藏文件进入 Templates 文件夹,创建新文件和 newfile.php 和 newfile.html 我还编辑了这些文件并放入我通常创建的代码。

然后我复制了模板文件并导航到“root”主页并将其粘贴到那里(该文件夹丢失)现在当我以 root 身份运行 nautilus 时,我可以创建我的文件以及没有扩展名的无标题文件。然后使用 gedit 进行编辑nautilus 我用我的新启动器(gksu nautilus)以 root 身份启动

Ubuntu 14.01LTS

相关内容