working with 1st or last characters of every line in vim
0
Remove the last char from every line
1 |
:%s/.$//g |
Insert a * in the beginning/end of every line
1 2 3 4 5 6 |
:%norm I* % = for every line norm = type the following commands A* = append '*' to the end of every line I* = insert '*' to the beginning of every line |
Change the default editor
I ran into this with CentOS 5. Where the default editor for the system is set to nano! I like vi and wanted to change the default to it. login to the system vi .bashrc Add the following two lines to .bashrc
1 2 |
export EDITOR="vim" export VISUAL="vim" |
run the command, source .bashrc A change to /etc/bashrc will make it a system wide change
Read MoreBlock insert with vim
Vi block insert (i.e // in front of a block of lines)
1 2 3 4 5 6 7 8 9 10 11 |
Method #1) - vi sameple_file.txt - Ctrl + V - Make selection by moving the cursor (j/k/l/h) - Shift + i - insert the text "//" - Press ESC to finish. Method #2) - visually select the text rows (using V as usual) - :norm i# |
Virtualbox dhcp set
1 |
VBoxManage.exe dhcpserver add --ip 10.0.7.1 --netmask 255.255.255.0 --lowerip 10.0.7.2 --upperip 10.0.7.10 --enable --netname intnet |
Simple all mail relay
You have a server who’s IP is already white listed on your mail server & you wanted this server to pass all outgoing mails to the company’s mail server. This method basically eliminates the need for a mail server to be running on the local box.
1 2 |
- vi /etc/mail.rc and add the following line to it. set your.valid.mail.com |
increase the loop device count
1 2 3 4 5 6 7 |
Increasing the loop devices from the default 7 to 150: - umount /dev/loop * - modprobe -r loop - modprobe loop max_loop=150 - vi /etc/modprobe.conf options loop max_loop=150 |
Put a time stamp in history
1 2 3 4 5 6 |
- vi /etc/bash.bashrc - insert any one of the following line (of course remove the commenting out part!) #HISTTIMEFORMAT=${HISTTIMEFORMAT:-"%F %H:%M:%S"} #HISTTIMEFORMAT='%F %T ' HISTTIMEFORMAT='%F %H:%M:%S ' |
Auto start services
1 2 3 4 5 6 |
- Works with Centos or Redhat - sudo /sbin/chkconfig --add mysqld - sudo /sbin/chkconfig --list mysqld - sudo /sbin/chkconfig mysqld on - To find out the name of service's script from /etc/init.d/ directory e.g. mysqld or httpd |