Showing posts with label ubuntu. Show all posts
Showing posts with label ubuntu. Show all posts

Friday 13 September 2019

How to install Postman in Ubuntu 18.04

Step 1 : Download postman from : https://www.getpostman.com/downloads/
Step 2 : Open terminal : #cp -r /home/jaydip/Downloads/Postman/ /usr/local/
Step 3 : #sudo nano /usr/share/applications/Postman.desktop
Step 4 : Paste following text into the terminal screen

[Desktop Entry]
Encoding=UTF-8
Name=Postman
Exec=/usr/local/Postman/app/Postman
Icon=/usr/local/Postman/app/resources/app/assets/icon.png
Terminal=false
Type=Application
Categories=Development;

FYI: Just goto Exec path and check there is Postman available or not?

Wednesday 5 June 2019

How to install letsencrypt SSL certificate on Ubuntu 14.04 apache

Download the Let’s Encrypt Client
Step 1 : sudo add-apt-repository ppa:certbot/certbot
Step 2 : sudo apt-get update
Step 3 : sudo apt-get install python-certbot-apache
Set Up the SSL Certificate
Step 4 : 

sudo certbot --apache -d jaydipkansagra.com
OR
sudo certbot --apache -d jaydipkansagra.com -d www.jaydipkansagra.com
Verifying Certbot Auto-Renewal
Step 5 : sudo certbot renew --dry-run

Tuesday 28 May 2019

How to connect ssh using PPK file into Cpanel from terminal Ubuntu

Connection command without PPK file
ssh username@146.66.87.208 -p18765
 Connection command with PPK file
ssh -i privatekey.ppk username@146.66.87.208 -p18765 (if not connect with PPK or give an error like "Load key "privatekey.ppk": invalid format" so please use the direct file without PPK format (See the following screenshot) ) (Supported port : 22, 18765, 18675)

Thursday 13 December 2018

How to generate new SSH key and adding it to the ssh-agent

1. Open Terminal
2. Paste the text, change email address. $ ssh-keygen -t rsa -b 4096 -C "jaydipkansagra@example.com"
3. Enter a file in which to save the key (/root/.ssh/id_rsa): [Press enter] (Recommend press enter)
4. Enter passphrase (empty for no passphrase): [Type password] (Recommend keep blank)
5. Enter same passphrase again: [Type password again] (Recommend keep blank)
6. For ubuntu
     Start the ssh-agent - $ eval "$(ssh-agent -s)"
   For windows
     1. $ ssh-agent bash
     2. $ eval "$(ssh-agent -s)" 
7. $ ssh-add ~/.ssh/id_rsa
8. Open  ssh-keygen.pub
9. Copy key from ssh-keygen.pub
10. Add into ssh-agent
11. Now, get data from your repository : git clone git@github.com:whatever

Saturday 24 November 2018

Optimized my.cnf MySQL configuration due to hign CPU usage in Ubuntu

# Optimized my.cnf configuration for MySQL/MariaSQL
#
# by Fotis Evangelou, developer of Engintron (engintron.com)
#
# === Updated July 2018 ===
#
# The settings provided below are a starting point for a 2GB - 4GB RAM server with 2-4 CPU cores.
# If you have less or more resources available you should adjust accordingly to save CPU,
# RAM and disk I/O usage.
# The settings marked with a specific comment or the word "UPD" after the value
# should be adjusted for your system by using database diagnostics tools like:
# https://github.com/major/MySQLTuner-perl
# or
# https://launchpad.net/mysql-tuning-primer (supports MySQL up to v5.6)
#
#
# Note that if there is NO comment after a setting value, then 99,9% of the times you won't need to adjust it.
#
#
# THINGS TO DO AFTER YOU UPDATE MY.CNF - TROUBLESHOOTING
# If any terminal commands are mentioned, make sure you execute them as "root" user.
# If MySQL cannot start or restart, then perform the following actions.
#
# 1. If the server had the stock database configuration and you added or updated any
#    "innodb_log_*" settings (as suggested below), then execute these commands ONLY
#    the first time you apply this configuration:
#
#    $ rm -rvf /var/lib/mysql/ib_logfile*
#    $ chown -R mysql:mysql /var/lib/mysql
#    $ service mysql restart
#
#    or use the shorthand command:
#    $ rm -rvf /var/lib/mysql/ib_logfile*; chown -R mysql:mysql /var/lib/mysql; service mysql restart
#
# 2. If the setting "bind-address" is not commented out, then make sure the file /etc/hosts is
#    properly configured. A good example of a "clean" /etc/hosts file is something like this:
#
#    127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
#    ::1       localhost localhost.localdomain localhost6 localhost6.localdomain6
#    1.2.3.4   hostname.domain.tld hostname # Replace accordingly!
#
#    Finally restart the database service:
#
#    $ service mysql restart
#
# 3. If the database service cannot restart even after the first 2 steps, make sure the database data folder
#    (common for either MySQL or MariaDB) "/var/lib/mysql" is owned by the "mysql" user AND group.
#    Additionally, the folder itself can have 0751 or 0755 file permissions. To fix it, simply do this:
#    $ chown -R mysql:mysql /var/lib/mysql
#    $ chmod 0755 /var/lib/mysql
#
#    Finally restart the database service:
#
#    $ service mysql restart
[mysql]
port                            = 3306
socket                          = /var/run/mysqld/mysqld.sock
[mysqld]
# Required Settings
basedir                         = /usr
bind_address                    = 127.0.0.1 # Change to 0.0.0.0 to allow remote servers to connect to this server's
                                            # database instance
datadir                         = /var/lib/mysql
max_allowed_packet              = 256M
max_connect_errors              = 1000000
pid_file                        = /var/run/mysqld/mysqld.pid
port                            = 3306
skip_external_locking
skip_name_resolve
socket                          = /var/run/mysqld/mysqld.sock
#sql_mode                       = ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION,ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES # Enable for b/c with databases
                                                                                                                                               # using null dates
tmpdir                          = /tmp
user                            = mysql
# InnoDB Settings
default_storage_engine          = InnoDB
innodb_buffer_pool_instances    = 1     # Use 1 instance per 1GB of InnoDB pool size
innodb_buffer_pool_size         = 1G    # Use up to 70-80% of RAM & optionally check if /proc/sys/vm/swappiness is set to 0
innodb_file_per_table           = 1
innodb_flush_log_at_trx_commit  = 0
innodb_flush_method             = O_DIRECT
innodb_log_buffer_size          = 16M
innodb_log_file_size            = 128M
#innodb_thread_concurrency      = 4     # Optional: Set to the number of CPUs on your system (minus 1 or 2) to better
                                        # contain CPU usage. E.g. if your system has 8 CPUs, try 6 or 7 and check
                                        # the overall load produced by MySQL/MariaDB.
# MyISAM Settings
query_cache_limit               = 4M    # UPD
query_cache_size                = 48M   # UPD
query_cache_type                = 1
key_buffer_size                 = 48M   # UPD
low_priority_updates            = 1
concurrent_insert               = 2
# Connection Settings
max_connections                 = 100   # UPD
back_log                        = 512
thread_cache_size               = 100
thread_stack                    = 192K
interactive_timeout             = 180
wait_timeout                    = 180
# Buffer Settings
join_buffer_size                = 3M    # UPD
read_buffer_size                = 2M    # UPD
read_rnd_buffer_size            = 4M    # UPD
sort_buffer_size                = 4M    # UPD
# Table Settings
# In systemd managed systems like Ubuntu 16.04 or CentOS 7, you need to perform an extra action for table_open_cache & open_files_limit
# to be overriden (also see comment next to open_files_limit).
# E.g. for MySQL 5.7, please check: https://dev.mysql.com/doc/refman/5.7/en/using-systemd.html
# and for MariaDB check: https://mariadb.com/kb/en/library/systemd/
table_definition_cache          = 8000  # UPD
table_open_cache                = 8000  # UPD
open_files_limit                = 24000 # UPD - This can be 2x to 3x the table_open_cache value or match the system's
                                        # open files limit usually set in /etc/sysctl.conf or /etc/security/limits.conf
                                        # In systemd managed systems this limit must also be set in:
                                        # /etc/systemd/system/mysqld.service.d/override.conf (for MySQL 5.7+) and
                                        # /etc/systemd/system/mariadb.service.d/override.conf (for MariaDB)
max_heap_table_size             = 128M
tmp_table_size                  = 128M
# Search Settings
ft_min_word_len                 = 3     # Minimum length of words to be indexed for search results
# Logging
log_error                       = /var/lib/mysql/mysql_error.log
log_queries_not_using_indexes   = 1
long_query_time                 = 5
slow_query_log                  = 0     # Disabled for production
slow_query_log_file             = /var/lib/mysql/mysql_slow.log
[mysqldump]
# Variable reference
# For MySQL 5.7: https://dev.mysql.com/doc/refman/5.7/en/mysqldump.html
# For MariaDB:   https://mariadb.com/kb/en/library/mysqldump/
quick
quote_names
max_allowed_packet              = 64M

Refer From : https://gist.github.com/fevangelou/fb72f36bbe333e059b66 

Saturday 17 November 2018

Mysql usage grater than 100% of CPU in ubuntu 18.04 | 16.04 in AWS

 You need to update server configuration.

1. Open terminal
2. Put command : sudo nano /etc/mysql/mysql.conf.d/mysqld.cnf




3. Find following variables
key_buffer_size         = 16M
max_allowed_packet      = 16M
thread_stack            = 192K
thread_cache_size       = 8
query_cache_limit      = 1M
query_cache_size        = 16M
Change To
key_buffer_size         = 160M
max_allowed_packet      = 160M
thread_stack            = 1920K
thread_cache_size       = 80
query_cache_limit       = 1024M
query_cache_size        = 2048M
4. Restart mysql : sudo /etc/init.d/mysql restart
5. Restart apache2 sudo systemctl restart apache2
6. Check CPU usage : ps -eo pid,ppid,cmd,%mem,%cpu --sort=-%cpu | head
 For more Information please Refer : https://dev.mysql.com/doc/refman/5.7/en/server-configuration.html

Thursday 11 October 2018

How to redirect www to non www AND http to https in AWS .htaccess


AWS WWW to non WWW redirection
RewriteEngine On
RewriteCond %{SERVER_NAME} =www.example.com
RewriteRule ^.*$ https://example.com%{REQUEST_URI}
AWS HTTP to HTTPS redirection
RewriteEngine On
RewriteCond %{HTTP:X-Forwarded-Proto} !https
RewriteRule ^.*$ https://example.com%{REQUEST_URI}
AWS WWW to non WWW and HTTP to HTTPS
RewriteEngine On
RewriteCond %{SERVER_NAME} =www.example.com
RewriteRule ^.*$ https://example.com%{REQUEST_URI}
RewriteCond %{HTTP:X-Forwarded-Proto} !https
RewriteRule ^.*$ https://example.com%{REQUEST_URI}

Thursday 12 April 2018

How to Find / Search a file using CMD / Terminal Command Linux Ubuntu


1. Find file from computer using CMD / Terminal Command

sudo find / -name index.php
2. Find file from Specific Directory using CMD / Terminal Command

sudo find /var/www/html/ -name index.php

Monday 25 December 2017

File Directly Open in NetBeans in Ubuntu / Linux using terminal


 File Directly Open in NetBeans in Ubuntu / Linux using terminal

1. Open terminal and login with sudo su
2. Edit file using nano in terminal (Use following command)
sudo nano /usr/share/applications/netbeans-8.1.desktop 
3. Change

Exec=/bin/sh "/usr/local/netbeans-8.1/bin/netbeans"
to
Exec=/bin/sh "/usr/local/netbeans-8.1/bin/netbeans" %U

Terminal=0
to
Terminal=false
4. Press CTRL+X , than Y and Enter
5. That't IT, Now you can see NetBeans in open with application

Ref by. Nirav Patel

Tuesday 12 December 2017

How to Enable SSL certificate in cloud.google.com

How to Enable SSL certificate in cloud.google.com


Open cloud.google.com
1. Goto your VM instance
2. Click on name of your instance
3. Edit instance
4. Checked "Firewalls Allow HTTPS traffic" and save


5. Goto Network services -> Load balancing -> Edit / add your Load balancer
6. Add / Edit "https protocol" on Frontend configuration and select / create new certificate




7. Again goto your VM instance list
8. Click on SSH



9. After open google cloud ssh window, write "sudo su" on ssh window
10. ssh-keygen
11. gcloud compute ssl-certificates list
12. gcloud compute ssl-certificates describe ssl2111(name of your ssl certificate)
13. nano /etc/apache2/sites-available/default-ssl.conf
Upload certificate files and update path here where you place your SSLCertificateFiles
<IfModule mod_ssl.c>
    <VirtualHost _default_:443>
        ServerAdmin webmaster@localhost
        <Directory /var/www/html/>
            Options Indexes FollowSymLinks MultiViews
            AllowOverride All
            Order allow,deny
            allow from all
    </Directory>
    DocumentRoot /var/www/html

    ..........
    ..........
    ..........
    ..........
    #SSLCertificateFile     /etc/ssl/certs/ssl-cert-snakeoil.pem
    #SSLCertificateKeyFile /etc/ssl/private/ssl-cert-snakeoil.key
    SSLCertificateFile "/var/www/html/cert/cert.pem"
    SSLCertificateKeyFile "/var/www/html/cert/privkey.key"
    SSLCertificateChainFile "/var/www/html/cert/chain.crt"
    ..........
    ..........
    ..........
    ..........
</VirtualHost>
</IfModule>

14. sudo service apache2 restart
15. gcloud auth login
16. gcloud config set project projectname-010412(Your project id)
17. sudo a2ensite default-ssl
18. service apache2 reload
19. sudo a2enmod ssl
20. sudo service apache2 restart
21. gcloud compute firewall-rules create www-firewall     --target-tags https-tag --allow tcp:443
22. service apache2 reload 

That's It, Please check your SSL 

Wednesday 29 March 2017

How to install PHP, apache and mysql in ununtu 14.04

https://www.howtoforge.com/ubuntu-lamp-server-with-apache2-php5-mysql-on-14.04-lts

https://www.digitalocean.com/community/tutorials/how-to-install-and-secure-phpmyadmin-on-ubuntu-12-04

Enable .htaccess

sudo a2enmod rewrite
sudo service apache2 restart
sudo nano /etc/apache2/sites-available/000-default.conf
<Directory "/var/www/html">
AllowOverride All
</Directory>

sudo service apache2 restart

Friday 20 November 2015

Upgrade Mysql version 5.6.0 or later ubuntu upgrade

For 14.04 users:

Ubuntu 14.04 defaults to MySQL 5.5, but also has MySQL 5.6 available for installation from the universe archive. Installing 5.6 is as easy as specifying the version:
myuser@mypc:~$ sudo apt-get purge mysql-server-5.5 mysql-client-5.5
myuser@mypc:~$ sudo apt-get autoremove
myuser@mypc:~$ sudo apt-get install mysql-server-5.6 mysql-client-5.6
If you have existing data in a MySql 5.5 database, it should be migrated automatically. Though it is always a good idea to make a backup before doing a major upgrade.

First make a backup of the data in your existing database:

mysqldump --lock-all-tables -u root -p --all-databases > dump.sql
Then after installing the newer version, you can restore if needed by running:

mysql -u root -p < dump.sql 

Wednesday 19 August 2015

How to import database using ubuntu terminal or windwos CMD

For linux ubunto
pv /var/www/html/decorati_main.sql.gz | gunzip | mysql -u root -p root

apt-get install pv
pv /var/www/html/decorati_main.sql.gz | gunzip | mysql -u root -p  decorativeplumb

For Windows

mysql -uroot -ppassword mydb > myfile.sql.gz