LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices

Reply
 
Search this Thread
Old 04-21-2003, 03:50 AM   #1
ludwig W
Member
 
Registered: Mar 2003
Posts: 404

Rep: Reputation: 30
how to edit a file when not in X (ie from the command line)


Just wondeing how one can edit a file from the command line,when not in X
I know how to show the contents of the file on the console ( #more filename) but how can I edit and save the changes ?


cheers
Ludwig
 
Old 04-21-2003, 03:53 AM   #2
XavierP
Moderator
 
Registered: Nov 2002
Location: Kent, England
Distribution: Lubuntu
Posts: 19,174
Blog Entries: 4

Rep: Reputation: 428Reputation: 428Reputation: 428Reputation: 428Reputation: 428
You need to use a text editor - eg pico /folder/subfolder/filename or vi or whatever your text editor is.

Which file do you need to edit? If it's xf86config to enable your NVidia drivers I found it easier to edit the file first and then to drop into a console to install the driver.
 
Old 04-21-2003, 03:55 AM   #3
ludwig W
Member
 
Registered: Mar 2003
Posts: 404

Original Poster
Rep: Reputation: 30
so from the command line,what would I type to edit a file?

I want to edit a file whilst not in X.

Cheers
Ludwig

Last edited by ludwig W; 04-21-2003 at 03:56 AM.
 
Old 04-21-2003, 03:58 AM   #4
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,376

Rep: Reputation: 1962Reputation: 1962Reputation: 1962Reputation: 1962Reputation: 1962Reputation: 1962Reputation: 1962Reputation: 1962Reputation: 1962Reputation: 1962Reputation: 1962
he already clearly told you...

Quote:
pico /folder/subfolder/filename
please pay a little more attention to the advise you are given, thanks
 
Old 04-21-2003, 04:01 AM   #5
XavierP
Moderator
 
Registered: Nov 2002
Location: Kent, England
Distribution: Lubuntu
Posts: 19,174
Blog Entries: 4

Rep: Reputation: 428Reputation: 428Reputation: 428Reputation: 428Reputation: 428
You need to use a text editor - eg pico /folder/subfolder/filename or vi or whatever your text editor is.

That is - type in your text editor name folowed by a space followed by the path to the file you wish to edit. Not knowing your system, distro, etc no one can tell you the exact command.

So your steps are:
Identify which text editor you need to use in a console
Identify the path to your folder and the file name
Type it into a console as "editorname /path/to/filename" (minus the quotes)
Edit the file
Save the file

Typing "man your text editor" (minus the quotes) into a console will give you a great deal of info on th editor and the commands you can use.
 
Old 04-21-2003, 04:02 AM   #6
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,376

Rep: Reputation: 1962Reputation: 1962Reputation: 1962Reputation: 1962Reputation: 1962Reputation: 1962Reputation: 1962Reputation: 1962Reputation: 1962Reputation: 1962Reputation: 1962
fyi, try using "less" instead of "more" it's much more powerful. no really...
 
Old 04-21-2003, 09:31 AM   #7
mjolnir
Member
 
Registered: Apr 2003
Posts: 661

Rep: Reputation: 68
Ludwig,I just got my first taste of vi editing fstab so that I could
write to my xp(fat32) partition.
vi <file name>
press ins
edit
esc
shift zz
It took a few trys but I got it done.
 
Old 04-21-2003, 10:01 AM   #8
ludwig W
Member
 
Registered: Mar 2003
Posts: 404

Original Poster
Rep: Reputation: 30
thanks XavierP.That's cleared up my confusion.

acid_kewpie:It's not a question of paying more attention.It's a question of understanding.Things that may seem blindingly obvious to you,might well confuse a newbie like me I'm sorry to be so dumb,but I am new to this and I know my questions must bug some of the more experienced posters here.I can only apologise.

mjolnir: I've also just got the hang of vi.I also have gedit which I can use,I think.

Thanks for all your help,
Ludwig
 
Old 04-21-2003, 09:40 PM   #9
wapcaplet
Guru
 
Registered: Feb 2003
Location: Colorado Springs, CO
Distribution: Gentoo
Posts: 2,018

Rep: Reputation: 48
Quote:
Originally posted by ludwig W
Things that may seem blindingly obvious to you,might well confuse a newbie like me. I'm sorry to be so dumb,but I am new to this and I know my questions must bug some of the more experienced posters here.I can only apologise.
Very true. It's easy to get impatient and forget how confusing some of this stuff was, starting out... all of us were newbies at one point.

Don't feel bad about asking questions! I mean, this is LinuxQuestions.org... And the more experienced people might be bugged but that's just too bad for them. Most of the people here are very willing to lend an ear and some assistance.
 
Old 04-21-2003, 10:00 PM   #10
fancypiper
Guru
 
Registered: Feb 2003
Location: Sparta, NC USA
Distribution: Ubuntu 10.04
Posts: 5,141

Rep: Reputation: 57
If you have midnight commander installed (command to run it is mc), it has a nice editor. Navigate to the file and press F4.

midnight commander
 
Old 04-21-2003, 10:05 PM   #11
fancypiper
Guru
 
Registered: Feb 2003
Location: Sparta, NC USA
Distribution: Ubuntu 10.04
Posts: 5,141

Rep: Reputation: 57
Quote:
Originally posted by acid_kewpie
fyi, try using "less" instead of "more" it's much more powerful. no really...
Less is more.
More is less.

Obviously that is true. Trust me. It is really true.

If you don't believe me and acid_kewpie, read the man pages for yourself.
 
Old 04-22-2003, 03:09 AM   #12
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,376

Rep: Reputation: 1962Reputation: 1962Reputation: 1962Reputation: 1962Reputation: 1962Reputation: 1962Reputation: 1962Reputation: 1962Reputation: 1962Reputation: 1962Reputation: 1962
not always. many distro's do just link it but not all
 
Old 04-22-2003, 04:00 AM   #13
doublefailure
Member
 
Registered: Mar 2002
Location: ma
Distribution: slackware
Posts: 747

Rep: Reputation: 30
emacs -nw filename

 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Any command-line tools which can edit EXIF image data? neocookie Linux - Software 1 01-27-2005 11:23 AM
Can't find edit grub.conf when im in command line. izac5 Linux - Newbie 7 11-16-2004 04:24 PM
nfs a file shares ok via file mngr but not command line. Suse 9.1 acummings Linux - Networking 2 10-09-2004 02:23 PM
Command to output file content line by line aznluvsmc Programming 2 09-12-2004 07:45 PM
How do I edit files in command line sweb74 Linux - Newbie 13 01-27-2004 10:53 PM


All times are GMT -5. The time now is 10:19 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration