如何使用Kate编辑器编辑系统文件?

分享于 

2分钟阅读

ubuntu

  繁體

问题:

我尝试使用sudo kate编辑系统文件,得到消息:

Executing Kate as root is not possible.

如何编辑系统文件?


答案1:

完成后,按常规保存,你将得到一个提示,询问系统密码,提供密码就行。


答案2:

试试 SUDO_EDITOR=kate sudo -e /path/to/the/file 这使用sudo将文件复制到临时目录,你的编辑器被非权限用户调用,当编辑器返回时(例如当它关闭时),它被复制到权限位置。

sudo -e也可以拼写为sudoedit


答案3

你可以尝试以下代码,并将它放入bash脚本中,


#!/usr/bin/env bash



#


# Enable root access to x-windows system.


#


# Motivation: Trying to run a graphical application as root via su, sudo in a 


# Wayland session (e.g. GParted or Gedit), will fail. Apps which use polkit to


# request administrator permissions for just certain operations and only when 


# needed are not affected (they are not started as root right away). 


# [1] https://bugzilla.redhat.com/show_bug.cgi?id=1274451


#


# Based on a Reddit comment.


# [2] https://www.reddit.com/r/Fedora/comments/5eb633/solution_running_graphical_app_with_sudo_in/



if (( $# != 1 )); then


 echo "Illegal number of parameters."


 echo


 echo "Usage: wsudo [command]"


 exit 1


fi



for cmd in sudo xhost; do


 if ! type -P $cmd &>/dev/null; then


 echo "$cmd it's not installed. Aborting." >&2


 exit 1


 fi


done



xhost +SI:localuser:root


sudo $1


#disable root access after application terminates


xhost -SI:localuser:root


#print access status to allow verification that root access was removed


xhost





文件  files  SYS  系统  EDI  system-f  
相关文章