Resetting a lost MySQL root password on Ubuntu

Stop MySQL

The first thing to do is stop MySQL. If you are using Ubuntu or Debian the command is as follows:

sudo service mysql stop

Safe mode

Next we need to start MySQL in safe mode – that is to say, we will start MySQL but skip the user privileges table. Again, note that you will need to have sudo access for these commands so you don’t need to worry about any user being able to reset the MySQL root password:

sudo mysqld_safe --skip-grant-tables &

Note: The ampersand (&) at the end of the command is required.

Login

All we need to do now is to log into MySQL and set the password.

mysql -u root

Note: No password is required at this stage as when we started MySQL we skipped the user privileges table.

Next, instruct MySQL which database to use:

use mysql;

Reset Password

Enter the new password for the root user as follows:

update user set password=PASSWORD("mynewpassword") where User='root';

and finally, flush the privileges:

flush privileges;

Restart

Now the password has been reset, we need to restart MySQL by logging out:

quit

and simply stopping and starting MySQL.

On Ubuntu and Debian:

sudo service mysql restart

Login

Test the new password by logging in:

mysql -u root -p

You will be prompted for your new password.

Ref: http://www.rackspace.com/knowledge_center/article/mysql-resetting-a-lost-mysql-root-password

How to Fix the “Wi-Fi: No Hardware Installed” Error on Mac OS X

What is the System Management Controller?

The SMC is a subsystem in Mac computers that helps control power management, battery charging, video switching, sleep and wake mode, LED indicators, keyboard backlighting, and a bunch of other stuff.

When your computer goes in and out of sleep mode, the SMC will control what devices are powered down to save battery. And this is where the problem lies. The SMC gets the wrong signal and thinks the Wi-Fi adapter should stay powered off even when the computer comes back to life.

Resetting the System Management Controller (to Fix Your Wi-Fi Problem)

If you’re using a device that doesn’t have a removable battery, which is pretty much all devices that Apple has made for a very long time, you’ll need to close down your apps and then use a simple key combination.

Newer MacBook without a Removable Battery

  1. Plug the laptop into a power source
  2. Press and hold all of these keys at the same time: Control + Shift + Option + Power
  3. Release the keys
  4. Press the Power button to turn it back on

This should fix the problem

Original Article: http://www.howtogeek.com/227662/how-to-fix-the-wi-fi-no-hardware-installed-error-on-os-x/

Find a match pattern and rename whole file with that Match

I have hundred of id file with format like this

106527-Sup, Perman .jpg
106528-Iron, man .jpg
106529-Bat, man .jpg
106530-Spider, man .jpg

I need to rename them to

106527.jpg
106528.jpg
106529.jpg
106530.jpg

use perl-based rename:

rename 's/^(\d+).*jpg$/$1\.jpg/' *.jpg
rename 's/^(\d+).*$/$1.JPG/' *
  • ^ matches the position at the beginning of the input
  • \d+ matches one or more digit
  • .* matches everything in between
  • $ matches the position at the end of the input

The first group ($1) contains the digits you want to replace with.

http://stackoverflow.com/questions/32244473/linux-find-a-match-pattern-and-rename-whole-file-with-that-match

Batch convert wav folder to mp3 folder

[vc_row][vc_column][vc_column_text]I need to convert 3 DVD contain .WAV file to .MP3. I prefer command line way.

In my Ubuntu 14.04 install FFMPEG

sudo add-apt-repository ppa:kirillshkrogalev/ffmpeg-next
 sudo apt-get update
 sudo apt-get install ffmpeg

Go to the Wav folder and run this command

cd wav/
 for file in *.wav
 do ffmpeg -i "${file}" "${file/%wav/mp3}"
 done
 mkdir mp3dir
 mv *.mp3 mp3dir

Done![/vc_column_text][/vc_column][/vc_row]

Ubuntu 14.04 – Canon E500 network printing and scanning at home

Recently switch my Mom machine from Windows 7 to Ubuntu Gnome 14.04 which’s my favorite one. So I need to share Canon E500 (USB) printing and scanning for my other devices over Network.
I set this host with static IP: 192.168.1.10

Install Canon E500 driver

sudo add-apt-repository ppa:inameiname/stable

sudo apt-get update -y
sudo apt-get install -y cnijfilter-e500series scangearmp-e500series
Now I can add the printer from Printer Config
For Scanner: I use ScanGear instead of Simple Scan

Sharing Printer

This step is share printing service over network
Cups printing running on port 631 localhost -> go to CUPS admin at http://localhost:631/admin
In the Server part setting: Check these options
  • Share printers connected to this system
  • Allow printing from the Internet
  • Allow remote administration
  • Allow users to cancel any job (not just their own)  //this is my home purpose
=> Change Settings -> wait for Cup restarting
Manage E500 printer via CUPS. Now we need to access CUPS by its IP address, I also leave the printer name as E500-series
http://192.168.1.10:631/printers  make sure the printer E500-series is available otherwise add it to
From here you can print any test pages, maintenance, etc…I don’t need to set any allowed user. Just me and my mom

Sharing Scanner

On the server (E500 connect directly via USB) tell sane to run as server
sudo vi /etc/default/saned
Run=no -> Run=yes
Allow user from my subnet
sudo vi /etc/sane.d/saned.conf
## Access list
192.168.1.0/24
service saned restart
On the client
sudo vi  /etc/sane.d/net.conf
## saned hosts
192.168.1.10
connect_timeout = 60
Open Xsane and wait for Scanner discovery