Remove ^M from Files Using the vi Editor

After moving text files from Microsoft Windows to the UNIX environment, I frequently end up with the ^M characters at the end of each line in the files. This occurs because UNIX uses 0xA for the newline character, while Windows uses a combination of two characters: 0xD 0xA. 0xD is the carriage return character. The vi editor displays 0xD as ^M. The ^M characters do not hurt anything being there, and the files still execute fine despite having the extra characters, but I like my code clean, so I remove the characters whenever I notice them.

To globally remove all of the ^M characters in a file using the vi editor, issue the following vi command:


To enter ^M, type Ctrl-v, then Ctrl-m. (hold down the Ctrl key then press v and m).

  • In UNIX, you can escape a control character by preceding it with a Ctrl-v.
  • The :%s is a basic search and replace command in vi. It tells vi to replace the regular expression between the first and second slashes (^M) with the text between the second and third slashes (nothing in this case).
  • The g at the end directs vi to search and replace globally (all occurrences).
Email this to someoneTweet about this on TwitterShare on LinkedInPin on PinterestShare on Google+Share on FacebookPrint this page

Apache Error – (13)Permission Denied: Make_sock

ApacheI ran into an error two years ago and I’m finally getting around to sharing the error and solution.  Another system administrator had installed an Apache web server on one of my AIX boxes and I wanted to fire it up and begin development.  Here is what happened:

$ ./apachectl start

(13)Permission denied: make_sock: could not bind to address [::]:80

(13)Permission denied: make_sock: could not bind to address

no listening sockets available, shutting down

Unable to open logs

 A Bing search (trying to wean myself off of Google) quickly uncovered the issue. In Unix / Linux, only privileged users (primarily root) are allow to bind the ports between 1 to 1024.  My Apache web server was configured to run on the default http port of 80, so my user ID did not have permission to start the web server. I do have sudo privileges however, so it was easy enough to resolve this issue:

$ sudo ./apachectl start

Now I’m up and running!  But there is another way around this. I can edit the httpd.conf configuration file and edit the Listen attribute to specify a port above 1024:

# Listen: Allows you to bind the web server to specific IP addresses
# and/or ports, in addition to the default. See also the <VirtualHost>
# directive.
# Change this to Listen on specific IP addresses as shown below to
# prevent the web server from accepting connections on all interfaces
# (
# Change this to "Listen" to restrict the server to
# IPv4.
Listen 80

If I were to change the configuration, I would probably assign 8080 because it typically is not used by any other processes and it is easy to remember like the default http port number.

Email this to someoneTweet about this on TwitterShare on LinkedInPin on PinterestShare on Google+Share on FacebookPrint this page

Useful Vim Commands for SAS Administrators on UNIX

After a successful installation of SAS Enterprise BI Server on my Sun Servers, a certain amount of time is spent modifying configuration files and backup scripts, as well as browsing log files.  I use the vi editor to accomplish the editing.  I used used vi a lot back when all of my GIS work was performed in the UNIX environment, but once the Intel hardware matured and the GIS tools because available on Windows, I thought I would be able to forget all about the UNIX command line.  Wrong.  I’m back there again, but now I’m armed with a cheat sheet:

Working with files

Vim Command


vi filename

Opens a file with the Vim editor.

:w filename

Save changes to a file. If you don’t specify a file name, Vim saves as the file name you were editing. For saving the file under a different name, specify the file name.


Quit Vim. If you have unsaved changes, Vim refuses to exit.


Exit Vim without saving changes.


Write the file and exit.

Moving around in the file

Vim command


j or Up Arrow

Move the cursor up one line.

k or Down Arrow

Down one line.

h or Left Arrow

Left one character.

l or Right Arrow

Right one character.


To the beginning of a line.


To the end of a line.


Jump to line number n.

Inserting and overwriting text

Vim command



Insert before cursor.


Open a new line below and insert.


Open a new line above and insert.


Change the rest of the current line.


Overwrite one character. After overwriting the single character, go back to command mode.


Enter insert mode but replace characters rather than inserting.

The ESC key

Exit insert/overwrite mode and go back to command mode.

Deleting text

Vim command



Delete characters under the cursor.


Delete characters before the cursor.

dd or :d

Delete the current line.

Undo and redo

Vim command



Undo the last action.


Undo all the latest changes that were made to the current line.

Ctrl + r


There are obviously many more Vim commands out there.  Typically if I find myself in a situation where extensive modifications need to be made with a text editor, I will use Crimson Editor on Windows.

The list of commands above are a subset of The Vim commands cheat sheet – 1.2.

Email this to someoneTweet about this on TwitterShare on LinkedInPin on PinterestShare on Google+Share on FacebookPrint this page

© 2017 Technoleros

Theme by Anders NorénUp ↑