LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   How to open A file with an editor through my shell (https://www.linuxquestions.org/questions/linux-newbie-8/how-to-open-a-file-with-an-editor-through-my-shell-300080/)

amer_58 03-10-2005 01:28 PM

How to open A file with an editor through my shell
 
After installing samba I need to configure my file in /etc/samba/smb.conf I can simply double click and open the file, How can I view the file using my shell .... for example Do i have to specify the name of editor before the file name in order to view the file...

eg.

root@Admin:/etc/samba# emacs smb.conf

Thanks.

{BBI}Nexus{BBI} 03-10-2005 01:37 PM

Yes put the name of the editor before the filename you wish to open.

amer_58 03-10-2005 01:42 PM

Thanks .. Just to know what is the common text editor for linux? Meaning that I will find in every machine.

enemorales 03-10-2005 02:03 PM

I think that the answer for that is "vi". It would be in the 99% of the machines, nevertheless sometimes it is actually "vim" (vi improved) what you will run, even if you put "vi". The problem is that "vi" could be a little difficult in the beginning, so keep a browser handy to look how it works.

Other very common editors are "nano", "emacs" and "joe".

perfect_circle 03-10-2005 02:22 PM

slackware also have pico by default installed, which is really easy to use.
The command are displayed in the bottom of the pico.
^X means CTRL+X
Most distros have either pico or nano which is a GNU pico - clone, but the default UNIX editor is vi. vi in slackware is a link to elvis, which is a vi clone like vim. vim is also installed
Find a tutorial for vi. It's a really powerfull command-line editor.

PTrenholme 03-10-2005 03:47 PM

Re: How to open A file with an editor through my shell
 
Quote:

Originally posted by amer_58
After installing samba I need to configure my file in /etc/samba/smb.conf I can simply double click and open the file, How can I view the file using my shell ....
If you really just want to look at the file, try
Code:

cat /etc/samba/smb.conf
the "cat" command conCATinates the file to the console. (The equivalent to the M$ "type" command.)

If you're actually configuring samba, check out (as root)
Code:

system-config-samba
or, better yet,
Code:

firefox localhost:901
if you have the SWAT service running on port 901 (its default). (Substitute your favorite browser for "firefox.")

See the "network" forum here for more info (and help)

casttellum 03-10-2005 05:22 PM

Also, if you have xwindows running, you can probaly use 'gvim **FILE TO EDIT**'. This will open a vim in a window. But: you might not have gvim installed and you must be logged in as either root or the user you are graphicaly logged in as.

smiler 03-10-2005 05:41 PM

the easiest for me to work with right away is jed, but it is not installed by default.
There is a menusystem in the console so you don't have to remember commands

chrism01 03-11-2005 12:57 AM

Whichever editor you finally go with, I'd recommend learning at least the basics of 'vi', as it's pretty much guaranteed to be avail on any Unix/Linux/*BSD machine. You favourite may not be... and in commercial env's, you prob won't be allowed to download your own...

amer_58 03-11-2005 01:49 AM

With the vi I can only view the file, I need to edit it as well.

perfect_circle 03-11-2005 04:58 AM

Quote:

Originally posted by amer_58
With the vi I can only view the file, I need to edit it as well.
No. This is why we are telling you that vi is not newbie friendly. To insert something before the letter the pointer is placed type the letter i (=insert). Then you enter in insertion mode and you can write. After you write you press Esc to leave insertion mode. The letter a (=append) will append something. You will enter in insertion mode and what you type will be added after the cursors position. Again press Esc to leave insertion mode. x is for deleting the letter under the cursor. v is for entering visual mode. To highlight something, what you do in windows editors by pressing shift and the arrows, or by using the mouse if you want to copy a sequence of letters. Then with d you cut the highlighted part, with y you copy the highlighted part, with p you past it. r is for replacing, dd is for deleting an entire line, :q is for quitting, :q! is for quiting without saving, ZZ or :wq is for save and quit :open is for opening files :new is for opening a empty new file. if you type :765 the cursor will move to line 765. There are really a lot more commands and features (for advanced searching, for highlighting a source code). Those are just the basics... If you learn to use vi you'll love it, but it's pretty frustrating in the beginning.

frrossk 03-11-2005 06:16 AM

Check out this link: http://www.eng.hawaii.edu/Tutor/vi.html

morrolan 03-11-2005 06:19 AM

I've been using vi for years and you've just lost me!


All times are GMT -5. The time now is 09:05 AM.