Thursday, January 28, 2010

How to determine the size of a file on Linux

I just need to document this one for future reference. Though its very basic but very important on daily sydadmin work. Hopefully, this can help others too.

1. Move the the directory of the file you wish to view the size of.
2. Once in the directory, perform one of the below commands.

ls -l ztibugol.tar.gz

Performing the above command would list output similar to the below information.

-rw-r----- 1 atats atats 11567230 July 07 01:12 ztibugol.tar.gz

In the above output example, the 11567230 is the size of the file. For a more user friendly output, use the du command as shown below.

du -h ztibugol.tar.gz

This command would display the output "12M ztibugol.tar.gz"

If you wish to see the total size of multiple files, type a command similar to the below command.

du -ch *tar.gz

In the above example, the command would list every .tar.gz file in the current directory, display the size of each of those files as it was listing the files, and the total of all the files combined.

Til next time folks...

For further reference, you can check it here.

Friday, January 1, 2010

How to reset/change MySQL root password

I think I should need to post this one so that I can remember if ever I will encounter it again. I tried to study Drupal again for some reason and suddenly when I try to check the database I forgot to note down its root password. Now here comes my Google friend and it helps me out found answers to solved my problem.

Here are the four steps to undertake the process: (By the way, I test this on Jaunty and I could not guarantee if it works also on other Linux distro. But I am 90% sure that it will.)

1. We need to stop mysql from running.

sudo /etc/init.d/mysql stop

2. And then start the mysql configuration.

sudo mysqld --skip-grant-tables &

Before I forgot, on this command the process will not close. So you need to supply the third command.

3. Login to MySQL as root.

mysql -u root mysql

Then this command will login you to mysql command prompt.

4. Replace YOURNEWPASSWORD with your new password.

UPDATE user SET Password=PASSWORD('YOURNEWPASSWORD') WHERE User='root'; FLUSH PRIVILEGES; exit;

And please be reminded also that this method is not regarded as the safest way of resetting the password. However it works for me.

My reference on this one. Click here.