September 27, 2009 | Posted by
admin | Category: cPanel Management, Linux Administration
Howto check number of emails in the mail queue:
exim -bpc
To check the email ID, sender and receiver of the each email:
exim -bp | more
To delete frozen emails from the mail queue, execute:
exim -bp | grep ‘frozen’ | awk ‘{print $3}’ | xargs exim -Mrm
similarly, to delete emails sent using a script’
exim -bp | grep ‘<>’ | awk ‘{print $3}’ | xargs exim -Mrm
Comments Off on Delete Frozen Emails
September 26, 2009 | Posted by
admin | Category: Linux Administration
You can send emails of your server from an additional IP of your server instead of the main IP using iptables. Here is the iptable command:
iptables -t nat -A POSTROUTING -o eth0 -p tcp -j SNAT –dport 25 –to-source IPAddress
where, “IPAddress” is the additional IP of your server. To save the rule, execute
service iptables save
This will make the settings permanent and you can check the rule using
iptables -L -t nat
Comments Off on Sending emails using a different IP address
September 22, 2009 | Posted by
admin | Category: Linux Administration
If your rpm database gets corrupt, you receive the following message on working on packages using rpm:
rpmdb: unable to join the environment
rpmdb: write: 0xbf91a7d0, 8192: Invalid argument
error: db4 error(22) from dbenv->open: Invalid argument
error: cannot open Packages index
You can try out any of the following two solutions:
1.
rm -f /var/lib/rpm/__db*
rpm –rebuilddb
OR
2. you need to add the following ‘export’ line in /etc/profile file and rebuild the database.
export LD_ASSUME_KERNEL=2.2.5 (2.2.5 is the base kernel)
rpm –rebuilddb
With the second solution, the changes will take effect on the next session.
Comments Off on rpmdb: unable to join the environment
September 18, 2009 | Posted by
admin | Category: Linux Administration
How to Password Protect a Directory using .htaccess?
You may need to password protect a directory in order to limit the sharing of files under it OR may need to protect a private area. You can password protect a directory using a .htaccess file which has to be placed under a directory which needs to be protected.
Create a .htaccess file
vi /home/username/.htaccess
Once created, add the following lines to it:
AuthUserFile /home/username/.htpasswd
AuthName “Private Area”
AuthType Basic
require valid-user
where, ‘username’ is the actual username of your domain. Now, create a .htpasswd file under the /home/username/ directory.
vi /home/username/.htpasswd
In order to grant access to the directory for specific users, you need to place all the users along with their passwords in the below format:
username1:encryptedpassword
username2:encryptedpassword
There is no limit in adding users to this file, just make sure each user should be on a separate line and you can encrypt passwords using any available tool on the internet.
Comments Off on Howto: Password Protect a directory using .htaccess
September 13, 2009 | Posted by
admin | Category: Linux Administration
How to disable root login and create an alternate SSH user? In order to disable root access on your server, you need to create an alternate SSH user who have privileges to gain root access else you will be locked out of the system.
First, create a user say ‘admin’
# useradd admin
Set a password for the new user
# passwd admin
By default, this user will have privileges to su to root but in case of a cPanel server, you need to add the user in the ‘wheel’ group.
WHM >> Security Center >> “Manage Wheel Group Users”
Once the user is created, follow the steps to disable the root access:
1) Edit the SSHD configuration file ‘sshd_config’:
pico /etc/ssh/sshd_config
2) Search the line
PermitRootLogin yes
and change it to
PermitRootLogin no
Once you are complete with the above changes, save the file and exit. You will have to restart the sshd service for the changes to take effect.
service sshd restart
Now, you will have to SSH to your server as user ‘admin’ and then su to root as follows:
login as: admin
admin@xx.xx.xx.xx’s password: <admin pass here>
[admin@server ~]$ su –
password: <root password here>
[root@server ~]#
Comments Off on Howto: Disable root login on a server?