Category Archives: Uncategorized

Linux : Vi and Vim Short Notes

Writing to file when your forgot to run Vi/Vim as root privileges.
:w !sudo tee %

Searching in Vi/Vim.
:%s///g

Copy and paste line in Vi/Vim.
[Esc] yy -
p - paste after cursor
P - paste before cursor

Reference:-
http://vim.wikia.com/wiki/
http://stackoverflow.com/

Advertisements

Steps to create “protected” user account in linux


Steps to create user account
----------------------------
1. # useradd [USERNAME] -d /home/sftponly/[USERNAME]/ -s /bin/false -G sftponly

2. set passwrd
# passwd [USERNAME]

3. change owner to root and chmod 755
# cd /home/sftponly
# chown root:root [USERNAME]
# chmod 755

4. Create folder in /var/www/html & link inside folder
e.g:
# mkdir /var/www/html/kosong.com.my
# chown apache:[USERNAME] /var/www/html/kosong.com.my
# mkdir /home/sftponly/[USERNAME]/kosong.com.my

5. Add mount bind in /opt/runbind.sh
# vim /opt/runbind.sh
add :-
mount –bind /var/www/html/kosong.com.my/home/sftponly/[USERNAME]/kosong.com.my
save.
run script:
# /opt/runbind.sh

p/s: tested on CentOS 6