Snippets Collections
#create an identity fil name {mycert} as per your need
ssh-keygen -f ~/.ssh/mycert -t ed25519

Host myserver
Hostname {hostname}
IdentityFile ~/.ssh/{identityFile}
User {username}

#from the console
ssh myserver
sudo firewall-cmd --zone=public --permanent --add-port=8080/tcp
sudo firewall-cmd --zone=public --permanent --add-port=1935/tcp
sudo firewall-cmd --reload
split -v
focus down
split -v

screen -t bash /bin/bash
screen -t deploy1 /usr/bin/ssh deploy1
screen -t deploy2 /usr/bin/ssh deploy2
screen -t deploy3 /usr/bin/ssh deploy3
screen -t deploy4 /usr/bin/ssh deploy4

focus up
focus left
select 1
focus right
select 2
focus left
focus down
select 3
focus right
select 4
curl -fsSL | sh

/ means the root of the current drive;

./ means the current directory;

../ means the parent of the current directory
location / {
                proxy_pass http://localhost:0909;
                proxy_set_header Connection '';
                proxy_http_version 1.1;
                chunked_transfer_encoding off;
                proxy_buffering off;
                proxy_cache off;

mbpfan is a daemon that uses input from coretemp module and sets the fan speed  using  the
applesmc  module.   This  enhanced version assumes any number of processors and fans (max.10), and it is distro- and kernel-independent.

# Download
# Create a folder
$ mkdir actions-runner && cd actions-runner
# Download the latest runner package
$ curl -o actions-runner-linux-x64-2.291.1.tar.gz -L Optional: Validate the hash
$ echo "1bde3f2baf514adda5f8cf2ce531edd2f6be52ed84b9b6733bf43006d36dcd4c  actions-runner-linux-x64-2.291.1.tar.gz" | shasum -a 256 -c
# Extract the installer
$ tar xzf ./actions-runner-linux-x64-2.291.1.tar.gz
# Configure
# Create the runner and start the configuration experience
$ ./ --url --token AB7YEM2R2HZDVVBJ3VEFFLLCSI5U6# Last step, run it!
$ ./
# Using your self-hosted runner
# Use this YAML in your workflow file for each job
# runs-on: self-hosted
sudo apt update; sudo apt upgrade -y; sudo apt autoremove -y; clear;
certbot certonly --standalone -d --staple-ocsp -m --agree-tos
grep -inRsH "Text to be searched" apps/
$ sudo hdparm -Tt /dev/sda
 Timing cached reads:   16924 MB in  2.00 seconds = 8469.95 MB/sec
 Timing buffered disk reads: 1386 MB in  3.00 seconds = 461.50 MB/sec

set -eu -o pipefail # fail on error and report it, debug all lines

sudo -n true
test $? -eq 0 || exit 1 "you should have sudo privilege to run this script"

echo installing the must-have pre-requisites
while read -r p ; do sudo apt-get install -y $p ; done < <(cat << "EOF"
    zip unzip

echo installing the nice-to-have pre-requisites
echo you have 5 seconds to proceed ...
echo or
echo hit Ctrl+C to quit
echo -e "\n"
sleep 6

sudo apt-get install -y tig
// This is the first function in which we get data from a request.
// After that we return a multidimensional array with that data.

   * {@inheritDoc}
  public function buildPaymentReportTable(Request $request) {
    $order_id = $request->request->get('oid');
    $authorization_code = $request->request->get('AuthCode');
    $payment_status = $request->request->get('Response');
    $transaction_status_code = $request->request->get('ProcReturnCode');
    $transaction_id = $request->request->get('TransId');
    $transaction_date = $request->request->get('EXTRA_TRXDATE');
    $status_code_3d = $request->request->get('mdStatus');

    // Add transaction data to order field.
    $order = $this->entityTypeManager
    $order_data = [
      'order_id' => $order_id,
      'authorization_code' => $authorization_code,
      'payment_status' => $payment_status,
      'transaction_status_code' => $transaction_status_code,
      'transaction_id' => $transaction_id,
      'transaction_date' => $transaction_date,
      'status_code_3d' => $status_code_3d,
    $order->field_banca_intesa_data = json_encode($order_data);

    return [
      ['name' => $this->t('Order ID'), 'value' => $order_id],
      ['name' => $this->t('Authorization code'), 'value' => $authorization_code],
      ['name' => $this->t('Payment status'), 'value' => $payment_status],
      ['name' => $this->t('Transaction status code'), 'value' => $transaction_status_code],
      ['name' => $this->t('Transaction ID'), 'value' => $transaction_id],
      ['name' => $this->t('Transaction date'), 'value' => $transaction_date],
      ['name' => $this->t('Status code for the 3D transaction'), 'value' => $status_code_3d],

// This is the second function

   * {@inheritDoc}
  public function getRenderedPaymentReportTable(Request $request) {
    $info_table_data = $this->buildPaymentReportTable($request);

    $info_table = [
      '#type' => 'table',
      '#header' => [$this->t('Parameter name'), $this->t('Parameter value')],
      '#rows' => $info_table_data,

    return $this->renderer->render($info_table);

namespace Drupal\product_importer\Form;

use Drupal\commerce_order\Entity\OrderItem;
use Drupal\commerce_price\Price;
use Drupal\commerce_product\Entity\Product;
use Drupal\commerce_product\Entity\ProductAttribute;
use Drupal\commerce_product\Entity\ProductAttributeValue;
use Drupal\commerce_product\Entity\ProductVariation;
use Drupal\commerce_store\Entity\Store;
use Drupal\Core\File\FileSystemInterface;
use Drupal\Core\Form\FormBase;
use Drupal\Core\Form\FormStateInterface;
use Drupal\file\Entity\File;
use Drupal\taxonomy\Entity\Term;

class ProductImportForm extends FormBase {

    public function getFormId()
        return "product_import";

    public function buildForm(array $form, FormStateInterface $form_state)
        $form['description'] = [
          '#markup' => '<p>Use this form to upload a CSV file of Data</p>'

        $validators = [
          'file_validate_extensions' => ['csv']

        $form['import_csv'] = [
          '#type' => 'managed_file',
          '#title' => t('Upload file here:'),
          '#upload_location' => 'public://importcsv/',
          '#upload_validators' => $validators,

        $form['submit'] = [
          '#type' => 'submit',
          '#value' => $this->t('Save'),
          '#button_type' => 'primary',

    return $form;

    public function submitForm(array &$form, FormStateInterface $form_state)
        $csv_file = $form_state->getValue('import_csv');

        $file = File::load($csv_file[0]);

        $file->setPermanent();          //Da bih ga sačuvao u bazi mora biti setovan na permanent.


        $data = $this->csvtoarray($file->getFileUri(), ';');

        $store = Store::load('1');

//            -----------------         KREIRANJE PROIZVODA         ------------------------
        $i = 1;

        foreach($data as $item) {
            $nesto = file_get_contents($item['Image']);
            $slika = file_save_data(

//            ---------------      Pozivanje odgovarajućeg terma i kreiranje ako ne postoji       ----------------

            $term = \Drupal::entityTypeManager()
              ->loadByProperties(['name' => $item['Category']]);
            if(count($term) > 0){
              $term = reset($term);
            } else {
              $term = Term::create([
                'name' => $item['Category'],
                'vid' => 'products'
//              $term = \Drupal::entityTypeManager()
//                ->getStorage('taxonomy_term')
//                ->loadByProperties(['name' => $item['Category']]);
//              $term = reset($term);

//            --------        Pozivanje odgovarajuce vrednosti atributa i kreiranje ako ne postoji        -----------

              $color = \Drupal::entityTypeManager()
                ->loadByProperties(['name' => $item['Color']]);
              if(count($color) > 0) {
                $color = reset($color);
              } else {
                $color = ProductAttributeValue::create([
                  'attribute' => 'color',
                  'name' => $item['Color']
//                $color = \Drupal::entityTypeManager()
//                  ->getStorage('commerce_product_attribute_value')
//                  ->loadByProperties(['name' => $item['Color']]);
//                $color = reset($color);

//              dsm($color);

              $gender =  \Drupal::entityTypeManager()
                ->loadByProperties(['name' => $item['Gender']]);
              if(count($gender) > 0) {
                $gender = reset($gender);
              } else {
                $gender = ProductAttributeValue::create([
                  'attribute' => 'gender',
                  'name' => $item['Gender']
//                $gender = \Drupal::entityTypeManager()
//                  ->getStorage('commerce_product_attribute_value')
//                  ->loadByProperties(['name' => $item['Gender']]);
//                $gender = reset($gender);

              $size =  \Drupal::entityTypeManager()
                ->loadByProperties(['name' => $item['Size']]);
              if(count($size) > 0) {
                $size = reset($size);
              } else {
                $size = ProductAttributeValue::create([
                  'attribute' => 'size',
                  'name' => $item['Size']
//                $size = \Drupal::entityTypeManager()
//                  ->getStorage('commerce_product_attribute_value')
//                  ->loadByProperties(['name' => $item['Size']]);
//                $size = reset($size);

//            -------------------       Kreiranje proizvoda i varijacija        -------------------------

            $product = Product::create([
              'type' => 'default',
              'stores' => [1],
              'title' => $item['Title'],
              'body' => $item['Body'],
              'field_category' => $term
            $variation = ProductVariation::create([
              'title' => $item['Title'],
              'type' => 'default',
              'sku' => $item['SKU'],
              'price' => new Price($item['Price'], 'EUR'),
              'field_stock' => $item['Lager'],
              'field_image' => [
                'target_id' => $slika->id(),
                'alt' => 'Sample',
                'title' => 'Sample file'
              'attribute_color' => $color,
              'attribute_gender' => $gender,
              'field_size' => $size

//            $product[$i]->save();
        // dsm($variation[1]);

    public static function csvtoarray($filename='', $delimiter) {
        if(!file_exists($filename) || !is_readable($filename)) return false;
        $header = NULL;
        $data = [];

        if(($handle = fopen($filename, 'r')) == true) {
            while (($row = fgetcsv($handle, 10000, $delimiter)) == true)
                if(!$header) {
                    $header = $row;
                } else {
                    $data[] = array_combine($header, $row);
        return $data;

#How to view SSH keys in Linux, macOS, and Windows

cat ~/.ssh/
cat /Users/USERNAME/.ssh/

#Send/Copy local file to Remote Machine
usage: scp -i <pemfile>  <filename> user-name@domain-or-ip:<path-to-copy>
scp -i .\keys.pem .\<filename> ubuntu@xx.xx.xx.xx:~/  

# copy file from remote machine to local machine (using GIT Bash)
#$scp -i <"pemfile"> user@xx.xx.xx.xx:/<path-of-file-to-copy> <directory-to-paste-file>
$ scp -i  "Light.pem"  bitnami@XX.XX.XX.XX:/home/bitnami/AOC_PROJ_UPDATED_08_06_2022/AOC_PROJ_UPD_08_06_22.tar.gz  . 
#ssh to remote machine.
ssh -i keys.pem ubuntu@xx.xx.xx.xx
#Author:Irfan Khan
#Description:this function will used to donwload & move that file to
#desired location
    wget -cO - >
    if [[ -f ]];
        mv ./mydb_data
        exit 0
        echo "hey file not moved some thing went wrong.."

download  #calling the function
#To Download File From Remote Server To Local Machine Using SCP.using Powershell or gitbash 
scp -i .\keys.pem ubuntu@XX.XX.XX.XX:/home/ubuntu/Dir/fileName  C:\Users\USER\Downloads\
adduser USER_NAME
usermod -aG sudo USER_NAME

# Verify new user
grep '^sudo' /etc/group
#!/usr/bin/env bash

# install ZSH
sudo apt -y install zsh

# Install oh-my-zsh
git clone git:// ~/.oh-my-zsh

# Install some external plugins:
git clone ~/.oh-my-zsh/custom/plugings/zsh-autosuggestions
git clone ~/.oh-my-zsh/custom/plugins/zsh-completions
git clone ~/.oh-my-zsh/custom/plugins/zsh-syntax-highlighting

# Set Zsh as your default shell:
chsh -s /bin/zsh

curl --proto '=https' --tlsv1.2 -sSf | sh

source $HOME/.cargo/env
#!/usr/bin/env bash

# Update the list of packages
sudo apt-get update

# Install pre-requisite packages.
sudo apt-get install -y wget apt-transport-https software-properties-common

# Download the Microsoft repository GPG keys
wget -q

# Register the Microsoft repository GPG keys
sudo dpkg -i packages-microsoft-prod.deb

# Update the list of packages after we added
sudo apt-get update

# Install PowerShell
sudo apt-get install -y powershell

# Start PowerShell
© 2022 GitHub, Inc.
#!/usr/bin/env bash

sudo apt-get -y update

# set config
XDG_CONFIG_HOME = ~/.config

# install nvm
curl -o- | bash

[ -s "$NVM_DIR/" ] && \. "$NVM_DIR/"  # This loads nvm
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion"  # This loads nvm bash_completion

# config
nvm alias default node # Always default to the latest available node version on a shell
nvm set-colors "yMeBg"

# install latest node and npm
nvm install node --latest-npm
nvm install-latest-npm

nvm use node
npm install -g npm

# setup npm
npm login
npm install -g eslint jshint prettier yarn npm-check doctoc tldr speedtest-cli serve

sudo mv /etc/apt/preferences.d/cuda-repository-pin-600
sudo dpkg -i cuda-repo-wsl-ubuntu-11-5-local_11.5.1-1_amd64.deb
sudo apt-key add /var/cuda-repo-wsl-ubuntu-11-5-local/
sudo apt-get -y update 
sudo apt-get -y install cuda

curl -fsSL | sudo -E bash -
sudo apt-get install -y nodejs
#!/usr/bin/env sh

sudo apt-get update && sudo apt-get -y upgrade && sudo apt-get -y autoremove
sudo apt-get -y install neovim
sudo apt-get install python-neovim python3-neovim

mkdir -p ~/.dotfiles/neovim/.config/nvim
touch ~/.dotfiles/neovim/.config/nvim/init.vim

echo 'set runtimepath^=/.vim runtimepath+=~./vim/after\nlet &packpath = &runtimepath\nsource ~/.vimrc' >> ~/.dotfiles/neovim/.config/nvim/init.vim
cd .dotfiles
stow neovim
cd ~
!#/usr/bin/env bash

# update and ensure build-essentials/git
sudo apt update
sudo apt-get install build-essential curl file git

# install homebrew
/bin/bash -c "$(curl -fsSL"

# add to PATH
echo 'eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv)"' >> /home/jimbrig/.profile
eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv)"
source ~/.profile

# test
test -d /home/linuxbrew/.linuxbrew && eval $(/home/linuxbrew/.linuxbrew/bin/brew shellenv)
test -r ~/.bash_profile && echo "eval \$($(brew --prefix)/bin/brew shellenv)" >>~/.bash_profile
echo "eval \$($(brew --prefix)/bin/brew shellenv)" >>~/.profile

brew doctor

# gcc installation
brew install gcc

# initial installations
brew install topgrade git-crypt git-cliff

sudo dpkg -i ./gitkraken-amd64.deb
sudo apt-get install -f
#!/usr/bin/env bash

# install github-cli
VERSION=`curl  "" | grep '"tag_name"' | sed -E 's/.*"([^"]+)".*/\1/' | cut -c2-`
mkdir ~/downloads
curl -sSL${VERSION}/gh_${VERSION}_linux_amd64.tar.gz -o ~/downloads/gh_${VERSION}_linux_amd64.tar.gz
cd ~/downloads
tar xvf gh_${VERSION}_linux_amd64.tar.gz
sudo cp gh_${VERSION}_linux_amd64/bin/gh /usr/local/bin/
gh version
sudo cp -r ~/downloads/gh_${VERSION}_linux_amd64/share/man/man1/* /usr/share/man/man1/
# man gh
gh auth login

rm -r ~/downloads
#!/usr/bin/env bash

# install cargo
sudo apt-get update -y
sudo apt-get install -y cargo

echo '\n# Add .cargo to $PATH\nexport PATH="~/.cargo/bin:$PATH"\n' >> ~/.zshrc

cargo install cargo-update
#!/usr/bin/env bash

curl -sL | sudo bash
az --version
az login
#!/usr/bin/env bash

# Install R on WSL
sudo apt-get update -qq -y
sudo apt-get install -y wget git
OS_DISTRIBUTION=$(lsb_release -cs)
wget -O-${OS_DISTRIBUTION}.us-nh.full | sudo tee /etc/apt/sources.list.d/neurodebian.sources.list
sudo apt-key adv --recv-keys --keyserver hkp:// 0xA5D32F012649A5A9
sudo apt-get update

sudo apt-get install libopenblas-base r-base
sudo apt-get update -qq -y
sudo apt-get install -y libgit2-dev
sudo apt-get install -y libcurl4-openssl-dev libssl-dev
sudo apt-get install -y zlib1g-dev libssh2-1-dev libpq-dev libxml2-dev
RewriteCond %{HTTPS} !=on
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
REWRITERULE ^(.*)$ http://dockerbackend/$1 [P]
 /root/ --issue -d --cert-file /etc/letsencrypt/live/ --key-file /etc/letsencrypt/live/ --fullchain-file /etc/letsencrypt/live/ -w /home/ --force --debug

   > driver.findElement();
    - Return value of the above code is always 'WebElement'.

1. ID
  > findElement("idNameHere"));

2. Name
> driver.findElement('valueHere'));  
- it's the attribute 'name' in the element.

3. Xpath  ( Extended HTML path )

  > //div /* It will select the all the div elements */
  > //div[@attribute='value'] /* It will select the all the div elements with specific attribute and value */
  > //div[@type='submit' and @value='Login']
  > //div[@type='submit' and @value='Login' and @name='Login']
  > //a[text()='Gmail']
  > //a[text()='Text to Match']
              //OR use 'contains'                    -- Recommended. 
  > //a[contains(text(),'Gmail')]                      
  > //a[contains(text(),'Text to Match')]
 //div[@class='bd-example']//button[@type='button' and @class='btn btn-dark']
  /*  **We have to mention all the active classes element( if we are searching using the class attribute )           */
  > //div[@class='bd-example']//input[@value='Reset'] > input 
4. CSS selector
 > driver.findElement(By.cssSelector("#idHere"));
 > driver.findElement(By.cssSelector(".classNameHere"));

5. LinkText : only for links text
 > driver.findElement(By.linkText("Trouble signing in?"));
//This will look for the link TEXT. Not the actual link. 

6. Partial Link Text
 > driver.findElement(By.partialLinkText("Trouble signi"));
//Only the partial string is passed. 
//Install MySql on Windows system.

> USE dataBaseName

                         // Clauses
                     - SELECT
  : '*' Will return all the coloumns from the selected   table.
> SELECT fName,lName FROM customers //This will only look for the 2 specified columns.
> SELECT lname, points, points + 10 FROM customers
 // 'points + 10' Will add the given points to existing points coloumn.

> SELECT lname, points, points - 10 * 800 FROM customers
 // 'points - 10' Will Subtract the given points from existing points coloumn amnd then multiple by 800. We can use brackets if needed. 

> SELECT lname, points, points - 10 * 800 AS discount_factor FROM customers
// 'points - 10 * 800' column heading will not make sense to read, So we use 'AS' ( Alliance ), It will rename the heading from 'points - 10 * 800' to 'discount_factor'

> SELECT DISTINCT fname,lname from tableName;
//It will return the unique values for fname and lname, Duplicates will be removed. 

                           - WHERE
SELECT name FROM table1 WHERE name = 'tom';

SELECT name FROM table1 WHERE name != 'tom';
SELECT name FROM table1 WHERE name <> 'tom'; //"! and <>" are same.
SELECT * FROM table1 WHERE NOT score = 120;
SELECT * FROM table1 WHERE SCORE NOT IN ( 132, 20, 60); 
SELECT * FROM table1 WHERE score IN ( 132, 20, 60);    
SELECT score FROM table1 WHERE score = 100;
SELECT score FROM table1 WHERE score > 10;
SELECT score FROM table1 WHERE score < 200;
SELECT * FROM table1 WHERE date > '1991-10-10';

                  //'ORDER BY'
  FROM customers
  ORDER BY first_name;
  //It will sort the list using the 'first Name' in     ascending order.

  FROM customers
  ORDER BY first_name DESC;
  //It will sort the list using the 'first Name' in     decending order.
* WE can also add multiple 

SELECT * FROM table1 WHERE date >= '1990-7-10' AND date <= '1990-10-10';

SELECT * FROM table1 WHERE date >= '1990-7-10' OR date <= '1990-10-10';

                               //AND OR
SELECT * FROM table1 WHERE date >= '1990-7-10' AND points > 100  AND score = 120;

** AND : 'AND' Operator has higer precedence then the 'OR' operator**
  : I.E 'AND' Operator will be executed first, Even if the 'OR' is mentioned first. We can change the order using parenthesis.

 'IN' Operator:                 // 'NOT'  // IN
: We can use 'NOT' pretty much anywhere. 
SELECT * FROM table1 WHERE  score = 20 OR score = 60 OR score = 132;  
SELECT * FROM table1 WHERE score IN ( 132, 20, 60);    
SELECT * FROM table1 WHERE score NOT IN ( 132, 20, 60);    

SELECT * FROM table1 WHERE SCORE BETWEEN 100 AND 150;           
//Both the points are inlusive.
: It's used to find some pattern string/number/data.
> SELECT * FROM table2 WHERE fname LIKE "kara%";  //look for string starting with 'kar'
> LIKE "%ingh";  //look for string ending with 'ingh'
> LIKE "%IN%";  //look for string 'IN' ( can be anywhere )
> NOT LIKE "%IN%";  // NOT look for string 'IN' ( can be anywhere )
> LIKE "___karan%";  //look for string 'karan' starting after 3 characters ( 3 uderscores ).
> LIKE "b__y";  //look for string starting with 'b', ending with 'y' and have any two characters in between.

                             //Regexp ( Regular expression )
> SELECT * FROM table2 WHERE fname REGEXP 'tring'; //It is same as '%tring%'
> SELECT * FROM table2 WHERE fname REGEXP '^stri'; //It is same as '%tring' ( look for 'Starting' of starting )
> SELECT * FROM table2 WHERE fname REGEXP 'ing$'; //It is same as 'ing%' ( look for Ending Part)

> SELECT * FROM nameinfo WHERE Name REGEXP 'Tom|Allen'; //We add pipe in between 2 strings, This way it will search for the either of the provided strings.
> SELECT * FROM nameinfo WHERE Name REGEXP 'Tom|Allen|karan';
>  SELECT * FROM nameinfo WHERE Name REGEXP 'Tom|Allen|rose$';

>  SELECT * FROM nameinfo WHERE Name REGEX '[gim]e';
//It will look for 'ge' or 'ie' or 'me', 1 will be string from the brackets and which will be matched with 'e'.

>  SELECT * FROM nameinfo WHERE Name REGEX '[a-c]j';
 //It will look for the pattern 'aj'or 'bj' or 'cj'.

>  SELECT * FROM nameinfo WHERE Name REGEX 'e[gim]';
 //It will look for patter 'eg' or 'ei' or 'em'

>  SELECT * FROM nameinfo WHERE Name REGEX 'j[a-c]';
 //It will look for the pattern 'ja'or 'jb' or 'jc'.

> SELECT * FROM nameinfo WHERE Name REGEXP 'om$|en$';
  //Will look for 'om' or 'en' at the end of the string.

>  SELECT * FROM nameinfo WHERE Name REGEXP 's|ll';
 //Will look for 's' or 'll' anythere in the field ( can be starting,ending or middle.)
 : We use double Hyphen ( -- ) in the front of the code to make it as a comment.
> --FROM customers        //This line will be commented. 
> WHERE customer_id = 100                         
> CREATE TABLE tableName (
                        columnName1 dataType(),
                        columnName2 dataType(),
                        columnName3 dataType(),
> INSERT INTO tableName VALUES("abv","ds","sda");

> ALTER TABLE tableName ADD newColumn1 dataType();
//Add new coloumn to the existing table

> DROP TABLE tableName1;
//'tableName1' will be deleted from the selected DB.

             //Null ( Empty Field )

  FROM tableName 
  WHERE phoneNumer IS NULL;
 //It will return all the phoneNumber's which has        values NULL.


Inspect a website and press CTRL + F ( curser should be selected on inspect side )to open xpath Search bar on chrome.

//Find Specific text with element H4
> //h4[text()='Cucumber - 1 Kg']
//Selecting parent of H4 element with text 'Cucumber....'  
> //h4[text()='Cucumber - 1 Kg']//parent

//Selecting parent of H4 element with text 'Cucumber....' with specific class   
> //h4[text()='Cucumber - 1 Kg']//parent::*[@class='production-action']
# check cuurent swap space
sudo swapon --show
free -h

# check available disk space
df -h

# create swap file
sudo fallocate -l 1G /swapfile

# verification
ls -lh /swapfile

# enable swap file
sudo chmod 600 /swapfile
ls -lh /swapfile

# mark file as swap space
sudo mkswap /swapfile
sudo swapon /swapfile

# verification
sudo swapon --show
free -h

# make swap file permanent
sudo cp /etc/fstab /etc/fstab.bak
echo '/swapfile none swap sw 0 0' | sudo tee -a /etc/fstab

# adjust swappiness
cat /proc/sys/vm/swappiness
sudo sysctl vm.swappiness=10

# set to automatically restart
sudo nano /etc/sysctl.conf

# set cache pressure
cat /proc/sys/vm/vfs_cache_pressure
sudo sysctl vm.vfs_cache_pressure=50

# make permanent
sudo nano /etc/sysctl.conf
sudo apt-get update
sudo apt-get install software-properties-common
sudo add-apt-repository universe
sudo apt-get update
sudo apt-get install python3-certbot-nginx 

sudo certbot --nginx
sudo certbot --authenticator standalone --installer nginx --pre-hook "service nginx stop" --post-hook "service nginx start"
sudo service nginx restart

crontab -e 
0 0 */1 * * certbot renew

cat ~/.ssh/
sudo service postgresql start
sudo service nginx start

sudo su postgres
# create database

nano .env
yarn install
yarn knex migrate:latest
yarn knex seed:run
forever start index.js
sudo apt-get update && apt-get upgrade

curl -sL | sudo -E bash -
sudo apt-get install -y nodejs
sudo apt-get install build-essential nginx htop git curl postgresql postgresql-contrib ranger

sudo npm install -g forever
sudo npm install -g yarn 

sudo apt install redis-server
sudo service redis start
public static void main(String[] args) {
 //Basic set up.

//Print in the console.
System.out.println("Printing String...");

- Pink letters are keywords. ( public, static, class, void... )
- Compiler will always start with the 'main' mathod.      
- use ';' after each line of code.
- 'void' is the basically how we tell that we returning nothing. if we want to return a number? then mention 'int' instead of 'void'.                              
int a = 10;
// 'int' is Integer.

String name = "Karan";
// 'String' is string.    
             // Transfer data/methods within classes.
  public class Parent {
   // This is the parent Class.    
    public static void main(String[] args){
     Methods m = new Methods;
     //Methods is the class name.
     // 'm' is the oject.
     // 'm.' will provide 'built in' and custom methods             available in the 'Methods' class.
     // It will return 'Done Amigo' as programed in method. 
 publick class Methods {
    //This is the 'Methods' class ( child class)
   // We won't be using 'main' method here as we are just            sending the data.
     public void ValidateHeader(){
      //Example of an Method.    
      // 'void' since we are not returning anything. 
     public String ValidateFooter(){
      //Example of an Method.    
       // 'String' as we are returning string
        return "Done amigo"  
     public int ValidateFooter2(){
      //Example of an Method.    
        return 200;  

//Java Installation

// Eclipse Installation
> 'New Java Project' 
- src > 'New Java Class'
 - Download Selenium Jar file for Java.
 // Adding 'External Jar' ( Downloaded Selenium exe files ) to the Project Properties. ( As Class not Module )  ( ProjectName => Properties => Libraries ), Which will be used to import methods used in project.
 * Need to do for every project.
 // ''   ( Java API for Selenium )
//For Each browser we need different 'Invoke' file.
 System.setProperty(key, value );
  key = '' ( It's provided by the respective browser developers, Will be different for each browser  )             value = 'Address of invoked file on PC'    
// Create new object.
 className driver = new className();
/* driver: is object
 new : creates new memory for the class */


//                       Basic set up;
  		//Invoking .exe file from Google Chrome 
		System.setProperty("", "C:\\Users\\jpann\\Downloads\\Don't Delete\\chromedriver.exe");
		//Creating Object.
		WebDriver driver1 = new ChromeDriver();

// Invoking for FireFox.
    System.setProperty("webdriver.gecko.driver","Location of           firefox invoke file.")
      //Creating Object.
		WebDriver driver1 = new FirefoxDriver();

          /*   WebDriver Methods.  
//Creating Object.
WebDriver driver1 = new ChromeDriver();          

//Pass the URL to open. 

//Return URL
//Return the Page Source.

//This can be used to navigate the browser ( Go to next or previous link )

//Once the execution is over, Close the test. (current window)

//Once the execution is over, This will close all the Child Windows.

   /* Locator Techniques & Tools used to identify Objects.  
 //Locators: ( the 'selector' is called 'Web Element in Selenium' )
 driver1.findElement("id_NameHere")); //Will locate using 'id'.
 driver1.findElement(By.className("class_NameHere")); // Will locate using 'class name',

// Will locate the element using Tag Name.

 driver1.findElement(By.linkText("forget password?"));
//It will locate the element by the exact text present in the tag.

//Sending Data to an element ( To Input Field ),
 driver1.findElement("id_NameHere")).sendKeys("Text is added from Selenium.")

//It will get the text from #text

- ID's with Numerical values might be dynamic. It might change with clicks/time. So avoid selecting such tags using ID
- Classes with spaces won't work. ( Compound classes will not work )
- If there are two same ID's Selected. It will select the first one.

 //This will click the button with class 'buttonPlay'

 // xpath

> Inspect (F12) on any selected element > Right click on HTML  code on right side ( on the element) > copy > XPath.
> This xpath can be used to select the element.
> This is not always 100% accurate.
> Double quotes inside the double quote won't work. ( use single quotes inside.)
> If the xpath starts with "html/body...", Then it is not relialble to use the path. 
> Might be different path for browsers.  
> Can be created in number of ways. ( using tag/class/attribute/id...)

> Before running the Scipts, We can validate the 'xpath' first, It will save time.
  - We can check/validate the xpath manually by running 
    > $x("xPathHere...") ( It should be written in browser's console, if it returns a array/object then it means the path is valid, if it show null then it's incorrect path)
  - Other way to check the path is to use a extension on the browser.                       
                   > Customized xpath 
 syntax:   //tagName[@attribute='value']
  /*for example */
 - //div[@id='box1'] ( double forward slash are part       of the code, Not comments)
 - //*[@id='username']  
   /*  Here it will  select any tags with id 'username' ( '//' is part of the code, not comments ) */
           > Creating xpath using Regular expression:
 - Sometimes in attributes the value string is fixed but the numerical values keep on changing, or if the value is too long but we know the format So in that case we can use syntax:


Example: <input id="username123"> </input>
> //input[contains(@id,'username')]
 // CSS selector
- CSSselector is 10 times faster than xpath.
> Inspect on any selected element > Right click on HTML  code on right side ( on the element) > copy > CSS selector.
> We can check/validate the path manually using ( in the browser console)
     $("Path here...")

- Css Customized selector:
tagName[attribute='value']   ( @ and '//' are not used here like xpath )

- CSS regular expression selector:

Example: <input id="name1233"> </input>

- Searching using Text
- Syntax : [class='class1 class2']


  // Traversing Through Elements

 // -parent-child
>  If there is no way to select the given element, We can select this tag using it's parent tag.
- define the xpath for parent and then direct to child using tagNames. 
Example: You want to select a 'input' tag and there is no unique/stable way to do it.
- Select it's parent tag first and then come to the child using tagNames, If on the way we have 2 same sibling tags then mention the number with it ( div[1] or divp[2] ).

  - parent : "//div[@class='1st-c']"

> Reach to Child using the parent now
- //div[@class='1st-c']/div/div[2]/div/input
-  parentTag/childTag/innerChildtag  

Child > Parent: ( only possible in xpath)

Example :
child: "//li[@id='item-1']"
- "//li[@id='item-1']/parent::ul"

  //Relative and Absolute xpath.
- Relative : Does not depend upon the Parent or the child node. Even if the parent/child tag is removed, Still the locator (Selected element) should work just fine.  
 Example : "//div[@id='username']"

- Absolute : Here the selector is depended upon the parent/child tags. if any change in the order ,then selector will be affected.
Example:  //section/div/div/div/div/ul/li[2]

      //Sibling Traversing ( "following-sibling::" )

- How to select/traverse through the siblings.

> "//li[@id='li-1']" ( This is the selected 'li' and we want to select it's 3rd sibling.) 
> "//li[@id='li-1']/following-sibling::li[3]"

    //Locating using 'text'  ( using xpath )  
Syntax: "//*[text()=' specificWord ']"
// '*' It represents any tag can be selected.                      
> driver1.findElement(By.xpath("//*[text()=' Singh ']")).getText();                      
//The word should be exactly on the HTML, Include spaces both sides if there are spaces on the HTML code.                      
   /* Selenium Web Drivers
//SELECT :                      
// >Static Dropdown: How to select  option from dropdown list.      
> Select sElement = new Select(elementLocation);
// 'Select' is the in-built class to manage 'select' element.
- We can choose 'option' in 3 ways.
 > sElement.selectByValue("JPY");
 > sElement.selectByIndex(3);
 > sElement.selectByVisibleTest("CANADIAN DOLLAR");

> sElement.deselectAll(); //Will de-Select all the options.

> Thread.sleep(time);
- We can use this to wait for the webpage/Program to laod, So as the next line codes can be executed after 2 seconds.

//Dynamic Dropdown.
- If there are two elements with exactly the same path, It will only select the first one.
- To select the second one, use ("(//a[@value='DEL'])[2]"));
- This will select using it's index.    

: It's not alway good idea to use index, So we use 'Parent-Child' locator,
- So Select the Parent Tag first and then it's child ( This way even if there are two elements with same name, But there Parent could be different.)

Example" ( 1 space after the Parent Element and then the child element Xpath. ):
( //input[@id='ctl00_mainContent_ddl_destinationStation1_CTXT'] //*[@value='DEL'] )
//AutoSuggestive Dropdown.  
: When user type something, The input field will provide some autoSuggestive results ( google, youtube...)

: To Clear the Pre-populated data OR sometimes we just select on the input field and it clears the data.
> .selector().clear();
> .selector().click();

: Use 'Down arrow' button and select using 'Enter'
> .selector()).sendKeys(Keys.DOWN);
> .selector()).sendKeys(Keys.ENTER);

: We can use 'selector' into an variable and re-use it multiple times.
WebElement element = drivere.findElement("idName"));
element.sendKeys("New Text To Seach");
element.sendKeys(Keys.ENTER); //This will push 'Enter' button.

//Radio Buttons:
- We can select button using the usual 'WebElement' 
- we can use  '//input[@name='group1']' to check/compare/code/test the size of the Inputs with same group name.

- Here is the example to select inputs of same group using it's index.
> driver.findElement(By.xpath("//input[@name='group1'][1]")).click();
> Thread.sleep(1000);
> driver.findElement(By.xpath("//input[@name='group1'][3]")).click();
> Thread.sleep(1000);
> driver.findElement(By.xpath("//input[@name='group1'][2]")).click();

- It will return the Size of the input with same same group name.
> driver.findElements(By.xpath("//input[@name='group1']")).size()
> driver.findElements(By.xpath("//input[@type='radio']").get(0);
//It will select the first element.                     

//Play with Attributes:
> selector.getAttribute("value");
> selector.getAttribute("name");
> selector.getAttribute("id");
> selector.getAttribute("class");

//Check the size of the input radio button with same group name.
> int count = driver.findElements(By.xpath("//input[@name='group1']")).size();
> for (int i = 0 ; i < count ; i++ ) {
 //Print the 'attribute's Value of name = 'group1'. We are using loop and it's findElement(s).`
> String checkText = driver.findElements(By.xpath("//input[@name='group1']")).get(i).getAttribute("value");
> if(checkText.equals("Milk")) {
> System.out.println("Milk Found: "+ i);							 driver.findElements(By.xpath("//input[@name='group1']")).get(i).click();

                   /*--------  */

/*  Java Alerts  */
: How can we manage the pop ups which are not web based element's. ( Which are not coded through HTML/Css/Js) are coded through 'Java'.

//We need to switch from 'web' to 'popup' View,So we can manage popups.
> driver.switchTo().alert().getText(); //This will return the whole 'text'on the PopUp.
> driver.switch().alert().sendKeys("Karan Singh"); //This can be used to Pass the value in the text field on PopUp.
> driver.switchTo().alert().accept(); // 'accept' will indicate as:'OK'|'agree'|'accept'
> driver.switch().alert().dismiss(); // 'dismiss' will indicated as 'cancel' | 'No' | 'Ignore'.

                   /*--------  */

//Check Boxes.
> ("//input[@type='checkbox']")
 - It will return all the checkboxes on the given web page. ( use findElements )
> selector.isSelected(); //It will tell if checkbox is selected or not.

                   /*--------  */

- It is a way to check if the Test case Passed or Failed. We are not to use console log's to check the results and see if the test is passed or failed, In work we are to be use "Assertions", Which will automatically tell if a test passes or failes. 
- Download 'testing Java' file and add it to your project Path.

- Boolean Check:
> Assert.assertTrue(data);
//This will expect a TRUE value to Pass the test.

> Assert.assertFalse(data);
//This will expect a FALSE value to Pass the test.

- Value Check: (String or value):
> Assert.assertEquals(selecter.getText(), "5 Adults");
: This will check the 'text' from selector and compare it to the '5 Adults'.

: We can select the current date using classes/ or some other way.

//Check if the element is enabled or disabled.
> select.isSelected(); //This does not work some times, Because of the website/app. As it might appear it's disabled but the selenium gets confused.
- We can Test/check the specific classed/attributes in the element, Which will tell us if the element is disabled/removed.
> select.getAttribute("style")
//This will return a complete STRING of all the CSS properties.
> select.getAttribute("style").contains("opacity:1"); //True
> select.getAttribute("style").contains("opa"); //True
> select.getAttribute("style").contains("1"); //True
> select.getAttribute("style").contains("opp"); //False
> select.getAttribute("style").contains("1");
//We can check the string by using 'contains' method.

  /* ------------XX--XX--XX---------*/

       /*-------Deep Dive Into Function-------------- */

: Format Code & debugging
// This will format the code in the aligned format. 

: Naming Convection
- Class name should always start with capital letter ( Not camelCase )
- Variable should always be in lower case letters.
- Use CamelCase for Variable name.

- Debugging:
 > Right click on the line number and tap 'Toggle Breakpoint'
 > Debug As > Java Application.
 //This way the scipt will stop at toggled point and we need to manually push the 'next button' ( Step over or F6) to move to next line on script or push 'RESUME' it will resume the script in regular fashion.

//Adding Item Into the Carts 
//set up:


  //It will return the absolute path for current folder.
console.log(__filename);  //It will return the absolute path for current folder  with file name.

// Modeles | Require
let data = require("./script");
/* :> './' will look for relative to current path,
'require(".fileName") Will return the object.'

module.exports = { var1, var2 }
// We can export multiple things/variables.

let { people } = require("./totalPeople");
// It will only return the 'people' variable in 'totalPeople'.

let { people, age } = require("./totalPeople");
// It will only return the 'people' and 'age' variables in 'totalPeople'.

// Also called Destructuring.
let os = require("os");
//Will provide built in Operating System module( object).

//Will return the type of OS ( windows/Linux...);

//It will provide the HOME directory

const fs = require("fs");
 //Built in module, Used to read/write the files. ( FILE SYSTEM )
                       // Reading Files
fs.readFile(('./R/text.txt'), ( error, data ) => {
   console.log("Data: ", data); // It will return a package as a Buffer. 
   console.log(data.toString()); // It will provide the data (text.txt) in readable format.
//'readFile' is an async function and will not block the execution.

                      // Writing Files
fs.writeFile('./R/text.txt', " This is new replaced data,  ", ( ) => {
  //If the address is not valid, It will create the file.
  // It will replace the old data.
  //Since it's Async function, Call back function is required.
  console.log("Data updated");
//'writeField' is an asyn function and will not block the execution.

                      // Directories
    if(err) { console.log("Error: ",err) }
    console.log("Folder created");
    if(err) { console.log("Error: ",err) }
    console.log("Folder Removed");

//Check if specific 'folder' exist or not.
  //Check if 'Resources' folder is there or not.
  //'existSync' is a sync function and will block the code. 

  //Check for folder 'R' using '!'.
    console.log(" R Folder does not exists");

 //Create Folder.
     if(err){ console.log("Issue with creatin Folder") };
     console.log("Folder R created")
}else {
    //If already there, then deleting 'R' Folder
        if(err){ console.log("issue with deleting Folder") }
        console.log("Folder R Deleted.")


                      // Deleting Files        
fs.unlink("./R/text.txt", (err)=>{
    console.log("Issue with deleting File");
    console.log("File has been deleted.")

//We should always check first if 'folder'/'files' exist or not.
  console.log("Folder 'R' does exist");

  console.log("File 'file.txt' does exist");
** //Summary
  //Import Modules
const http = require("http");
const fs = require("fs");

//Creating Server
const server = http.createServer((req, res)=>{})

//Read File.
fs.readFile("./R/blogData.txt",(err,data)=>{ })

//Writing Files
fs.writeFile("./R/newFile4", "To a worm in horseradish, The world is horseradish.", (error)=>{
 // console.log("File Updated.")

//Create Directories.

//Check the Folder/File

//Remove Folder
fs.rmdir("./R/NewFolderCreated",(error)=>{ })

//Deleting File
fs.unlink("./R/newFile2",(error) =>{ })

//Server Configuration.
server.listen(8080 ,"localhost",()=>{});


 //Streams and Buffers.       
 Stream : Start using data, Before it has finished loading. Data will be transferred as 'Buffers'.
                //Create/Read new Stream
let createStream1 = fs.createReadStream("./R/sampleData.txt");
//Address should be mentioned.
/* We can pass the 2nd argument as '{ encoding: "utf8" }', and this we don't have to use 'toString()'.
let createStream1 = fs.createReadStream("./R/sampleData.txt",{encoding:"utf8"});

  //'on' is event listener, 
  //'data' is type of event. ( example 'click','scroll')
  //Every time we get new buffer, This 'bufferData' will be called ( call back function.)
                          //Write Stream       
let createStream = fs.createReadStream("./R/sampleData.txt", { encoding:'utf8'});
let writeStream = fs.createWriteStream('./R/blogData.txt');//if address does not exist, It will create new one.

writeStream.write('First Line Here...'); 
// It will write the provided text in './R/blogData.txt'

  //For every 'buffer' generated, It will passed on to 'writeStream' 
    writeStream.write("Some Data");
    writeStream.write( buffer );
 writeStream.write('Last Line Here....'); 
  //Streams and buffers.
let createStream = fs.createReadStream("./R/sampleData.txt", { encoding:'utf8'});
let writeStream = fs.createWriteStream('./R/blogData.txt');

writeStream.write("First Line...");

//Using 'PIPE'
 //It will automatically pass all the data to './R/blogData.txt'. from "./R/sampleData.txt".
                 //Client and Servers
const http = require("http");

const server = http.createServer((req, res)=>{
      console.log("Request Made")

server.listen( 3000 , 'localhost' ,()=>{
  // 'localhost' is by default.
    console.log("Server is Live on Port 3000")

            //Requests and Responses.
  const server = http.createServer((req, res)=>{
      console.log("Request Made")
    //It will provide the 'url'. Root url is '/'.
    //It will return the method used. 

const server = http.createServer((req, res)=>{

  //Set Header Content Type.
  res.setHeader("Content-type", "text/plain");
  //It will tell browser what kind of content to      expect. It can '"text/html"', If we want to pass     on HTML content/tags. 
  res.write(" Hello Karan");
  res.end(); //Manually end it. This will send the response to the browser. 
//Linking HTML file to the Code. 
 let fs = require("fs");

const server = http.createServer((req, res)=>{

  res.setHeader("Content-type", "text/html");
  //'text/html' is used, This time we will passing data as a HTML content ( with Tags nd all);
  fs.readFile('./home/Index.html',(err, data)=>{
      console.log("Koi Panga", err);
      //If err then we want to end the response, So that browser will move with next step ( other wise it will struck on loading )
    }else {
      res.write(data); //We are passing 'index.html' as the data.
      //We can also use 'res.end(data)'(for single file). ( res.write() will not be needed. )

  res.write(" Hello Karan");
  res.end(); //This will send the response to the browser. 
 const server = http.createServer((req, res)=>{   
 console.log("URL: ", req.url)
 let path = "./"; // Root will always be './'
 switch( req.url ){
  case '/':
  path += 'index.html'

  case '/about':
  path += "about.html";
  default :
  path += "404.html";
     //This we can add specific page

 //Header Content.
 res.setHeader("Content-type", "text/html");
 fs.readFile(path,(err, data )=>{
   //Depending upon the URL, It will return the required HTML/plain page.
                  //Status Codes
   200 - OK
   301  Resource moved
   404  Not Found
   500  Internal serval error



/*  Creating Database  */
           /* Common Commands */

man //It is the 'manual' for all the commands in the linux system. 
> man ls //It will provide manual for 'ls'
> man touch //It will provide manual for 'touch'
> man man (All the manual will be displayed)
> man -k search //It will provide all the keywords related to 'search'.
> man -k jaskara //It will provide all the keywords related to 'jaskara'

which //It will provide the location from where shell is using the command.
> which touch //It will return the location of 'touch' cmd.
> which ls //It will return the location of 'ls' cmd.

 uname // This cmd will provide the system OS basic information.
uname -a | uname -i | uname -m

sudo parted // "Hard drive" details
parted -l //Provide partition of the HDD

sudo shutdown -h now //It will immediately shutdown the system
sudo shutdown -h +10 //It will shutdown the system in 10minutes.   
sudo shutdown -h +10 "System Will shutdown in 10minutes, Please Save your Work"//It will shutdown the system in 10minutes with the Prompted information.   
sudo shutdown -r now //It will Reboot the system.
sudo shutdown -c // To cancel the scheduled shutdown. 

pwd //Print Working Directory. ( It will provide the current directory)

cd //Change directory.
> cd /  //This will take to the parent directory.
> cd /childFolder/ChildsChildFolder/ // This will take the folder. But we should be in the current node to get to the child.   
> cd ~/desiredFolder //It will directly take to the desired folder. We don't have to worry about the current node.
> cd ..   //It will take to the previous directory
> cd ../..  /* Will take two directories back*/
> cd ../../..  /* Will take three directories back*/
> cd ~ //It will take to home directory

ls // It will Provide all the list items/files in the relative directory
> ls -l // It will provide detailed information.
> ls -alh  
> ll
// It will provide easier format to read.
> ls test* //It will only look for folders starting with string 'test'.
> ls *est //It will only look for folders ending with string 'est'.

> find / -name fileName* //it will find evrything starting          with 'fileName'.( might have to add sudo )
mkdir //It is used to create new folders. 
> mkdir folderName1
> mkdir test{1..5} //It will create 5 folders with pattern test1...test5.
> mkdir test{a..d}
touch // It will create new File(blank) in the directory.
> touch index.html
> touch script.js
> touch index.html style.css script.js //It will create all three files.

mrdir //It is usded to delete folders.

rm //It is used to remove files/Folders.
> rm index.html
> rm index.html style.css script.js //It will remove all three files.
rm -r folderName //Will delete all child data ( 'r' is recursive )
> rm -r test{1..5} //It will remove all the files with provided pattern

cat //Concatenate FILE(s) to standard output.
    //It can also be used to view files/data
    //It can only view text files.
> cat text.txt // It will print the 'text.txt'
> head text.txt //It will display the first 10 lines of the 'text.txt'
> head -2 text.txt //It will display first 2 lines.
> tail text.txt //It will display the last 10 lines of the 'text.txt'
> tail -2 text.txt //It will display last 2 lines.

> cat fileName (press double 'Tab') //It will return all the files starting with 'fileName'(s)

 grep //...
     //This can be used to filter data.
> sudo grep opened /var/log/auth.log //It will provide all the 'opened' in 'auth.log' file.

date //It will return date information.


                 /*General Theory */
- Linux is case sentitive
- Relative : Present location ( Current directory)
- Absolute : Location from Root.
- Sudo group : A group of superusers that can access the root account and be receive unlimited privileges.


              /* Ubuntu Server */

> sudo updateddb //It will update the database.

> locate fileName 
> locate test* //It will return all files starting with 'test'  

              /*  Managing User */
//ONLY super user can add user on the system.
 //To Add User.  
> sudo useradd -d /home/dUserFolder -m dUserName
//It will add 'dUserName' as a new user name on the system
> sudo passwd dUserName
//It will create the password for 'dUserName'.

//2nd way to Add User. ( better way )
adduser //It is a script to 'add user',(not a command)  
> sudo adduser dUserName
//It will automatically create user and it's respestive folder and will ask to create password for it.

> cat /etc/group
 //It will return all the groups on the system. 
> cat /etc/group | grep dUserName
//It returns the 'group'(s) of user name 'dUserName'


              //Modify Users

//Add Group to user.
sudo usermod -aG groupName UserName
> sudo usermod -aG sudo dUserName
// We are adding 'sudo' group to user 'dUserName'.

> su UserName1
//It will change the terminal to 'UserName1'

//Lock User
> sudo usermod -L dUserName

//unlock User
> sudo usermode -U dUserName

//   /etc/passwd
> cat /etc/passwd
 //It will provide all the user's on the system ( including system groups ).

> sudo vipw
//It will display all the User's in a nano editabled list.
// Remove the need groups by using CTRL+K(To remove the line/group ) > CTRL+O (over write) > CTRL+X (exit).
//Removed groups will not show in the '> cat /etc/passwd'

//2nd way to remove group
> groupdel [options] GROUPNAME

//  /etc/shadow
//It will return all the user's and there respective password and password data ( encryption used + Password expiration information ) . 

//Remove User
> deluser [--remove-all-files] [--backup] [--back-to DIR] dUserName
//It will remove the user and also the create the back for it.


            /*   Managing Groups  */

> sudo addgroup groupName1
//It will add 'groupName1' to the user.

> grep groupName1 /etc/group
//It will return the information about 'groupName1' 

> groups
//It will return all the groups for the user.

> ll text.txt  
> ls -alh text.txt
 //It will provide the basic information about the file, inclduing permissions it has. 

-1 - 2- 3 -4
//Here Numbers are different groups. 
rw : read and write
r : Read.
x : executable file

To change Groups:
> sudo usermod -g newPrimaryGroup dUserName
//'newPrimaryGroup' Will be the primary group.

//Where can we keep the files to share data between different users. 
/srv - for files that may be shared using a service externally.

//To modify the permission for user on the group.

//It will make new folder,
> sudo mkdir /home/newFolder

 //Adding new group
> sudo addgroup grpName1

// Group 'groupName1' will have access to 'newFolder' folder.
> sudo chgrp grpName1 /home/newFolder


           /*  Managing Text Files  */

vim | nano
//Two popular linux terminal's IDE.

// VIM

> sudo app install vim
//In case if VIM is not installed by default.

> vim filesName.text


     /* Linux Structure */

- man hier
//It will return the structure of the Linux system and basic idea about all the files.


         /*  Remote Access    */

- SSH works on TCP.



# By default, each destination (name of new link) should not already exist

ln -s /home/user/project /var/www/html

# The link will be created inside /var/www/html having the name of the target i.e. project.
# If you want to have a symlink /var/www/html pointing to /home/user/project then you should not have the directory html present beforehand. So, you should only have /var/www and then running the following will create the desired symlink (don't do this unless you are sure)
command -v STM32_Programmer_CLI >/dev/null 2>&1 || { echo >&2 "Need to add STM32_Programmer_CLI to the enviorenment path. Aborting..."; exit 1; }

if [[ $file =~ \.bin$ ]] || [[ $file =~ \.hex$ ]]; then
    echo "OK" >&2
    echo "NOT OK" >&2
    exit 2
if [ "$#" -ne 1 ]; then
  echo "Usage: $0 Path to binary file" >&2
  exit 1
sudo apt install stress
stress --cpu 8
curl -fsSL | sudo -E bash -
sudo apt-get install -y nodejs
# check the status of the web server i.e apache2
sudo systemctl status apache2

# restart the service
sudo systemctl restart apache2

# return network-related information using a combination of flags along with the netstat command to check which process is using a particular port
sudo netstat -nlp

# find python3 programs running
ps -ax | grep python3

# kill a process by its process ID (PID)
sudo kill [process-id]

# let's check for the availability of any service with the keywords "python" or "jimmy"
sudo systemctl --type=service | grep jimmy

# stop and disable a service using
sudo systemctl stop _servicename_ && sudo systemctl disable _servicename_

# start a web service using nginx
service nginx start

# check nginx landing page using curl
curl http://localhost:80
# install docker
sudo apt-get install

# create and run a container from an image from the Docker Hub
sudo docker run --name firstContainer ubuntu:latest # where firstContainer is the name of the container

# list locally available docker containers
sudo docker ps -a

# open a docker container in interactive mode in the terminal
sudo docker run -it --name myContainer ubuntu:latest # where myContainer is the container name
# you can exit the container by pressing CTRL+P and CTRL+Q

# attach container to terminal
sudo docker attach myContainer # the container will now stay open in the background even after exiting via CTRL+P and CTRL+Q

# execute commands in the container running in the background
sudo docker exec myContainer echo $PATH

# delete containers
sudo docker rm -f firstContainer myContainer

# create new docker image based on your local environment/container
sudo docker commit myNginx docker_id/image_name # where myNginx is the name of your currently running container

# create new docker container from an image from a previously committed image
sudo docker run -it --name nginxNew docker_id/image_name

# list images on your machine
sudo docker image ls

# login to your docker hub account from the terminal
sudo docker login # you will be prompted to enter your id and password

# push an image to docker hub when logged into your docker account
sudo docker push docker_id/image_name

# run a docker container in the background
sudo docker run -d --name myApp nginx

# start an interactive bash terminal for the container running in the background
sudo docker exec -it myApp bashapt-get

# stop a running container
sudo docker stop myApp

# start a stopped container again
sudo docker start myApp
# replace _file_name_ with the name of the file that is to be made executable including its filetype suffix, e.g. ".py"
chmod +x _file_name_
sudo forever start --sourceDir /opt/bitnami/projects/nesk_back -c "npm run prod" /
ip addr | grep eth0 | grep inet | awk '{print $2}' | awk -F '/' '{print $1}' | awk '{printf "%s:3000", $0}' | clip.exe

Wed Mar 01 2023 18:29:15 GMT+0000 (UTC)

#oracle #linux

Sat Dec 03 2022 18:21:51 GMT+0000 (UTC)

#ubuntu #linux

Tue Oct 04 2022 13:49:00 GMT+0000 (UTC)

#ubuntu #linux #deb #install

Wed Sep 07 2022 06:51:12 GMT+0000 (UTC)

#bash #linux #screen

Wed Aug 03 2022 08:54:45 GMT+0000 (UTC)


Sat Jul 02 2022 01:17:06 GMT+0000 (UTC)

#whatever #unix #linux #path

Sun Jun 12 2022 06:10:39 GMT+0000 (UTC)

#linux #ngnix

Sat May 28 2022 21:19:29 GMT+0000 (UTC)

#ubuntu #linux #mbpfan

Sat May 28 2022 14:42:18 GMT+0000 (UTC)

#bash #linux #ubuntu

Sun May 15 2022 17:04:29 GMT+0000 (UTC)

#ubuntu #linux #bash #sariohara

Fri Apr 22 2022 17:12:36 GMT+0000 (UTC)

#bash #ssl #linux #apache #certificates

Fri Apr 22 2022 16:54:00 GMT+0000 (UTC)

#bash #ssl #linux #unix #certificate

Mon Apr 11 2022 14:11:19 GMT+0000 (UTC)

#linux #ubuntu #nginx

Mon Apr 11 2022 13:41:23 GMT+0000 (UTC)

#linux #ubuntu #nginx

Tue Apr 05 2022 15:48:31 GMT+0000 (UTC)

#terminal #linux

Tue Apr 05 2022 15:44:18 GMT+0000 (UTC)

#linux #terminal #benchmark

Tue Mar 29 2022 10:28:56 GMT+0000 (UTC)

#raspberrypi #linux

Wed Mar 16 2022 12:56:00 GMT+0000 (UTC)

##terminal #linux #commandline

Sat Feb 26 2022 16:02:13 GMT+0000 (UTC)

#vim #linux

Tue Feb 15 2022 17:06:49 GMT+0000 (UTC) undefined

#linux #commands

Thu Feb 10 2022 11:23:59 GMT+0000 (UTC)

#vim #linux

Wed Feb 09 2022 13:38:38 GMT+0000 (UTC)

#linux #ssh

Wed Feb 09 2022 13:32:52 GMT+0000 (UTC)

#linux #ssh

Sun Feb 06 2022 11:34:48 GMT+0000 (UTC)

#linux #commandline #bash

Wed Feb 02 2022 22:16:48 GMT+0000 (UTC)

#installation #linux #bash #wsl

Wed Feb 02 2022 22:16:16 GMT+0000 (UTC)

#installation #linux #bash #wsl

Wed Feb 02 2022 22:15:45 GMT+0000 (UTC)

#installation #linux #bash #wsl #powershell

Wed Feb 02 2022 22:15:12 GMT+0000 (UTC)

#installation #linux #bash #wsl

Wed Feb 02 2022 22:14:32 GMT+0000 (UTC)

#installation #linux #bash #wsl

Wed Feb 02 2022 22:14:04 GMT+0000 (UTC)

#installation #linux #bash #wsl

Wed Feb 02 2022 22:13:33 GMT+0000 (UTC)

#installation #linux #bash #wsl

Wed Feb 02 2022 22:12:47 GMT+0000 (UTC)

#installation #linux #bash #wsl

Wed Feb 02 2022 22:09:23 GMT+0000 (UTC)

#installation #linux #bash #wsl #git

Wed Feb 02 2022 22:08:42 GMT+0000 (UTC)

#installation #linux #bash #wsl #github #cli

Wed Feb 02 2022 22:07:52 GMT+0000 (UTC)

#installation #linux #bash #wsl #cargo #rust

Wed Feb 02 2022 22:07:13 GMT+0000 (UTC)

#installation #linux #bash #wsl #azure

Wed Feb 02 2022 22:06:40 GMT+0000 (UTC)

#r #installation #linux #bash #wsl

Sun Jan 30 2022 20:56:24 GMT+0000 (UTC)

#vim #linux

Sat Nov 13 2021 03:35:18 GMT+0000 (UTC)

#linux #server

Mon Oct 18 2021 14:17:05 GMT+0000 (UTC)

#linux #server

Wed Sep 29 2021 04:22:23 GMT+0000 (UTC)

#linux #server

Tue Sep 21 2021 17:41:17 GMT+0000 (UTC)


Tue Sep 21 2021 17:30:11 GMT+0000 (UTC)


Tue Sep 21 2021 17:17:46 GMT+0000 (UTC)


Tue Sep 21 2021 13:03:29 GMT+0000 (UTC)


Tue Sep 21 2021 12:58:44 GMT+0000 (UTC)


Mon Aug 30 2021 20:10:30 GMT+0000 (UTC)

#linux #server

Wed Aug 25 2021 04:44:09 GMT+0000 (UTC)

#linux #server

Mon Aug 23 2021 14:59:32 GMT+0000 (UTC)

#linux #server

Wed Aug 11 2021 03:54:23 GMT+0000 (UTC)

#linux #server

Tue Jul 27 2021 03:07:32 GMT+0000 (UTC)

#linux #server

Sat Jul 24 2021 13:41:12 GMT+0000 (UTC)

#linux #server

Fri Jun 18 2021 08:58:12 GMT+0000 (UTC)

#symlink #linux #filesystem

Wed Jun 09 2021 10:26:20 GMT+0000 (UTC)

#linux #shell-script

Wed Jun 09 2021 10:16:48 GMT+0000 (UTC)

#linux #shell-script

Wed Jun 09 2021 08:41:11 GMT+0000 (UTC)

#linux #shell-script

Thu May 06 2021 10:24:14 GMT+0000 (UTC)


Thu May 06 2021 10:20:29 GMT+0000 (UTC)

#linux #cpu

Thu May 06 2021 10:18:48 GMT+0000 (UTC)

#linux #cron

Sun Apr 18 2021 16:35:19 GMT+0000 (UTC)

#ubuntu #bash #linux

Sat Apr 10 2021 05:57:14 GMT+0000 (UTC)

#linux #nginx

Sat Apr 10 2021 05:55:14 GMT+0000 (UTC)

#linux #docker

Thu Mar 25 2021 09:14:28 GMT+0000 (UTC)


Sat Jun 13 2020 08:20:55 GMT+0000 (UTC)

#bash #linux

Fri Dec 27 2019 13:19:35 GMT+0000 (UTC)

#commandline #interesting #windows #ubuntu #linux

Save snippets that work with our extensions

Available in the Chrome Web Store Get Firefox Add-on Get VS Code extension