Category Archives: Linux

The Linux Category actually encompasses *BSD, RH, Fedora, Ubuntu, and the like.

Reset MySQL Password

I setup a LAMP server for a developer a while back and he changed the passwords for root and the root mysql user to something besides my defaults. So when he asked me to give him the password for the database, I could not really help him out. Or could I?

Stop the mysql services:
/etc/init.d/mysql stop

Start mysql without the passwords:
mysqld_safe --skip-grant-tables &

Connect to the safe mysql:
mysql -u root

Set a new root password:
use mysql;
update user set password=PASSWORD("your_New_Password_here") where User='root';
flush privileges;
quit

Stop the safe mysql database:
/etc/init.d/mysql stop

Start mysql and test:
/etc/init.d/mysql start
mysql -u root -pYOURNEWPASSWORDHERE

*note – there is no space between -p and your password.

AND, in case you’re just wanting to change the password of a known user:
mysqladmin -u root -pOLDPASSWORD password NEWPASSWORD

Mount NFS on Ubuntu

Basic LAMP Ubuntu 10.04.2 LTS trying to mount NFS share from a FreeNAS 0.7.2 system. I was running the following command:

mount -t nfs 10.10.0.99:/mnt/hotswap/NFS/ /mnt/freenas/

and receiving the following error

mount: wrong fs type, bad option, bad superblock on 10.10.0.99:/mnt/hotswap/NFS/,
missing codepage or helper program, or other error
(for several filesystems (e.g. nfs, cifs) you might
need a /sbin/mount. helper program)
In some cases useful info is found in syslog – try
dmesg | tail or so

Awesome. So I tried with the -o ‘vers=3’ command just in case. Same issues persist.

It looks like the common NFS files are missing in the vanilla ubuntu server installation:
apt-get install nfs-common
Rerun the mount command is successful

And, since I like to create NFS on ubuntu as well:
apt-get install nfs-kernel-server
nano /etc/exports
Add:
/path/to/share Hostname(rw,sync,no_root_squash)
or in my case
/NFS *(rw,sync,no_root_squash)
Then restart nfs
/etc/init.d/nfs-kernel-server restart

iFolder

I was tasked with removing access to dropbox, but also with creating an internally-hosted dropbox-like solution. This is about as creative as I could get as most of the users were on Windows, with another handful of developers using their Macs:
iFolder 3.8.x

Installed Ubuntu 10.04.2 LTS x32
LAMP, MySQL, Mail Server

Change the password for the root user
sudo passwd root

Log in as root
su

Add the PPA repositories to your system
nano /etc/apt/sources.list
Add the following lines at the bottom of the file:

deb http://ppa.launchpad.net/marceloshima/ifolder/ubuntu lucid main
deb-src http://ppa.launchpad.net/marceloshima/ifolder/ubuntu lucid main

Save and Close
Add the signing of the packages
sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys ED649F97DE6BFD99
Test configuration
apt-get update

Install ifolder3-enterprise
apache2ctl stop
apt-get install ifolder3-enterprise

Create the self-signed cert/Allow Apache features
make-ssl-cert generate-default-snakeoil
a2enmod ssl
a2enmod rewrite

Link the conf files
ln -sf /etc/ifolder-server/apache/ifolder_apache.conf /etc/apache2/conf.d/
a2ensite default-ssl

Install .net files
apt-get install liblog4net1.2-cil
apache2ctl restart

Test by navigating to http://IPADDRESS/admin
You must create a user before you can use http://IPADDRESS/ifolder or the locally installed applications.

To change any configuration, just run either of these commands:
ifolder-admin-setup
ifolder-web-setup

Molly-Guard

After having someone reboot the wrong linux machine (again), we decided to take some action:

apt-get install molly-guard

This works on Debian/Ubuntu systems. After install, try running reboot or shutdown commands – the molly-guard will force you to type in the name of the system you’re trying to reboot/power off before it will actually allow the command to continue.

RHEL 3 or 4 Updates via CLI

I had the opportunity to work on a Red Hat Enterprise Linux box that was running version 3 of the software – but I’ve been told this should work on 3 or 4 (and possibly 2, but who cares about 2 anymore?). Starting with 4 and perhaps 5 through 6 you can use:
yum update

But before these good days, you had to use:
up2date -l
Lists all the available updates
up2date -u
Download and update all available packages (not kernels)
up2date -uf
Download and update all available packages
up2date PACKAGENAME
Update specific packages (up2date php for example)

Change the From Address for Users Emails

I was running a cron job script:
cat /var/log/syslog | mailx -s "Server 48 - Syslog - Daily" email@domain.tld
Unfortunately I setup all these cronjobs as root. All emails were showing up as from “root@domain” or “root@server”, or even just plain “root”. Awesome.

So here’s the easiest way to fix this issue:
chfn
Then change the information for first/last/etc. This will change it for the CURRENTLY LOGGED IN USER.

Otherwise you can always just run:
chfn -f "Full name" root
Usage is chfn [-f full_name] [-r room_no] [-w work_ph] [-h home_ph] [-o other] [user]