My way in life

Anything is possible. Some things just take a little longer.

Archive for the ‘Unix’ Category

May
10

Remove ^M from file in unix file

Posted by anilezfa on May 10, 2008

This note is dedicated to my chubby hubby that keep asking me how to remove ^M in a file.

UNIX treats the end of line differently than other operating systems. Normally CTRL-M character is visibly displayed at the end of each line as ^M if the file is not transfered in binary mode (this is why I always prefer SFTP instead of FTP).

  1. In vi, to remove the ^M do as following :
  2. :%s/^V^M//g

    ^V is a CONTROL-V character
    ^M is a CONTROL-M.

    So it will look like this:

    :%s/^M//g

    %s is a basic search and replace command in vi.
    The g is use for search and replace globally (all occurrences).

  3. with Solaris you can just do (heard HPUX has the command “dos2ux” instead of dos2unix):
  4. dos2unix <dos file> <unix file>

  5. You can also use the octal representatiion of ^M:
  6. tr -d ‘\015\032′ < file

Apr
22

semaphores and shared memory settings

Posted by anilezfa on April 22, 2008

shmsys:shminfo_shmmax
Maximum shared memory segment size

shmsys:shminfo_shmmin
Minimum shared memory segment size

shmsys:shminfo_shmmni
Number of shared memory identifiers

shmsys:shminfo_shmseg
Number of segments, per process

semsys:seminfo_semmap
Number of entries in the semaphore map

semsys:seminfo_semmni
Number of semaphore identifiers

semsys:seminfo_semmns
Number of semaphores in the system

semsys:seminfo_semmsl
Maximum number of semaphores, per ID

semsys:seminfo_semmnu
Number of processes using the undo facility

semsys:seminfo_semume
Maximum number of undo structures per process

Apr
21

Useful vi command - quick guide

Posted by anilezfa on April 21, 2008

Useful vi Commands

Cut/Paste Commands:

x delete one character (destructive backspace)
dw delete the current word (Note: ndw deletes n numbered words)
dd delete the current line (Note: ndd deletes n numbered lines)
D delete all content to the right of the cursor
d$ same as above
:u undo last command
p,P paste line starting one line below/above current cursor location
J combine the contents of two lines
"[a-z]nyy yank next n lines into named buffer [a-z]
"[a-z]p/P place the contents of selected buffer below/above the current line

Read the rest of this entry »

Apr
19

Reset root password on linux red hat vmware

Posted by anilezfa on April 19, 2008

I forgot my root password on my linux vmware. Here are the steps that I do in order to reset it.

  1. Press any key to go to the menu :rhat4-18-2008-11.49.25 PM.gif Read the rest of this entry »

Apr
11

Reset Root Password on Solaris

Posted by anilezfa on April 11, 2008

In order to reset root password on Solaris box, you would need to do the following :

  1. Go to OK Prompt by:
  2. <stop> + <a>

    or

    # init 0

  3. Once you got the OK prompt, boot into single user mode:
  4. OK> boot cdrom -s

  5. Mount the root directory, On a typical system, it’s probably c0t0d0s0 or c0t0d0s1:
  6. # mount /dev/dsk/c0t0d0s1 /

  7. Make a copy of /etc/shadow.
  8. # cp /etc/shadow /etc/shadow.backupcopy

  9. Edit /etc/shadow file
  10. # vi /etc/shadow

    Your /etc/shadow should look like this:
    root:<password>::877667

  11. Delete the password of the root user (Leave the second field empty, dont change anything else):
  12. root:<password>::877667

    edit to

    root:::877667

  13. Reboot the box
  14. Login to root account with no password.