UNIX: Bash password input

read -s -p "Password: " mypasswd

or

stty -echo
read -p "Password: " mypasswd
stty echo

CENTOS: Installing Git 1.7.4.4 on 5.5

Using CentOS for the first time today, and boy did it bring back horrible memories of Unix in the ucsd computer dungeon...

Anyway, since it was a new installation of CentOS 5.5, installation required LOTS of updates...

1. log into root (su root)
2. wget http://kernel.org/pub/software/scm/git/git-1.7.4.4.tar.gz
3. tar -zxf git-1.7.4.4.tar.gz
4. cd git-1.7.4.4

let's just run the installation so that we can see what libs we are missing...

5. make prefix=/where-ever-i-want/git all

if you receive the following kind of error, you need to update/install packages...

expat.h: No such file or directory (yum install expat-devel)
zlib.h: No such file or directory (yum install zlib-devel)
openssl/ssh.h: No such file or directory (yum install openssl-devel, yum install curl-devel)
openssl/err.h: No such file or directory

you get the idea...

6. once installation completes, now you can install libs/binaries to the prefix directory...

7. make prefix=/where-ever-i-want/git install

OSX: Adding new user on 10.6

dscl . -create /Users/username
dscl . -create /Users/username UserShell /usr/bin/false
dscl . -create /Users/username RealName "User description"
dscl . -create /Users/username UniqueID ###
dscl . -create /Users/username PrimaryGroupID ###
dscl . -create /Users/username NFSHomeDirectory /dev/null
dscl . -passwd /Users/username PASSWORD

view users' full configs:

dscacheutil -q user

view particular user's full config:

dscacheutil -q user -a name username

view user's uid only:

dscl . list /Users uid

view group's gid only:

dscl . list groups gid

OSX: Installing mysql on 10.6

1. Download mysql-5.0.92.tar.gz

2. Unpackage to /usr/local/mysql-5.0.92/

3. Create symlink mysql

cd /usr/local/
ln -s /usr/local/mysql-5.0.92/ mysql

4. Open Terminal and set temporary PATH

export PATH=$PATH:/usr/local/mysql/bin

5. Create 2 folders

mkdir tmp
mkdir var

6. Configure mysql
./configure --prefix=/usr/local/mysql \
--with-extra-charsets=all \
--enable-thread-safe-client \
--with-unix-socket-path=/usr/local/mysql/tmp/socket \
--with-mysqld-user=mysql \
--with-comment \
--with-debug

7. Install mysql

make
make install

8. If during the installation process you encounter the following error:
/usr/bin/install -c 'bench-count-distinct' '/usr/local/mysql/sql-bench/bench-count-distinct'
install: bench-count-distinct and /usr/local/mysql/sql-bench/bench-count-distinct are the same file
make[3]: *** [install-benchSCRIPTS] Error 64
make[2]: *** [install-am] Error 2
make[1]: *** [install-recursive] Error 1

You aren't alone, the problem is with the OS and directory name resolution. The fix is to simply ignore these errors.

option A. make -i install

option B. edit /usr/local/mysql/sql-bench/Makefile line 418

from:

$(...) "$$d$$p" "$(DESTDIR)$(benchdir)/$$f"; \

to:

$(...) "$$d$$p" "$(DESTDIR)$(benchdir)/$$f" 2>/dev/null | wc -l; \

9. installing the database

sudo /usr/local/mysql/bin/mysql_install_db --force

10. create mysql user

dscl . -create /Users/mysql
dscl . -create /Users/mysql UserShell /usr/bin/false
dscl . -create /Users/mysql NFSHomeDirectory /dev/null
dscl . -passwd /Users/mysql PASSWORD

11. giving permission to mysql to write files

sudo chown -R mysql /usr/local/mysql

12. running the database (sudo is needed unless you are running from mysql account/root)

sudo /usr/local/mysql/bin/mysqld_safe --user=mysql &

13. creating a database root user

/usr/local/mysql/bin/mysqladmin -u root password rootpwd

14. stop running databases

/usr/local/mysql/bin/mysqladmin shutdown

15. as was the case with the tomcat server, here's a mini script that can simplify starting and shutting down the mysql server
#!/bin/bash
export PATH=$PATH:/usr/local/mysql/bin
if [ "$1" == "start" ]; then
sudo mysqld_safe -user=mysql &
elif [ "$1" == "stop" ]; then
sudo mysqladmin shutdown
elif [ "$1" == "info" ]; then
mysqladmin version
else
echo "Command: mysql [start|stop|info]"
fi

OSX: Installing tomcat on 10.6

TO INSTALL TOMCAT

1. Download jakarta-tomcat-x.x.xx.tar.gz

2. Unzip to /usr/local/tomcat-x.x.xx/

3. Create symlink tomcat

cd /usr/local/
ln -s /usr/local/tomcat-x.x.xx/ tomcat

4. Use the following script to start/stop tomcat
#!/bin/bash

export CATALINA_BASE=/usr/local/tomcat
export CATALINA_HOME=/usr/local/tomcat
export CATALINA_TMPDIR=/usr/local/tomcat/temp
export JRE_HOME=/*dir to java home*/
export CLASSPATH=/usr/local/tomcat/bin/bootstrap.jar

if [ "$1" == "start" ]; then
$CATALINA_HOME/bin/startup.sh
elif [ "$1" == "stop" ]; then
$CATALINA_HOME/bin/shutdown.sh
else
echo "Command: tomcat [start|stop]"
fi

5. Assuming the script's path is ~/tomcat, start the server using

~/tomcat start

6. Assuming the script's path is ~/tomcat, stop the server using

~/tomcat stop

OSX: Making symbolic links (folder aliases)

If you navigate to /Library/Java, you will notice there's a folder alias in there called Home, which maps to /System/.../Home

If you do an ls -l on the /Library/Java directory, you will see the following:

lrwxr-xr-x 1 xxxx xxxx xx xxx xx xx:xx Home -> /System/.../Home

This is a symbolic link, NOT to be confused with Aliases, and creating one is actually much easier than I thought.

First, to create an Alias, you just right click on a folder, and select Make Alias. This creates a 'shortcut file', not a symbolic link. Case in point, try typing the ls command on the folder shortcut you just made, Terminal will complain that the alias is NOT A DIRECTORY.

To create the symbolic link, you'd type the following:

ln -s /actual/dir/location/ linkname

Now you can ls on the linkname which will spit out the structure for /actual/dir/location/