Archive for the ‘Unix’ Category
Remove ^M from file in unix file
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).
- In vi, to remove the ^M do as following :
- with Solaris you can just do (heard HPUX has the command “dos2ux” instead of dos2unix):
- You can also use the octal representatiion of ^M:
:%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).
dos2unix <dos file> <unix file>
tr -d ‘\015\032′ < file
semaphores and shared memory settings
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
Useful vi command – quick guide
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 »
Reset root password on linux red hat vmware
I forgot my root password on my linux vmware. Here are the steps that I do in order to reset it.
- Press any key to go to the menu :
Read the rest of this entry »
Reset Root Password on Solaris
In order to reset root password on Solaris box, you would need to do the following :
- Go to OK Prompt by:
- Once you got the OK prompt, boot into single user mode:
- Mount the root directory, On a typical system, it’s probably c0t0d0s0 or c0t0d0s1:
- Make a copy of /etc/shadow.
- Edit /etc/shadow file
- Delete the password of the root user (Leave the second field empty, dont change anything else):
- Reboot the box
- Login to root account with no password.
<stop> + <a>
or
# init 0
OK> boot cdrom -s
# mount /dev/dsk/c0t0d0s1 /
# cp /etc/shadow /etc/shadow.backupcopy
# vi /etc/shadow
Your /etc/shadow should look like this:
root:<password>::877667
root:<password>::877667
edit to
root:::877667
