Welcome Anonymousregister
Categories
· Home
· Authors and Articles
· Downloads
· Feedback
· Forums
· Journal
· Private Messages
· Recommend Us
· Stories Archive
· Submit News
· Surveys
· Top 10
· Topics
· Web Links
· Your Account

Survey
What Topics Of FreeBSD Servers & Workstations Do You Want More Information About?

FreeBSD Installation
Webserver Setup
E-Mail Server Setup
IRC Server Setup
Mailing Lists
Autoresponders
Scripting
Software Coding
Server Security
Installing Ports
Domain Servers
Website Design



Results
Polls

Votes: 10
Comments: 0


FreeBSD Hacks Welcomes All You Scripting And BSD Professionals

Join the thousands of other FreeBSD users who push this operating system to its extremes via scripting and other server applications.

What is FreeBSD Hacks?  It is a site full of Tips, Tricks and Techniques for maximizing FreeBSD.  Are you looking to build your own Webserver machine and want to know exactly how to do it?  Then FreeBSD Hacks is where you can find ebooks and forum posts that describe how to do just that.  No matter what it is that you wish to accomplish with FreeBSD, we can help.  Become part of a growing community of FreeBSD experts that can show you how to Maximize your servers potential, and also show people the Tips, Tricks and Hacks, that you have developed, to make FreeBSD your favorite Server platform.

Click on the register text in the login block on the right and sign up for an account, this will grant you access to not only our public forum but also to some of our downloads area where you can grab scripts and ebooks which will enhance FreeBSD and the other BSD flavors such as OpenBSD, NetBSD, PCBSD and more.  With that, we look forward to hearing from you and learning how you have utilized FreeBSD in your own daily life.

Learn How-To Install FreeBSD 6.2, Shell Scripting Hacks, FreeBSD Server Security, FreeBSD e-mail Server setups, FreeBSD DNS Server Configuration, FreeBSD IRC Server Configuration, FreeBSD Web Server Configuration and Operations, and the list goes on and on.  If it's FreeBSD Server or Workstation Configuration, we are likely to cover it, so check it out today!




Recent Forum Posts

Forum/Topic  Replies   Author   Views   Last Post 
 FreeBSD Ports, Apps & Daemons
  Displaying Log Files Via Tail On Your Desktop
0 Michael 295   12/03/2007 at 00:21 
Michael Latest Post
 Shells
  Learn How-To Use The Date Function To Automate Saving Files
0 Michael 220   12/02/2007 at 23:54 
Michael Latest Post
 Shells
  Learn How-To Remove ^M Carriage Returns From PC Files
0 Michael 255   12/02/2007 at 23:49 
Michael Latest Post
 General Discussions
  Welcome to FreeBSD Hacks!
0 Michael 173   11/22/2007 at 16:22 
Michael Latest Post
 

 Title : News: Learn To View Your Security Log Files From Right On Your Desktop
News
News


Another Fantastic Tool For Monitoring Your Log Files Right On Your Desktop

One of the best tools around for keeping an eye on your log files for security purposes is root-tail. I have been using this tool for years now and it's pretty phenomenal. Using the KDE desktop it's very straight forward to use and you can color code which tail file is being displayed on your desktop. If you've never seen root-tail in action, you will really get a kick out of how this log is displayed right on your desktop.

Here is an actual 
ksnapshot of root-tail in action on my KDE desktop.

For the full story check out our forum post about this fantastic tool.

Forum Post About root-tail



Monday, December 03, 2007 @ 20:12:54 EST
(comments? | News | Score: 0)

 Title : Scripting: How To Batch Remove ^M From PC Files
Scripting
Scripting


Removing ^M From Files Saved Within Windows Is Easy Using This Utility.

This is probably one of the most annoying issues you have to deal with when you open a lot of files which have either been on a windows system or were created on a windows machine, and that is removing those pesky ^M symbols when viewed on a Unix box.  Generally these carriage return symbols (^M) don't do any harm when they are within Unix files but they are annoying and make the file your viewing that much harder to read. 

If you are anything like I am when it comes to these, you want an easy way to remove them from a batch of files all at once and not waste a whole lot of time on them.  The utility I use to remove them is called dos2unix and it can be found in the ports tree at
/usr/ports/converters/unix2dos Now you're probably asking, 'Wait, I thought you said it was dos2unix', yes you're right I did, but included in the unix2dos application is the dos2unix command which we will be using.

<------Begin Type Within a Shell------->
#cd /usr/ports/converters/unix2dos
#make clean
===>  Cleaning for unix2dos-1.3
#make install distclean
######Code Compiles#######
#rehash
<-------End Type Within a Shell-------->


Once you have compiled unix2dos you will issue the following command from the shell:

<-------Begin Type Within a Shell------->
#
find /path/to/folder/of/files/to/process/ -name "*.php" -print -type f -exec dos2unix {} \;
<-------End Type Within a Shell--------->

This will spit out a list of the files that it found within this folder and execute the dos2unix command on the files with the extension of .php.

Now there are probably a million different ways to accomplish the task of removing these carriage return within your files, but I found that using this method to do a batch search and execute is the simplest most effective way of doing this chore.

You can use other tools to remove these ^M symbols from your files and if you're are just dealing with one file then this may be a little overboard.  You could use perl to do this for example by doing the following:


<-------Begin Type Within a Shell------>
#perl -pi -e 's/
\015//g' filename
<-------End Type Within a Shell-------->

I hope you find this as useful as I do when dealing with files that you move from a windows  box to your FreeBSD machine.  These are the kinds of hacks that make using FreeBSD so much fun.



Sunday, December 02, 2007 @ 18:38:07 EST
(comments? | Scripting | Score: 5)

 Title : Scripting: Using Date Function To Automate Saving Of Mysql Database Files
Scripting
Scripting


We Show You How To Use The Date Function To Save Reoccurring Files Which Would Otherwise Get Overwritten

One of the first things I ran into when beginning my FreeBSD adventure was finding a way to automatically backup my web servers mysql database files. I found that even webmin (an application management interface) wasn't able to handle saving of my mysql database files without overwriting the previously saved (day before) files.

As you may already know it's especially important with websites that you have progressive saves of the database in case you find a problem that requires you use a version of your site that happened 7 days previously.  If you are new to scripting then all of this may not be something you will understand right off the bat, but eventually you'll understand the power of using the date function within your scripts when saving files.  Essentially what this date function does is add a time stamp to the end of your file name so that it is completely unique because it's based off the current time of when the file is being saved. 

What I did in my case was create a small script called websiteback.sh that I then placed in a bin directory within my home such as /root/bin/websiteback.sh.  For this example I simplified the code within this file just for the sake of simplicity for those new to scripting.  Basically what this file contains a line for each database within my system as follows:

<-----Begin File Code----->
#!/bin/sh
/usr/local/bin/mysqldump -u root --password=aBcD1234 dataBaseName > /location/you/want/to/save/backup/dataBaseName.`date +%m%d%Y%H%M%S`

/usr/local/bin/mysqldump -u root --password=aBcD1234 dataBaseName2 > /location/you/want/to/save/backup/dataBaseName2.`date +%m%d%Y%H%M%S`
<-----End File Code------>

The first line executes this file as a shell script via sh which needs to be set as an executable otherwise it will not run.  See man chmod if you aren't sure how to set it executable. 

Once you have created this file, the only thing left to do is create a cron job to execute the above file on a daily basis.  For example you would create a cron job like the following:

0 8 * * * /root/bin/websiteback.sh

See man crontab for more information about how to set a cron job within FreeBSD.  That's all there is to it! 

Using the date function is very versatile and you can use it directly within your scripts and can use them within paths as I've shown above.  I hope you find it as useful as I do and if you have any questions or comments, please feel free to post them here. 



Friday, November 30, 2007 @ 23:16:20 EST
(comments? | Scripting | Score: 5)

Hacks Members
Your IP: 38.103.63.57

Welcome, Anonymous
Nickname
Password
Security Code
Security Code
Type Security Code


· Register
· Lost Password
Server Date/Time
6 January 2009 15:32:25 EST (GMT -5)

Related Links


Random Headlines

gentoo
[ gentoo ]


Big Story of Today
There isn't a Biggest Story for Today, yet.

Old Articles
There isn't content right now for this block.

Information

Powered by RavenNuke(tm)


1: Credit Repair Combat
39 times
2: My Internet Business
52 times
0.646 Seconds