Please support VectorLinux!

Author Topic: HOWTO: Edit a file  (Read 1065 times)

macondo

  • Member
  • *
  • Posts: 57
HOWTO: Edit a file
« on: July 18, 2012, 05:50:28 am »
HOWTO: Edit a file

When i started with Linux, i couldn't figure out the importance of editors and this file editing thing.
I found the hard way how important it is and the consequences of not knowing how to change things in files that control
the functioning of the OS. Thus, i dedicate this mini-howto to all newbies and the unwashed masses out there :)

WHO DOES WHAT:
The user is allowed to edit the files that "belong to him", i.e. files in his /home, or files he created, files that start
with a period (dot files) e.g. .ratpoisonrc . Ok? nothing else.

The rest of the files in the system belong to ROOT.

There are tons of editors, some gui and some that work from the console/terminal.
Start with the terminal ones, if you are stuck and cannot get into the X system, you can work from the console and enter the X.
If you only know gui editing you are in deep doodoo.

Don't confuse the console and the terminal, the console is that black hole before you enter the X system.

Say you want to edit the .xinitrc file that controls the launching of apps and the entering to the X system.
You notice is a dot file (starts with a dot), are you with me? so, right away you know you can edit it as a user ($)

Code: [Select]
$ nano .xinitrc

By now you have googled 'nano', you know how to save, exit, move from the beginning of a line, go to the end, etc.
Same with 'vim', go with nano first and then learn vim, it is very important to learn both and then choose the one you like best.
I don't program, code or do any of that, i use both.

Do you want to edit the /etc/inittab file? Is it a dot file, is it in your /home? no? Then ROOT comes to action:

Code: [Select]
$ su <Enter>
type your root password
and you become root:
# nano /etc/inittab

If you want the changes you have done by editing to stick, you have to save and exit:

NANO:

Code: [Select]
Ctrl + o will save the file
Ctrl + x will exit the program

VIM
Code: [Select]
Press the Esc key
:x
this will do both, save/exit

I'm getting old, this is all i remember...
VL 7.0 Light - Barebones Install - Kernel 3.0.17
Debian Testing - Minimal Install - kernel 3.4.0-6.dmz.1-liquorix-686
Desktop: Atom Processor || 1 GB RAM || 500 GB HD

retired1af

  • Packager
  • Vectorian
  • ****
  • Posts: 1280
Re: HOWTO: Edit a file
« Reply #1 on: July 18, 2012, 06:22:24 am »
Vector Linux defaults to mcedit, which is far nicer IMO than nano.
ASUS K73 Intel i3 Dual Core 2.3GHz

macondo

  • Member
  • *
  • Posts: 57
Re: HOWTO: Edit a file
« Reply #2 on: July 18, 2012, 07:14:37 am »
Probably, i must confess i've never used mcedit, the object of this writing is to introduce new users to file editing, thank you for the suggestion. Now i will install it, 'cause i try to launch it, but i ain't got it (light install and all), thanks for the contribution. I spent Sunday playing with vi/vim :)

PS: you were right, it's already there, i tried it on .xinitrc and it worked, console and everything. something learned today :)
« Last Edit: July 18, 2012, 07:31:12 am by macondo »
VL 7.0 Light - Barebones Install - Kernel 3.0.17
Debian Testing - Minimal Install - kernel 3.4.0-6.dmz.1-liquorix-686
Desktop: Atom Processor || 1 GB RAM || 500 GB HD