Kevin Hatfield's Blog

Kevin's blurry train of thought……

Posts Tagged ‘tutorial’

UNIX Commands Cheat List!

Tuesday, January 13th, 2009


Unix commands cheat list

This is nothing more than a place for me to jot down all the *nix commands that I have a hard time remembering. It is not a tutorial, and all the information here is to be used at your own risk. The commands here are used for either freeBSD 5.3, OS X 10.3 or both.

1. Flush the DNS cache:

lookupd -flushcache

2. Run CPAN in shell mode:

perl -MCPAN -e shell

3. Start, Stop, Restart Apache:

apachectl start
apachectl stop
apachectl restart

4. Shutdown and reboot:

shutdown -R now

5. Show disk space:

df -k (in Kb)
df -m (in Mb)
df -g (in Gb)

6. Show disk usage:

du -hc

7. Show disk usage one folder deep:

du -hc -d1

8. Show running processes:

ps aux

9. Edit the Apache configurations file (for freeBSD):

pico /usr/local/etc/apache/httpd.conf

10. Edit the Apache configurations file (for OS X):

pico /private/etc/httpd/httpd.conf (for Apache 1.3)

11. Run the install utility for freeBSD:

/stand/sysinstall

12. Rebuild the access or virtualusertable databases after editing /etc/mail/access or /etc/mail/virtusertable :

make maps

13. Dump a MySQL database:

mysqldump -u USER -pPASSWORD DBNAME > filename.sql

14. Import from a dump file into MySQL:

mysql -u USER -p DBNAME < filename.sql

15. Grab your most important configuration files and email them to yourself:

tar cvfz - /etc/rc.conf /etc/master.passwd /etc/fstab /usr/local/etc | uuencode seedfiles.tgz | mail -s “Web Server Seed Files” someguy@someserver.com

16. Configure Apache 2 from source with the proper modules:

sudo ./configure --prefix=/apache2 --enable-cgi=yes --enable-cgid=yes --enable-dav=yes --enable-expires=yes --enable-headers=yes --enable-info=yes --enable-rewrite=yes --enable-so=yes --enable-speling=yes --enable-ssl=yes --enable-usertrack=yes --enable-vhost-alias=yes

17. Change the mySQL password:

mysqladmin -u root password 'new password goes here'

18. rsync for dummies:

rsync -r --stats --progress --exclude 'some wildcard' /from/some/folder /to/some/other/folder

19. PHP5 on OS X:

http://www.entropy.ch/software/macosx/php/ has a ready to run installer with every possible option turned on. Saves a hell of a lot of hassle.

20. CVS – How to set the CVSROOT in bash:

Put this in .bashrc:
CVSROOT=/usr/local/cvsroot
export CVSROOT

21. CVS – How to set your default editor to pico instead of vi:

EDITOR=pico
export EDITOR

22. CVS – Checkout

(from the folder you want to hold the checked out code)

cvs checkout project

23. CVS – Commit

(from within the working folder)

cvs commit

It will open pico so you can type an explanation of the changes commited.

24. CVS – Refresh working copy

(from within the working folder)

cvs update

I don’t trust this one 100%, so every now and then I re-check out the source.

25. Webmin

A great way to easily manage *nix servers is Webmin. I use it on both freeBSD and it is pretty damn nice. While some of its modules are a bit rustic, overall it beats the hell out of having to use the CLI for annoying stuff.

26. Split a file based on a separation string

csplit -k -f output_file_prefix source_file_name '/separation string/' {99}

99 is the number of times top repeat the command. In the unix flavor of split you can do {*}, but OS X doesn’t like it so I am setting it to 99.

27. Run the Apache Bench:

ab -n100 -c20 http://www.mydomain.com/

Where 100 is the number of iterations and 20 is the number of concurrent hits.

28. Default admin web site for Smoothwall Express:

https://smoothwall.yourdomain.com:441/

29. Recursive find:

find . -iname "*\?*"

finds anything with the escaped character (in this case a question mark) within your current folder.

30. ftp upload from command line:

This one falls under “annoying quirks of OS X.” I wasted over one hour trying to decypher the man page for ftp for 10.4 because it would not let me upload a file from a compressed one-line command within a bash script. Here is the one that worked:

ftp -u ftp://$USER:$PASSWORD@$FTPSERVER/$FTPFOLDER/$REMOTE_FILENAME $LOCAL_FILENAME

This one worked like a champ.

Excellent Tutorial for FreeBSD Server Installation

Sunday, October 28th, 2007

a basic FreeBSD server install

When it comes to servers, I have always preferred FreeBSD as my operating system of choice. Maybe it’s the cute devil mascot, maybe it’s the amazing stability it offers, maybe it’s just what I’m used to, but I love it! In this article, I’ll discuss how to set up a very basic, bare-bones FreeBSD server installation.

The first thing you need, obviously, is FreeBSD itself! FreeBSD is free, open-source software licensed under the BSD License. You can obtain a copy at http://www.freebsd.org. I will be using the version 6-2-RELEASE boot-only ISO. This ISO will boot into the FreeBSD kernel and start the sysinstall utility. A direct link is available here: ftp://ftp.freebsd.org/pub/FreeBSD/releases/i386/ISO-IMAGES/6.2/6.2-RELEASE-i386-bootonly.iso. You can choose to use the full ISOs available in the same directory on the FTP site. Go ahead and burn your ISO(s) using whichever software you prefer and boot the computer with the CD.
FreeBSD installation:

Entire article here

Excellent FreeBSD Install Tutorial

Friday, October 12th, 2007

a basic FreeBSD server install

When it comes to servers, I have always preferred FreeBSD as my operating system of choice. Maybe it’s the cute devil mascot, maybe it’s the amazing stability it offers, maybe it’s just what I’m used to, but I love it! In this article, I’ll discuss how to set up a very basic, bare-bones FreeBSD server installation.

The first thing you need, obviously, is FreeBSD itself! FreeBSD is free, open-source software licensed under the BSD License. You can obtain a copy at http://www.freebsd.org. I will be using the version 6-2-RELEASE boot-only ISO. This ISO will boot into the FreeBSD kernel and start the sysinstall utility. A direct link is available here: ftp://ftp.freebsd.org/pub/FreeBSD/releases/i386/ISO-IMAGES/6.2/6.2-RELEASE-i386-bootonly.iso. You can choose to use the full ISOs available in the same directory on the FTP site. Go ahead and burn your ISO(s) using whichever software you prefer and boot the computer with the CD.
FreeBSD installation:

Boot your soon-to-be server with the ISO you’ve just created and when the boot menu comes up, select option 1 or just wait and it will boot into the OS for you. The first screen you see should be the Country Selection screen:

Read More Here