• Skip to main content

Uly.me

cloud engineer

  • Home
  • About
  • Archives

root

Resizing XFS root partition in GCP

July 16, 2021

How to resize a root partition in GCP.

Increase disk size.

gcloud compute disks resize server-boot-disk-name \
--size=50GB \
--zone us-central1-c \
--project your-project-id

gcloud compute disks resize server-boot-disk-name \ --size=50GB \ --zone us-central1-c \ --project your-project-id

Run growpart.

growpart /dev/sda 1

growpart /dev/sda 1

Run xfs_growfs.

xfs_growfs /dev/sda1

xfs_growfs /dev/sda1

To verify, run these.

lsblk
df -Th

lsblk df -Th

Filed Under: Cloud, Linux Tagged With: boot, extend, gcp, growpart, root, xfs, xfs_growfs

Sudoers File Explained

June 30, 2021

You are probably wondering how the sudoers file works. Here’s a simple explanation.

Command

username host=(user:group) tag:commands

username host=(user:group) tag:commands

Explanation

    • username – the specified user allowed to run commands.
    • host – the specified host the command is allowed to run.
    • user – specifies which users can use the command.
    • group – specifies which groups can run the command.
    • tag – the option allowed. NOPASSWD
    • command – the command allowed to run.

Examples

root    ALL=(ALL) ALL
username ALL=(ALL) ALL
john test=(ALL) NOPASSWD: /bin/useradd
jane ALL=(sales) NOPASSWD: /bin/sh
%sudo ALL=(ALL) ALL
%adgroup ALL=(ALL) ALL

root ALL=(ALL) ALL username ALL=(ALL) ALL john test=(ALL) NOPASSWD: /bin/useradd jane ALL=(sales) NOPASSWD: /bin/sh %sudo ALL=(ALL) ALL %adgroup ALL=(ALL) ALL

Filed Under: Linux Tagged With: access, root, sudo, sudoers

Set Immutable Attribute

November 27, 2019

If you don’t want a file edited or deleted, you can set the immutable attribute to ON. If activated, not even root or the owner of the file can delete it. Users with write access can still read it, but they obviously will not be able to modify it. To unset it, just use the -i option.

# Set immutable attribute
sudo chattr +i text.txt
 
# Unset immutable attribute
sudo chattr -i text.txt

# Set immutable attribute sudo chattr +i text.txt # Unset immutable attribute sudo chattr -i text.txt

Filed Under: Linux Tagged With: attribute, delete, immutable, read, root, write

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

Change MySQL Password

October 8, 2015

The following are instructions on how to change your MySQL password from the Unix command line.

Login to MySQL and access MySQL table.

mysql -u root -p
use mysql;

mysql -u root -p use mysql;

Change the password for any user, flush privileges and quit.

update user set password=PASSWORD('new_password') where User='root';
flush privileges;
quit

update user set password=PASSWORD('new_password') where User='root'; flush privileges; quit

Make sure to make password changes on your applications as well.

In WordPress, edit the wp-config.php file to change database password.

Filed Under: Linux, WP Tagged With: mysql, password, root

  • Home
  • About
  • Archives

Copyright © 2023