Skip to content

Instantly share code, notes, and snippets.

@chathudan
Last active September 9, 2022 11:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chathudan/10a46c9b403378aef82fbfba7e4b10b6 to your computer and use it in GitHub Desktop.
Save chathudan/10a46c9b403378aef82fbfba7e4b10b6 to your computer and use it in GitHub Desktop.

free -m to see memory statistics

df -h to see disk usage statistics

du -h --max-depth=1 | sort -hr

ls -ld .?* Will only list hidden files

ls -a List All Files

How To Find your Server's Public IP Address

ip addr show eth0 | grep inet | awk '{ print $2; }' | sed 's/\/.*$//'

UFW firewall

sudo ufw app list

Rename files to uppercase

for f in * ; do mv -- "$f" "$(tr [:lower:] [:upper:] <<< "$f")" ; done

To Get Server's IP addres

ip addr show eth0 | grep inet | awk '{ print $2; }' | sed 's/\/.*$//'

MySQL

Import an SQL file using the command line in MySQL?

mysql -u username -p database_name < file.sql

Reset the MySQL 5.7 root password in Ubuntu 16.04 LTS

Stop MySQL

sudo service mysql stop

Make MySQL service directory.

sudo mkdir /var/run/mysqld

Give MySQL user permission to write to the service directory.

sudo chown mysql: /var/run/mysqld

Start MySQL manually, without permission checks or networking.

sudo mysqld_safe --skip-grant-tables --skip-networking &

Log in without a password.

mysql -uroot mysql

Update the password for the root user.

UPDATE mysql.user SET authentication_string=PASSWORD('YOURNEWPASSWORD'), plugin='mysql_native_password' WHERE User='root' AND Host='%'; EXIT;

Turn off MySQL.

sudo mysqladmin -S /var/run/mysqld/mysqld.sock shutdown

Start the MySQL service normally.

sudo service mysql start

Update NodeJs

Use n module from npm in order to upgrade node

sudo npm cache clean -f sudo npm install -g n sudo n stable

sudo ln -sf /usr/local/n/versions/node/<VERSION>/bin/node /usr/bin/nodejs (NOTICE that the default installation for nodejs is in the /usr/bin/nodejs and not /usr/bin/node)

To upgrade to latest version (and not current stable) version, you can use

sudo n latest

To undo:

sudo apt-get install --reinstall nodejs-legacy # fix /usr/bin/node sudo n rm 6.0.0 # replace number with version of Node that was installed sudo npm uninstall -g n

PHP

To check PHP running user

sudo ps wwaux | grep php7-fpm

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment