我想将设置RUN
为yes
,/etc/default/saned
如中所述这个答案。
以下是该文件的片段:
# Defaults for the saned initscript, from sane-utils
# Set to yes to start saned
RUN=no
# Set to the user saned should run as
RUN_AS_USER=saned
如何在 tty1 终端内编辑 saned 文件?
答案1
打开 TTY1 ( ++ Ctl)并运行此命令:Alt F1 sed
sed -i '/^RUN=no$/s/no$/yes/' /etc/default/saned
/^RUN=no$/
将匹配行RUN=no
在这一行中我们
no
用yes
s/no$/yes/
-i
选项是就地编辑文件。
测试 :
$ sed '/^RUN=no$/s/no$/yes/' /etc/default/saned
# Defaults for the saned initscript, from sane-utils
# Set to yes to start saned
RUN=yes
# Set to the user saned should run as
RUN_AS_USER=saned
答案2
Ctrl使用++切换到 tty1Alt并F1登录。
使用以下方式编辑文件
sudo nano /etc/default/saned
Ctrl+O保存,Ctrl+X离开编辑器。
或者使用下面的简短命令...
好的,@heemayl 我们有一个sed
版本,因此我们也需要一个 perl 版本=)
sudo perl -i -pe 's/(^RUN=)no/$1yes/' /etc/default/saned
例子
起始情况
% cat /etc/default/saned # Defaults for the saned initscript, from sane-utils # Set to yes to start saned RUN=no # Set to the user saned should run as RUN_AS_USER=saned aboettger-VirtualBox% perl -pe 's/(^RUN=)no/$1yes/' /etc/default/saned # Defaults for the saned initscript, from sane-utils # Set to yes to start saned RUN=no # Set to the user saned should run as RUN_AS_USER=saned
试运行
% sudo perl -pe 's/(^RUN=)no/$1yes/' /etc/default/saned # Defaults for the saned initscript, from sane-utils # Set to yes to start saned RUN=yes # Set to the user saned should run as RUN_AS_USER=saned aboettger-VirtualBox% perl -pe 's/(^RUN=)no/$1yes/' /etc/default/saned # Defaults for the saned initscript, from sane-utils # Set to yes to start saned RUN=yes # Set to the user saned should run as RUN_AS_USER=saned
替代者
% sudo perl -i -pe 's/(^RUN=)no/$1yes/' /etc/default/saned
最后的情况
% cat /etc/default/saned # Defaults for the saned initscript, from sane-utils # Set to yes to start saned RUN=yes # Set to the user saned should run as RUN_AS_USER=saned aboettger-VirtualBox% perl -pe 's/(^RUN=)no/$1yes/' /etc/default/saned # Defaults for the saned initscript, from sane-utils # Set to yes to start saned RUN=yes # Set to the user saned should run as RUN_AS_USER=saned