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.

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



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
# mkdir /var/www/html/
# chown apache:[USERNAME] /var/www/html/
# mkdir /home/sftponly/[USERNAME]/

5. Add mount bind in /opt/
# vim /opt/
add :-
mount –bind /var/www/html/[USERNAME]/
run script:
# /opt/

p/s: tested on CentOS 6