• Skip to main content

Uly.me

cloud engineer

  • Home
  • About
  • Archives

Archives for September 2019

Get Directory Size

September 7, 2019

Here’s how to get the size of a directory.

du -sh /var/www

du -sh /var/www

Output:

2.1GB    /var/www

2.1GB /var/www

Size of the directories and files one level down.

du -sh /var/www/*

du -sh /var/www/*

Sort with biggest files from top to bottom.

du -sh /var/www/* | sort -rh

du -sh /var/www/* | sort -rh

Top 5 biggest files from top to bottom.

du -sh /var/www/* | sort -rh | head -5

du -sh /var/www/* | sort -rh | head -5

Filed Under: Linux Tagged With: directory, linux, size

Git Diff Head

September 3, 2019

Here’s how to check what’s changed in your local Git repo vs the master repo.

Git Status tells you what file has changed, but not to the level of detail such as what lines or what code was changed.

git diff HEAD

git diff HEAD

Filed Under: Git Tagged With: compare, diff, git, head

Diff Between Two Directories

September 2, 2019

Here’s how to get the differences between two directories using diff.

  • -q display only files when they differ
  • -r recursive to all sub-directories
diff -qr /directory-1 /directory-2

diff -qr /directory-1 /directory-2

Filed Under: Linux Tagged With: diff, directories, recursive

Recover MySQL Root Password

September 2, 2019

How to recover a MySQL root password without a password.

  1. Stop MySQL.
  2. Start MySQL Safe Mode.
  3. Login to MySQL as root without password.
  4. Change root password.

# Stop MySQL.
service mysql stop
# MySQL Safe Mode.
mysqld_safe --skip-grant-tables &

# Stop MySQL. service mysql stop # MySQL Safe Mode. mysqld_safe --skip-grant-tables &

# Login to MySQL without password. Set new password.
mysql -u root -p
use mysql;
# For MySQL 5.6 or lower
UPDATE mysql.user SET Password=PASSWORD('newpassword') WHERE User='root';
# For MySQL 5.7 or higher
SET PASSWORD FOR 'root'@'localhost' = PASSWORD("newpassword");
FLUSH PRIVILEGES;
exit;

# Login to MySQL without password. Set new password. mysql -u root -p use mysql; # For MySQL 5.6 or lower UPDATE mysql.user SET Password=PASSWORD('newpassword') WHERE User='root'; # For MySQL 5.7 or higher SET PASSWORD FOR 'root'@'localhost' = PASSWORD("newpassword"); FLUSH PRIVILEGES; exit;

# Kill mysqld
killall mysqld
# Restart MySQL
service mysql start

# Kill mysqld killall mysqld # Restart MySQL service mysql start

I ran into issues running MySQL Safe mode. I got a “UNIX socket file don’t exists” error. Here’s the fix.

mkdir -p /var/run/mysqld
chown mysql:mysql /var/run/mysqld

mkdir -p /var/run/mysqld chown mysql:mysql /var/run/mysqld

Filed Under: Cloud, Linux Tagged With: error, mysql, password, recover, reset, root, safe mode, unix file socket

  • « Go to Previous Page
  • Go to page 1
  • Go to page 2
  • Go to page 3
  • Go to page 4
  • Home
  • About
  • Archives

Copyright © 2023