LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (https://www.linuxquestions.org/questions/linux-software-2/)
-   -   Using ed text editor for EMERGENCY (https://www.linuxquestions.org/questions/linux-software-2/using-ed-text-editor-for-emergency-277998/)

Echo Kilo 01-15-2005 02:36 AM

Using ed text editor for EMERGENCY
 
I need to edit my fstab so I can boot properly, but ed is the only edotor available. I've read the man pages, but can't figure it out.

I think I've deleted the line causing the error, but how do I save it and exit?

frob23 01-15-2005 02:42 AM

w
q


If you would like to make sure you hit the correct line:
1,$p
will print the whole file for you.

frob23 01-15-2005 02:46 AM

Hint, if you got the wrong one.

q
q

will quit without saving.

Then open it again and type
1,$n
Which will print all the lines with their line numbers.
This example is from an /etc/rc.conf on the live cd I am using.
Code:

1      background_dhclient="YES"
2      firewall_enable="YES"
3      firewall_type="open"
4      hostname="freesbie.livecd"
5
6      NIC="de em ixgb txp vx bfe bge dc fxp lge nge pcn re rl sf sis sk ste ti tl tx vge vr wb xl cs ed ex ep fe ie lnc sn xe an awi wi"
7
8      for i in $NIC; do
9              eval ifconfig_${i}0="DHCP"
10              eval ifconfig_${i}1="DHCP"
11      done
12
13      inetd_enable="NO"
14      moused_enable="YES"
15      saver="logo"
16      sendmail_enable="NONE"
17      sshd_enable="NO"
18      usbd_enable="YES"
19      background_fsck="YES"

If the line I wanted to delete was moused_enable="YES" I could use the number to tell ed to remove that line.
14d
Then save and exit
w
q

frob23 01-15-2005 02:49 AM

Note: it is very wise to have some passing familiarity with ed (and vi) for the very situations like this one. Even if you personally don't like to use them. There have been times when it was only my knowledge of ed which saved me from reinstalling a system which would not behave enough to use a different editor.

Echo Kilo 01-15-2005 02:50 AM

Thanks! That worked to save the fstab, but my theory didn''t fix the problem.

I mounted a drive that was plugged in via usb so that I could format it. Then I unplugged it and now it looks for it when I boot up and it says:

"no such file or directory when trying to open /dev/sda1
Failed to check file system.

RoaCh Of DisCor 01-15-2005 02:51 AM

Never used ed, but I'm sure I'm could if I had to. I always make sure pico or nano is installed. Very great easy to use in-console editors. You may want to see if you have one of them installed.

Echo Kilo 01-15-2005 02:53 AM

I guess my issue is different now so I'll start another thread....

frob23 01-15-2005 02:54 AM

What is currently in your fstab?

If you have a reference to /dev/sda1 make sure the last two columns are 0 and the one before that includes the keyword "noauto"

Echo Kilo 01-15-2005 02:58 AM

Not sure what you mean (or do that with ed)

frob23 01-15-2005 02:58 AM

Quote:

Originally posted by RoaCh Of DisCor
Never used ed, but I'm sure I'm could if I had to. I always make sure pico or nano is installed. Very great easy to use in-console editors. You may want to see if you have one of them installed.
A problem that results in the need to use ed usually means the terminal can't be defined. You may no longer have a terminal definition file or whatever. So anything that would need a terminal definition to work wouldn't load. That would include pico, nano, and even vi.

ed is not very hard and actually will be very easy to use (at least the basics) if you have any experience with EDLIN from back in the long ago days of DOS.

Nothing like a good line editor to keep it simple and make changes.

frob23 01-15-2005 03:00 AM

Quote:

Originally posted by Echo Kilo
Not sure what you mean (or do that with ed)
You don't have to do it with ed if your computer can boot beyond the point you were stuck at before.

I just want to know what is in /etc/fstab... if you could cut and paste the whole file here it might help solve the problem.

jschiwal 01-15-2005 03:09 AM

You may have 'vim-minimal' available.

frob23 01-15-2005 03:19 AM

Quote:

Originally posted by jschiwal
You may have 'vim-minimal' available.
That is possible but I am fairly certain that vim-minimal (which is installed as /bin/vi anyway) is still not going to work without any terminal definitions. Not that it really matters. If you are fairly comfortable with vi then using ed is not going to be a major issue.

Echo Kilo 01-15-2005 03:20 AM

I can't cut and paste b/c I'm on another computer.

I think I got it. I removed the line from fstab and it works!!!

frob23 01-15-2005 03:21 AM

Cool... good to know.


All times are GMT -5. The time now is 08:33 PM.