PDA

View Full Version : how to open a file using command line in terminal and edit the code within it ?



naved
10th June 2011, 07:25 PM
how to open a file using command line in terminal and edit the code within it ?

for eg: we need edit this : <Directory /usr/share/phpMyAdmin/>
order deny,allow
deny from all
allow from 127.0.0.1
allow from ::1
</Directory>

to

#<Directory /usr/share/phpMyAdmin/>
#order deny,allow
#deny from all
#allow from 127.0.0.1
#allow from ::1
#</Directory>

Miikka
10th June 2011, 07:36 PM
su -
//enter root password here
gedit

jvillain
10th June 2011, 07:43 PM
If you don't have a GUI available there are a number of options. Nano, Vim, EMACs etc. I prefer nano myself.

To open
nano -w <file>

Then use it mostly like notepad, no whacko 70s style EMACs insert mode etc.

To save and exit CTRL+x

RHamel
10th June 2011, 07:49 PM
You can also use vi or vim. Here is some documentation (http://rute.2038bug.com/node9.html.gz#SECTION00910000000000000000). It comes in handy if a gui is unavailable.

Miikka
10th June 2011, 07:51 PM
If you don't have a GUI available there are a number of options. Nano, Vim, EMACs etc. I prefer nano myself.

To open
nano -w <file>

Then use it mostly like notepad, no whacko 70s style EMACs insert mode etc.

To save and exit CTRL+x

I prefer nano as well, but it is no longer installed by default (atleast with liveCD). :(

naved
11th June 2011, 06:43 PM
If you don't have a GUI available there are a number of options. Nano, Vim, EMACs etc. I prefer nano myself.

To open
nano -w <file>

Then use it mostly like notepad, no whacko 70s style EMACs insert mode etc.

To save and exit CTRL+x

after editing how to exit from nano i press ctrl+x bt ...the application is still open in terminal how to come back to terminal from nano ?

jvillain
11th June 2011, 07:09 PM
It asks first if you want to save. Press either 'y' or 'n'
It then asks where you want to save the file and gives the existing file name. If you want to save there just hit enter. Other wise enter the new path/name and press enter.

With the live disk you can always do a "yum install nano"