Posts

Showing posts from June, 2020

How to reload Apache

sudo service httpd reloadOR sudo systemctl reload httpd

Get Linux IP by hostname

$ hostname -I 172.17.0.2

Bash prompt variables

We can customize bash prompt by changing the values of bash PS1, PS2, PS3, PS4.root@2e5540791177:/# echo "Bash PS1 variable:"  $PS1 Bash PS1 variable: \[\e]0;\u@\h: \w\a\]${debian_chroot:+($debian_chroot)}\u@\h:\w\$ root@2e5540791177:/# echo "Bash PS2 variable:"  $PS2 Bash PS2 variable: > root@2e5540791177:/# PS1="\u@\H:\w [\t]\$ " root@2e5540791177:/ [23:52:00]$

Record Linux terminal session

script makes a typescript of everything printed on your terminal. If the argument file is given, script saves all dialogue in the indicated file in the current directory. If no file name is given, the typescript is saved in default file typescript. 
root@2e5540791177:/# script output.log Script started, file is output.log # date Sat Jun 27 23:44:48 UTC 2020 # exit Script done, file is output.log root@2e5540791177:/# root@2e5540791177:/# script Script started, file is typescript # ls bin  boot  dev  etc  home  lib  lib32  lib64  libx32  media  mnt  opt  proc  root  run  sbin  srv  sys  tmp  typescript  usr  var # date Sat Jun 27 23:43:23 UTC 2020 # exit Script done, file is typescript root@2e5540791177:/# cat typescript Script started on 2020-06-27 23:43:14+00:00 [TERM="xterm" TTY="/dev/pts/0" COLUMNS="172" LINES="55"] # ls bin  boot  dev  etc  home  lib  lib32  lib64  libx32  media  mnt  opt  proc  root  run  sbin  srv  sys  tmp  typescript  usr  var # date Sat Jun …

Invoked Bash as an interactive non-login shell

When an interactive shell that is not a login shell is started, Bash reads and executes commands from ~/.bashrc, if that file exists. This may be inhibited by using the --norc option. The --rcfile file option will force Bash to read and execute commands from file instead of ~/.bashrc.
So, typically, your ~/.bash_profile contains the line
if [ -f ~/.bashrc ]; then . ~/.bashrc; fi after (or before) any login-specific initializations.

How To Change Timezone on Linux

[ec2-user@ip-172-16-0-86 ~]$ date Wed Jun 24 12:52:22 UTC 2020 [ec2-user@ip-172-16-0-86 ~]$ timedatectl list-timezones | grep Toronto America/Toronto [ec2-user@ip-172-16-0-86 ~]$ sudo timedatectl set-timezone America/Toronto [ec2-user@ip-172-16-0-86 ~]$ date Wed Jun 24 08:54:18 EDT 2020

Remove Symbolic Links with rm

To get prompted before removing the symlink, use the -i option:
rm -i symlink_name
If the symbolic link points to a directory, do not append the / trailing slash at the end. Otherwise, you will get an error:
rm symlink_to_dir/ rm: cannot remove 'symlink_to_dir/': Is a directory
To be on the safe side, never -r option when removing symbolic links with rm.

Faban comes with a simple program (fhb) that can be used to measure the performance of a simple URL

a free and open source performance workload creation and execution framework.
Faban is used in performance, scalability and load testing of almost any type of server application. If the application accepts requests on a network, Faban can measure it.
Read more...

China finds heavy coronavirus traces in seafood, meat sections of Beijing food market

Get processlist of MySQL

For non-sleep processlist:$ mysql --login-path=root -e "SELECT * FROM INFORMATION_SCHEMA.PROCESSLIST pl where pl.command not in ('Sleep')\G "  | less
For all processlist:
SELECT * FROM INFORMATION_SCHEMA.PROCESSLIST

SHOW FULL PROCESSLIST

Official Jenkins Docker image

To use the latest LTS: docker pull jenkins/jenkins:ltsTo use the latest weekly: docker pull jenkins/jenkins https://hub.docker.com/r/jenkins/jenkins

Update default python on Linux

Add
alias python=python3to/etc/profileThensource /etc/profile

To search using Vim/vi

In normal mode, you can search forward or backward.One can search forward in vim/vi by pressing / and then typing your search pattern/word.To search backward in vi/vim by pressing ? and then typing your search pattern/word.Once a word found in vim, you can press the n key to go directly to the next occurrence of the word backwards.

Java JVM time zone

The list of supported Java JVM time zone IDs is:

Africa/Abidjan
Africa/Accra
Africa/Addis_Ababa
Africa/Algiers
Africa/Asmara
Africa/Asmera
Africa/Bamako
Africa/Bangui
Africa/Banjul
Africa/Bissau
Africa/Blantyre
Africa/Brazzaville
Africa/Bujumbura
Africa/Cairo
Africa/Casablanca
Africa/Ceuta
Africa/Conakry
Africa/Dakar
Africa/Dar_es_Salaam
Africa/Djibouti
Africa/Douala
Africa/El_Aaiun
Africa/Freetown
Africa/Gaborone
Africa/Harare
Africa/Johannesburg
Africa/Juba
Africa/Kampala
Africa/Khartoum
Africa/Kigali
Africa/Kinshasa
Africa/Lagos
Africa/Libreville
Africa/Lome
Africa/Luanda
Africa/Lubumbashi
Africa/Lusaka
Africa/Malabo
Africa/Maputo
Africa/Maseru
Africa/Mbabane
Africa/Mogadishu
Africa/Monrovia
Africa/Nairobi
Africa/Ndjamena
Africa/Niamey
Africa/Nouakchott
Africa/Ouagadougou
Africa/Porto-Novo
Africa/Sao_Tome
Africa/Timbuktu
Africa/Tripoli
Africa/Tunis
Africa/Windhoek
America/Adak
America/Anchorage
America/Anguilla
America/Antigua
America/Araguaina
America/Argentina/Buenos_Aires
America/Argentina/Catamarca
America/Argentina/ComodRivadavia
America/…

jq is a lightweight and flexible command-line JSON processor.

jq is like sed for JSON data - you can use it to slice and filter and map and transform structured data with the same ease that sed, awk, grep and friends let you play with text.
https://stedolan.github.io/jq/

How to activate SSL/HTTPS on Jenkins

For CentOS or RPM based:
Go to /etc/sysconfig/jenkins, set the JENKINS_HTTPS_PORT="8443"

Then restart Jenkins.

If you want to generate ssh key:
openssl genrsa -out key.pem  # creates key.pem

openssl req -new -key key.pem -out csr.pem
# you need to put the dns name of your website, testweb.local
# for the 'Common Name' question
# other questions, you can just accept defaults
# actually, you can accept defaults for all, will work ok too

openssl x509 -req -days 9999 -in csr.pem -signkey key.pem -out cert.pem
rm csr.pem
start jenkins
if you want both https and http:
java -jar jenkins.war --httpsPort=8443 --httpsCertificate=cert.pem --httpsPrivateKey=key.pem
if you want https only, dont open http port:
java -jar jenkins.war --httpsPort=8443 --httpsCertificate=cert.pem --httpsPrivateKey=key.pem --httpPort=-1
starting a slave
Convert the cert.pem to cert.der:
 openssl x509 -outform der -in cert.pem -out cert.der
create keystore, containing this cert:
keytool -import -alias testweb.local -keysto…

Fixed jenkins Failed to connect to repository : Error performing git command: git ls-remote -h git@

You need to

git is available in your systemgit path is correctly set in the Jenkins
Verify your git path at:

Jenkins > Manage Jenkins > Global Tool Configuration > Git