sudo config
sudo is a standard way to give users some administrative rights without giving out the root password. This can also be configured for non root users as well.
1 2 3 |
vi /etc/sudoers and add the following line Syntax: user hosts = (runas) commands |
1 2 |
# user john is allowed to run some_script.sh as jack with no password john ALL = (jack) NOPASSWD: /work/some_script.sh |
1 2 3 |
# Any user part of the opsgrp will be allowed to mount and unmount squashfiles as root with no password. User_Alias OPSACC = %opsgrp OPSACC ALL = (root) NOPASSWD: /bin/mount -t squashfs -o loop *, /bin/umount -t squashfs * |
sftp only access (no shell access)
1 2 |
groupadd sftponly_group useradd -d /home/sftp_dir/ -g sftponly_group -s /bin/false sftp_user |
Add the following lines to /etc/ssh/sshd_config
1 2 3 4 5 |
Match Group sftponly_group ChrootDirectory %h AllowTcpForwarding no X11Forwarding no ForceCommand internal-sftp -l INFO -f AUTH |
Make sure to restart sshd daemon.
Read Moreworking with 1st or last characters of every line in vim
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 ' |