Archive for the 'General' Category

SBDavid

Email Alert on Root SSH Login

Email Alert on Root SSH Login

Login to your server as root user

vi /root/.bashrc

Add the following to the end of the file.

echo ‘ALERT - Root Shell Access on $hostname:’ `date` `who` |
mail -s “Alert: Root Access from `who | cut -d”(” -f2 | cut -d”)” -f1`” admin@serverbuddies.com
SBDavid

Redirecting Standard Error

Redirecting Standard Error

Instead of redirecting the standard output to a file, you can redirect the error messages to a file. This can be done by placing a 2 directly in front of the redirection angle bracket. If you are not interested in the error messages, you simply can send them to /dev/null

$ find / -name foo 2> /dev/null

This shows you the location of file foo, if it exists, without those pesky permission denied error messages. I almost always invoke the find command in this way.

The number 2 represents the standard error output stream. Standard error is where most commands send their error messages. Normal (non-error) output is sent to standard output, which can be represented by the number 1. Because most redirected output is the standard output, output redirection works only on the standard output stream by default. This makes the following two commands equivalent:

find / -name foo > output.txt
$ find / -name foo 1> output.txt

$

piping the output to another command.

find -name test.sh 2>&1 | tee /tmp/output2.txt
SBDavid

Adding user/group in a FreeBSD server

Adding user/group in a FreeBSD server

How do I add a user and group to the FreeBSD Server?:

The ‘pw’ command can be used to add a user and or group to the FreeBSD System. The ‘pw’ command is a program that will allow any user with superuser privileges to edit and or add users and groups on FreeBSD with ease. It also allows a way to standardize modification of adding and removing users and groups.

pw groupadd anewgroup

This would create the group ‘anewgroup’ to the machine.

Now to add a users ‘ben’ to the ‘anewgroup’ using pw, issue the following command.

pw useradd ben -s /bin/csh -g anewgroup

This command would create the user ben, with a shell of /bin/csh and add it to the anewgroup group. The user would also have his home directory under /home/ben.

Now say, if the user needs to have the home directory on a different partition, for example /mnt/test/home issue the following command.

pw useradd ben -d /mnt/test/home/ben -s /bin/csh/ -g anewgroup

If the user ‘ben’ is to be added to a secondary group on the system, say a group that has been created already called ‘oldgroup’, then execute the following.

pw usermod ben -G oldgroup
SBDavid

Steps to upgrade MySQL in FreeBSD

Steps to upgrade MySQL in FreeBSD

Steps to upgrade MySQL version 4 to 5 in the FreeBSD :

1. Backup the existing MySQL database.

$ cd /var/db/
$ tar cvfz mysql.tar.gz mysql

2. Stop the MySQL service.

$ /usr/local/etc/rc.d/mysql-server.sh stop

3.Remove the existing MySQL Server .

pkg_delete mysql-server-4.*.*
pkg_delete mysql-client-4.*.*
Replace the ‘*’ with the version that is the server.

4. For installing the new MySQL Server, execute the following step.

$ cd /usr/ports/databases/mysql50-server && make install clean

5.Start MySQL 5.0 in the server and run the upgrade script.

$ /usr/local/etc/rc.d/mysql-server.sh start
$ /usr/local/bin/mysql_upgrade -u root -p –datadir=/var/db/mysql

You will be prompted for the new MySQL password where you can provide it.

Recompiling the FreeBSD kernel with PAE support

Please follow the steps to recompile the Freebsd with PAE support.

1. Edit the file named after the hostname in /usr/src/sys/i386/conf and remove “include GENERIC” and put “include PAE”

2. Rebuild/install it by going to /usr/src and typing “make buildkernel KERNCONF=whatever that file is called && make installkernel KERNCONF=whatever that file is called” ( substituting for the actual filename)

3 Reboot the server to make effect.

« Prev - Next »