3

I want to set the RUN to yes in the /etc/default/saned, as mentioned in this answer.

Here is a snippet of the file :

# 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

How can I edit the saned file from within the tty1 terminal?

3 Answers3

6

Open the TTY1 (Ctl + Alt + F1 ) and run this sed command :

sed -i '/^RUN=no$/s/no$/yes/' /etc/default/saned
  • /^RUN=no$/ will match the line RUN=no

  • On that line we are substituting no with yes by s/no$/yes/

  • -i option is to edit the file in place.

Test :

    $ 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
heemayl
  • 91,753
2

Switch to tty1 with Ctrl+Alt+F1 and login.

Edit the file with

sudo nano /etc/default/saned

Ctrl+O for save and Ctrl+X to leave the editor.


Or use the short command below …

Ok, @heemayl we have a sed version, therefore we need a perl version also =)

sudo perl -i -pe 's/(^RUN=)no/$1yes/' /etc/default/saned

Example

  • The starting situation

    % 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
    
  • The dry run

    % 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
    
  • The replacement

    % sudo perl -i -pe 's/(^RUN=)no/$1yes/' /etc/default/saned
    
  • The final situation

    % 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
    
A.B.
  • 90,397
0

Indeed you just need to use one of the text-based editors, and lucky you can find many which is installed by default.

The most known/used text based editors are:

and sure you can install tons of other text-based editors.

Now to do what you want you just need to open the file /etc/default/saned with one of your text-based editors, and then edit RUn to yes save and close.

Maythux
  • 84,289