Posts Tagged ‘unix’

How to Change User’s Shell Environment in FreeBSD

Wednesday, May 26th, 2010

In FreeBSD, user’s default shell environment is either sh or csh and I have installed Bash in FreeBSD and would like to change user’s shell environment to Bash.

To change user’s shell environment in FreeBSD.


shell> chsh -s /usr/local/bin/bash userid

To change your shell environment in FreeBSD


shell> chsh -s /usr/local/bin/bash

Quick File Copy on File Name with Sample Extension

Tuesday, May 18th, 2010

By default, some of the application installation provide you a sample configuration file. Usually the sample of configuration will end with name like *.sample, *.default and so on. Let say you have 20 of *.sample files and it will take you some time to copy, move or rename one by one. Lets do some quicker way which will save more time.

Create a sample file file random name ended with *.sample. Example


touch apple.sample.cfg
touch microsoft.sample.cfg
touch php.sample.cfg
touch config.sample.cfg
touch apache.sample.cfg
touch mysql.sample.cfg
touch pgsql.sample.cfg
touch cacti.sample.cfg
touch wordpress.sample.cfg
touch jessicaalba.sample.cfg

Now you have all the sample configuration, you are going to use them. Are you going to copy one by another and change the same with .cfg prefix? We can do it, in a better and faster way.

Make a new directory to store all the sample file


mkdir sample
cp *.sample.cfg sample/

After that, go to sample directory and copy the files to a location


cd sample
for d  in `ls *.sample.cfg`; do cp $d `echo $d | sed s/sample.cfg/cfg`; done

That one simple line will easily save you 1-2 minutes.

Enable SSHD on FreeBSD

Tuesday, May 18th, 2010

I believe most system admin does remote access to the server. Who doesn’t enable SSHD on FreeBSD? Almost every new FreeBSD installation, the first thing I will do after installation is enable SSHD Service on FreeBSD. Start the service and remote access from laptop, with a cup of coffee!

To enable SSHD on FreeBSD

  • Edit the file: vi /etc/rc.conf
  • Add: sshd_enable=”YES”
  • To start sshd service: /etc/rc.d/sshd start

If it’s the first time you enable SSHD, it will generate the keys for the first time.

Disable phpinfo() on Apache Web Server

Tuesday, July 22nd, 2008

Information displays from phpinfo() may provide resourceful information to attacker, such as file patch, web server environment, php modules, web server modules and etc. It’s better to disable phpinfo() function on your webserver.

Changing File’s Date and Time on Unix Systems

Wednesday, July 16th, 2008

Change Data and Time of a File

At times, we might want to change date and time of a file, for record purposes. For example, when you copying log file from remote machine, when it’s extract on local machine, the date and time will reflect to current date time.

touch Command

To update the date and time of file, run;

touch -t ccyymmddhhMMSS filename

For more info, run;

man touch