Wednesday, November 24, 2010

I lost/forgot mysqld root password

Oops, it happens, you install quickly set a good password then promptly forget to record it.
What a pain, but easily remedied using the command line!
  1. stop mysqld
    service mysqld stop 
  2. create a text file for example mysqld.reset.password containing the following 2 lines
    update mysql.user set password=password('yournewpassword') where user='root';
    flush privileges;
  3. load mysqld using the text file as input
    mysqld_safe --init-file ~/mysqld.reset.password
  4. delete your text file, for cleanliness & security reasons
    rm ~/mysqld.reset.password
  5. start mysqld
    service mysqld start

Monday, September 27, 2010

Which Linux should I use ???

This is a huge bombshell of a question because there are many implementations of Linux,  and some people are attached to distros passionately.  So I am going to concentrate on a few mostly  Redhat and Debian based in this post. I will not even try to cover everything, that would be crazy...

I moved this to a static page instead of a blog post as I've been updating it occasionally see   Which Linux should I use ??? page

Tuesday, August 17, 2010

Set up LAMP stack on Fedora

LAMP = Linux Apache MySQL PHP
(I set this up for a class I was teaching they were using Fedora 13, it is of course easily adaptable for CentOS or RHEL)
Fedora comes with Apache (httpd) installed and mysql client but it is missing a few things to complete the LAMP stack.  So a little work is required to get everything set up.  All of the following are systems administration tasks and must be done as root user:

Once you complete this you can install Wordpress, Mediawiki, Tikiwik etc.  Or if you want to build your own application start with this tutorial IBM DeveloperWorks Introduction to LAMP

These  instructions are also applicable to Centos 5.x.  Be aware that where it says install / update you may need to do one or the other depending upon your install.


Apache  http://httpd.apache.org/docs/2.2/
  1. yum update httpd -y
  2. service httpd start  
  3. chkconfig httpd on
    make sure it starts up when we reboot
  • Note: main configuration file /etc/httpd/conf/httpd.conf, others in /etc/httpd/conf.d./*
MySQL Server http://dev.mysql.com/doc/refman/5.6/en/index.html
  1. yum install mysql-server -y
  2. service mysqld start
  3. chkconfig mysqld on
    make sure it starts up when we reboot
  4. mysql_secure_installation
    secure the install a little bit!
  5. yum install phpmyadmin -y
    the browser/web interface for mysql
  6. service httpd restart 
  7. Optional create a database:
    1. mysql -u root -p
    2. mysql> create database testing;
    3. mysql> grant all on testing.* to 'userx' identified by '123pass';
    4. mysql> quit
    5. mysql -u userx -p
    6. mysql> show databases;
    7. mysql> quit
    • or you can do the same thing using http://localhost/phpMyAdmin
    • Note: phpMyAdmin defaults to respond only to a localhost client, to allow other hosts to use it you must modify /etc/httpd/conf.d/phpMyAdmin.conf:
      1. Locate the line(s)   Allow from 127.0.0.1
      2. Add a line below it  
        Allow from 192.168.10.0/24 

        where 192.168.10.0/24 is your network
      3. save the file
      4. service httpd reload


    PHP http://ca3.php.net/tut.php
    1. yum -y update php php-mysql
    2. If you are using Tikiwiki  you may also need the php & gd connection: yum install php-gd -y 
    3. service httpd reload
    4. create a file /var/www/html/hello.php containing:
    5. Load the file in a browser   http://localhost/hello.php
      if you see the text hello world, you are ready to go
    6. Optional 
      1. create a file /var/www/html/phpinfo.php
      2. load the file in a browser http://localhost/phpinfo.php
    Firewall tcp ports to open:
    • 80 for  apache/httpd (443 for https)
    • 3306 for mysql

    Thursday, July 8, 2010

    Remote control your Linux box (VNC ~= Remote Desktop on Windows)

    For those who visit or live in the Windows world the built in Remote Desktop client and server capabilities are quite handy for administrative tasks.  It allows you to log onto one Windows computer via another.

    Windows on the server side (the one you want to control, not necessarily a server)
    • right click on My Computer > Properties > Remote tab
    • ensure that remote Desktop "Allow Connections" is selected

    Windows on the client side
    • (Win 7 / Vista) All Programs > Accessories > Remote Desktop
    • (Win XP) All Programs > Accessories > Communications > Remote Desktop  
    pop in the host name & click on connect.


    While administrators of Linux boxes generally will connect using ssh, to use a command line interface, the demand for GUI based remote control has increased.  So here are some instructions for configuring VNC on Linux if ssh & cli are not enough for you (note the instructions do not include ssh tunneling of VNC,  see future posts for tunneling):


    Linux server & client instructions Configure Fedora 12 - 13 VNC remote access 

    For a windows client download and install VNC Viewer it is a stand alone application.

    Monday, July 5, 2010

    Have fun with your neighbours!

    So somebody is piggy backing on your wireless network?


    I am of the mind that it's no harm no foul if someone occasionally uses my wireless.  I also support the ideas and use of http://www.ilesansfil.org/  but where I live it hasn't been adopted much, I think it has to do with population density 'burbs vs urbs?? 


    However if someone is slowing your network or using it for nefarious purposes you may want to lock them out or mess with their heads:

    The essential idea is that you split your network into trusted and unknown using DHCP.  Then you have some fun with the unknowns: the two suggestions are
    1. send all traffic to kittenwar.com 
    2. reverse all of the images  using a simple perl script &  the mogrify binary from ImageMagik
    I'm sure you could come up with something else !! 


    You may find instructions here:
    http://www.ex-parrot.com/pete/upside-down-ternet.html

    Tuesday, June 29, 2010

    Using iso file contents

    So you have an iso file & want to see what's on it ?? 

    These are systems administration type tasks and must be done as root (su - to root, or sudo)


    An iso is  a file system so you have to mount it as you would any other file system:

    1. create a mount point mkdir -p /mnt/iso
    2. mount -o loop -t iso9660 yourisofile.iso /mnt/iso 
    3. look at the files under the tree ls -l /mnt/iso
    Again we don't need anything that doesn't come with a linux install!


    Use the man pages:
    man mkdir
    man mount
    man ls

    Creating iso files

    On linux (& unix type boxes) it is easy to create an ISO file no extra software is needed, we use the dd command.  d(isk)d(ump) is one of the core gnu utilities and should be installed by default on all but the most lean implementations.

    These are systems administration type tasks and must be done as root (su - to root, or sudo)

    From a CDROM or DVD
    1. Open a terminal session.
    2. for a CD:  dd if=/dev/cdrom  of=thenameofmycd.iso
    3. for a DVD: dd if=/dev/dvd  of=thenameofmydvd.iso  

      dd is disk dump, if is in file, of is out file

    From a files on  disk drive
    1. Open a terminal session.
    2. mkisofs -o thenameofmy.iso      file(s) and/or directory(ies)

      n.b. mkisofs will create an hybrid file system (ISO9660  in this case)
    These are the simplest forms of use for the two commands, use the man pages: 
    *man dd
    *man mkisofs