Skip to content

Instantly share code, notes, and snippets.

@kangmasjuqi
kangmasjuqi / centos commands
Last active August 9, 2018 06:15
my commonly used centos commands
uname -a
who
whoami
/etc/hosts
cat /etc/*-release
cat /proc/meminfo
ll /etc/sysconfig/network-scripts/
nmtui
nmcli device
@kangmasjuqi
kangmasjuqi / allowance.py
Last active August 12, 2018 04:56
allowance - simulate allowance calculation based on the salary, the number of childrens and their age
##
## Bismillaahirrahmaanirrahiim..
## Allahumma sholli 'alaa sayyidinaa Muhammad..
##
## allowance.py
## created by marjuqi r.
## august 2018
##
## run using : python allowance.py
##
@kangmasjuqi
kangmasjuqi / fastest_car.py
Last active December 12, 2018 03:37
Calculate how many races needed to find N fastest cars
##
## Bismillaahirrahmaanirrahiim..
## Allahumma sholli 'alaa sayyidinaa Muhammad..
##
## fastest_car.py
## created by marjuqi r.
## august 2018
##
## run using : python fastest_car.py
##
@kangmasjuqi
kangmasjuqi / create_md5sum_all_file.sh
Last active August 13, 2018 12:40
generate md5sum keys for all files under targetted folder
#!/bin/bash
##########################################################################################
##########################################################################################
## Bismillaahirrahmaanirrahiim..
## Allahumma sholli 'alaa sayyidinaa Muhammad..
##
## create_md5sum_all_file.sh
## created by marjuqi r.
## august 2018
@kangmasjuqi
kangmasjuqi / mysql_engine_stats.sh
Last active September 7, 2018 03:09
view statictic/ highlight/ summary of mysql database
mysql -uroot
--
-- SHOW TABLES SIZE OF EACH DATABASES
--
SELECT
table_schema as `Database`,
table_name AS `Table`,
round(((data_length + index_length) / 1024 / 1024), 2) `Size in MB`
FROM information_schema.TABLES
@kangmasjuqi
kangmasjuqi / md5sum_create_and_check.sh
Last active September 19, 2018 09:24
working with MD5SUM
# find all files under current active directory
find -type f
# generate MD5SUM hash of all files under current active directory and store in file MDSUM.txt
find -type f | xargs -I{} md5sum {} > MD5SUM.txt
# validate the content of file MD5SUM.txt (files and their MD5SUM hash)
@kangmasjuqi
kangmasjuqi / show_linux_users_and_groups.sh
Last active September 7, 2018 03:08
working with Linux Users and Groups
# List users and their groups:
for user in $(awk -F: '{print $1}' /etc/passwd); do groups $user; done
# List groups and their users:
cat /etc/group | awk -F: '{print $1, $3, $4}' | while read group gid members; do
members=$members,$(awk -F: "\$4 == $gid {print \",\" \$1}" /etc/passwd);
@kangmasjuqi
kangmasjuqi / php_upgrade_into_v.7.sh
Last active September 7, 2018 03:07
PHP Upgrade to 7.x Version (on CENTOS)
cd ~
curl 'https://setup.ius.io/' -o setup-ius.sh
sudo bash setup-ius.sh
sudo yum remove php-cli mod_php php-common
sudo yum install mod_php70u php70u-cli php70u-mysqlnd
systemctl restart httpd
#ref : https://www.digitalocean.com/community/tutorials/how-to-upgrade-to-php-7-on-centos-7
@kangmasjuqi
kangmasjuqi / mysql_db_backup.sh
Last active September 7, 2018 09:39
working with mysql database backup
####################################################################################################
####################################################################################################
#
# ON-TIME BACKUP
#
# assuming we have large enough "/data" folder
# and we use root user without password
# then database will zipped using GZIP
@kangmasjuqi
kangmasjuqi / linux_mounting_device.sh
Last active September 10, 2018 09:23
how to mount device / drive on linux
fdisk -l
# we assume our new device/drive is named '/dev/sdb'.
fdisk /dev/sdb
################################################
[/sociallocker] Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel