Using a text editor
Scripts are plain text files, and to edit them you need to use a text editor. There are several editors available on the Linux server, and the easiest one to use is called nano. To edit a file, use the command:
1 |
|
If you call nano without specifying a filename, it creates a new file which you can save later. Once the editor starts it offers you a window that you can type into straight away as shown in Figure 3. You can move around the editor window using the cursor keys, but remember that you can't position the cursor using the mouse because you are still in a text-oriented environment.
Along the bottom of the window is a list of commands that are available. The caret symbol stands for the CTRL key, so to exit the editor, for example, is CTRL+X.
If you want an editor with more features and greater control, you should look into vi
Many people prefer to edit files on their own computer where they have access to GUI editors. These provide a number of advantages besides the ability to move the cursor and to highlight text using the mouse. Good text editors also provide syntax highlighting which picks out different parts of the language you are working with in different colours. This can be very useful when composing code or when looking for errors.
There are a number of text editors available for free including Notepad++, SublimeText and Atom. Please note that applications for document preparation such as Microsoft Word are not text editors. Their files contain a lot of information besides the text that you are interested in and they will not behave as you expect if you try to run them like script files.
Editing files on your computer is fine, but then you need a way of moving them to and from the server. For this you need a file transfer application.