Friday, November 3, 2023

Centos 7 reset root/ any user lost password / lockout due to cant remember password

1. Need to be in front of the terminal. (Physically if not vm).
2. Reboot the server
3. Press 'e' in the GRUB2 boot screen.

3. bunch of text will come out. We can edit those text. 

  • find the line that load the kernel - begins with 'linux16' in my case.
  • find text "rhgb quiet" , replace it with "rd.break enforcing=0".
  • When done. Press Ctrl X. The system will boot with the parameter edited.
[image text]
4. after boot. terminal prompt appear.

  • remount the root filesystem. "# mount -o remount,rw /sysroot"
  • set the environment to /sysroot "# chroot /sysroot/"
  • change desired password. root/any other user. "# passwd root"
  • when done. remount / to readonly back "# mount -o remount, ro /"
  • Then "# exit". 
  • Then "# exit" againsystem continue to boot.
  • login as root with the newly created password. DO NOT REBOOT YET.
  • SELinux will detect that the password file /etc/shadow has been changed and will restrict access to it).  Instead, you must first restore the SELinux labels on that file:
  • "# restorecon /etc/shadow".
  • Then reboot




Thursday, June 17, 2021

mysql_upgrade return error "Can't get stat of './mysql/general_log.CSV"

mysql_upgrade return error

Phase 3/6: Running 'mysql_fix_privilege_tables'
ERROR 13 (HY000) at line 286: Can't get stat of './mysql/general_log.CSV' (Errcode: 2 "No such file or directory")
ERROR 13 (HY000) at line 297: Can't get stat of './mysql/slow_log.CSV' (Errcode: 2 "No such file or directory")
ERROR 13 (HY000) at line 299: Can't get stat of './mysql/slow_log.CSV' (Errcode: 2 "No such file or directory")
ERROR 13 (HY000) at line 301: Can't get stat of './mysql/slow_log.CSV' (Errcode: 2 "No such file or directory")
FATAL ERROR: Upgrade failed

Solution:

elenstElena Stepanova added a comment - 2016-10-11 17:42

This is very strange that general_log.CSV and slow_log.CSV did not exist, do you know how it happened? Did somebody remove them manually?
Did general_log.frm and slow_log.frm files exist?
The most likely reason for the problem is that due to the disappearance of CSV files, the tables were left in an inconsistent state.
You can try to do the following:

# Make sure there are no remains of the table
- rm ./mysql/general_log.* ./mysql/slow_log.*
# connect to the server and run
[MariaDB]> FLUSH TABLES;
# Then re-run 
mysql_upgrade -uroot -p --force 

It should work unless somebody previously tried to convert general_log and slow_log tables into InnoDB, in this case things can be a bit more complicated.


source: https://jira.mariadb.org/browse/MDEV-11032

Wednesday, November 25, 2020

Apache get concurrent connection

Reference: https://www.cloudtechtiq.com/blog/check-apache-concurrent-connections-using-netstat-command


To Count Apache concurrent connection's, use any of the below commands.

netstat -nt | grep :80 | wc -l    
netstat -plan|grep :80 | wc -l    
netstat -an | grep 'EST' | wc -l    
netstat -ant | grep ESTABLISHED | grep :80 | wc -l    
ps -A | grep httpd | wc -l    
ps -ef | grep http | wc -l    
ps aux | grep httpd | wc -l    
ps aux | grep http | grep -v "\(root\|grep\)" | wc -l

To print the active Internet connections to the server at port 80 and sort the results, use the below commands.

netstat -an | grep :80 | sort 
netstat -plan | grep :80 
netstat -anp | grep :80

To calculate and count, number of connection currently established from each IP address with server.

netstat -ntu | awk '{print $5}' | cut -d: -f1 | sort | uniq -c | sort -n

To calculate and count, number of connection currently established from each IP address through TCP or UDP protocol with server.

netstat -anp |grep 'tcp\|udp' | awk '{print $5}' | cut -d: -f1 | sort | uniq -c | sort -n

To Print ESTABLISHED connections instead of all connections, and displays the connections count for each IP

netstat -ntu | grep ESTAB | awk '{print $5}' | cut -d: -f1 | sort | uniq -c | sort -nr

To print the list of IP address and its connection count, that connect to port 80 on the server.

netstat -plan|grep :80|awk {'print $5'}|cut -d: -f 1|sort|uniq -c|sort -nk 1

To print all the apache httpd actual processes in Linux, use the below commands.

ps -aux | grep httpd  or  ps -ef | grep httpd

Sunday, August 30, 2020

mysqldump comparison using compress option with bzip2 and gzip performance and the output size

[root@server2 vagrant]# time mysqldump --compress myportal | gzip  > test.gz

real 0m14.675s
user 0m7.426s
sys 0m0.618s
[root@server2 vagrant]# time mysqldump  myportal | gzip  > test.gz

real 0m9.455s
user 0m6.343s
sys 0m0.646s
[root@server2 vagrant]# time mysqldump --compress myportal | gzip  > test-compress-gzip.gz

real 0m14.603s
user 0m7.371s
sys 0m0.580s
[root@server2 vagrant]# time mysqldump  myportal | gzip  > test--gzip.gz

real 0m9.357s
user 0m6.314s
sys 0m0.668s
[root@server2 vagrant]# time mysqldump  myportal | bzip2  > test--bzip.bz2

real 1m10.520s
user 1m7.152s
sys 0m0.739s
[root@server2 vagrant]# time mysqldump --compress  myportal | bzip2  > test-compress-bzip.bz2

real 1m15.358s
user 1m7.156s
sys 0m0.773s

[root@server2 vagrant]# du -h test-*
6.7M test--bzip.bz2
13M test--gzip.gz
6.7M test-compress-bzip.bz2
13M test-compress-gzip.gz

[root@server2 vagrant]# du  test-*
6808 test--bzip.bz2
12376 test--gzip.gz
6808 test-compress-bzip.bz2
12376 test-compress-gzip.gz

bzip2 compress more than gzip but the process time is longer than gzip. 

So please choose between speed and compression ratio, which suite ur needs.

Tuesday, December 3, 2019

Show hidden files and sub directories in root directory

By default the root directory will not show you the directories like /usr/bin/etc etc. To make them visible you need to show the hidden files.

Open terminal and type the following command and hit return.

defaults write com.apple.finder AppleShowAllFiles -bool TRUE;killall Finder

Reference: https://themacbeginner.com/view-content-root-directory-mac-os-x/

Saturday, December 29, 2018

Mysql On delete cascade reference information

Tips to find tables affected by MySQL ON DELETE CASCADE action

Sometimes, it is useful to know which table is affected by the MySQL ON DELETE CASCADE  referential action when you delete data from a table. You can query this data from the referential_constraints in the information_schema  database as follows:

1
2
3
4
5
6
7
8
9
10
USE information_schema;
 
SELECT
    table_name
FROM
    referential_constraints
WHERE
    constraint_schema = 'database_name'
        AND referenced_table_name = 'parent_table'
        AND delete_rule = 'CASCADE'


Thursday, November 29, 2018

Wednesday, June 27, 2018

Tuesday, June 26, 2018

PHP / CentOS 7Connect DATABASE Error TYPE: 2002: Permission denied


9
down voteaccepted

I had the same issue after getting a new CentOS 7 box, running SELinux. I could connect to my remote MySQL DB server from the command line, but Drupal (and test PHP scripts) could not.

The issue turned out to be the SELinux security policies.

By default, the policy httpd_can_network_connect_db is disabled (meaning that your web server cannot contact a remote DB.)

Check this via:

getsebool -a | grep httpd

If httpd_can_network_connect_db is Off, enable it via:

setsebool -P httpd_can_network_connect_db 1

(The -P flag makes the change permanent, so the setting survives a reboot.)



Nginx php html permission denied

After searching , I found it.It's all deals with SELINUX which is a security feature. when using ls -Z

drwxrwxrwx. ec2-user root system_u:object_r:httpd_sys_content_t:s0 www

change this to

drwxrwxrwx. ec2-user root system_u:object_r:httpd_sys_rw_content_t:s0 www

using cmd

chcon -R -t httpd_sys_rw_content_t /var/www


Thursday, July 13, 2017

Sublime Text Licence

-----Begin----------

TwitterInc
200 User License
EA7E-890007
1D77F72E 390CDD93 4DCBA022 FAF60790
61AA12C0 A37081C5 D0316412 4584D136
94D7F7D4 95BC8C1C 527DA828 560BB037
D1EDDD8C AE7B379F 50C9D69D B35179EF
2FE898C4 8E4277A8 555CE714 E1FB0E43
D5D52613 C3D12E98 BC49967F 7652EED2
9D2D2E61 67610860 6D338B72 5CF95C69
E36B85CC 84991F19 7575D828 470A92AB

----------End---------

Tuesday, November 1, 2016

Git delete merged remote branch


git branch -r  --merged origin/master | grep origin | grep -v '>' | grep -v master | awk '{sub(/origin\//,"");print}'| xargs git push origin --delete

Saturday, October 1, 2016

phpstorm 2016.2

code:

43B4A73YYJ-eyJsaWNlbnNlSWQiOiI0M0I0QTczWVlKIiwibGljZW5zZWVOYW1lIjoibGFuIHl1IiwiYXNzaWduZWVOYW1lIjoiIiwiYXNzaWduZWVFbWFpbCI6IiIsImxpY2Vuc2VSZXN0cmljdGlvbiI6IkZvciBlZHVjYXRpb25hbCB1c2Ugb25seSIsImNoZWNrQ29uY3VycmVudFVzZSI6ZmFsc2UsInByb2R1Y3RzIjpbeyJjb2RlIjoiSUkiLCJwYWlkVXBUbyI6IjIwMTctMDItMjUifSx7ImNvZGUiOiJBQyIsInBhaWRVcFRvIjoiMjAxNy0wMi0yNSJ9LHsiY29kZSI6IkRQTiIsInBhaWRVcFRvIjoiMjAxNy0wMi0yNSJ9LHsiY29kZSI6IlBTIiwicGFpZFVwVG8iOiIyMDE3LTAyLTI1In0seyJjb2RlIjo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H3QUNbbCUlviSz6+GiRnt1kA9N2Qachl+2yBfaqUqr8h7Z2gsx5LcIf5kYNsqJ0GavXTVyWh7PYiKX4bs354ZQLUwwa/cG++2+wNWP+HtBhVxMRNTdVhSm38AknZlD+PTAsWGu9GyLmhti2EnVwGybSD2Dxmhxk3IPCkhKAK+pl0eWYGZWG3tJ9mZ7SowcXLWDFAk0lRJnKGFMTggrWjV8GYpw5bq23VmIqqDLgkNzuoog==

Sunday, September 25, 2016

window 8.1 product key

Windows 8.1 Single Language
  • Y9NXP-XT8MV-PT9TG-97CT3-9D6TC
  • TNH8J-KG84C-TRMG4-FFD7J-VH4WX (CN)

Monday, June 27, 2016

Kabinet reshuffle after muhyidin and mukhriz sacked.

Proxmox installation display out of range

Reference:  https://forum.proxmox.com/threads/proxmox-ve-screen-out-of-range.131297/