Linux Platform - Yash-777/LearnJava GitHub Wiki

λ cmder Portable console emulator for Windows

Installation - Latest Version: v1.3.25 download/v1.3.25/cmder.zip

  • Unzip
  • (optional) Place your own executable files into the bin folder to be injected into your PATH.
  • Run Cmder (Cmder.exe)
C:\Softwares\cmder
λ D:

D:\
λ CD D:\MyWork\bashScript
MySQL Client Connectivity Commands
D:\MyWork\bashScript
λ mysql -u root -p -h 127.0.0.1 -P 3306
Enter password: ****
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 943
Server version: 8.0.33 MySQL Community Server - GPL

Copyright (c) 2000, 2023, Oracle and/or its affiliates.

Oracle is a registered trademark of Oracle Corporation and/or its affiliates. 
Other names may be trademarks of their respective owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> SET GLOBAL local_infile = 1;
Query OK, 0 rows affected (0.00 sec)

mysql> show variables like '%local_infile%';
+---------------+-------+
| Variable_name | Value |
+---------------+-------+
| local_infile  | ON    |
+---------------+-------+
1 row in set (0.03 sec)

mysql> SELECT VERSION();
+-----------+
| VERSION() |
+-----------+
| 8.0.33    |
+-----------+
1 row in set (0.00 sec)

mysql> exit;
Bye
Shell Script Run with Example

Run with out parameters, Sample Output:

D:\MyWork\bashScript
λ bash shellScriptBasics.sh
Usage: shellScriptBasics.sh DB_USER DB_PASS DB_NAME DATA_DIR
Example: shellScriptBasics.sh myuser mypassword myDB /path/to/data/files

Run with parameters, Sample Output:

D:\MyWork\bashScript
λ bash shellScriptBasics.sh root root myworkdb loadSqlFilesDir
-----------------------------------------
✅ Runtime Parameters:
DB_USER  : root
DB_PASS  : ******** (hidden for security)
DB_NAME  : myworkdb
DATA_DIR : loadSqlFilesDir
-----------------------------------------
START...
Starting at time: 2025-10-16 19:32:43
---------------------------
� Found data directory: loadSqlFilesDir
---------------------------
� Loop count: 1 | Current time: 2025-10-16 19:32:44
� Loop count: 2 | Current time: 2025-10-16 19:32:49
� Loop count: 3 | Current time: 2025-10-16 19:32:54
� Loop count: 4 | Current time: 2025-10-16 19:33:00
� Loop count: 5 | Current time: 2025-10-16 19:33:05
---------------------------
⚠️  No CSV files found in directory: loadSqlFilesDir
---------------------------
END...
Finished at: 2025-10-16 19:33:11
Total duration: 00:00:27 (hh:mm:ss)
#!/bin/bash
###############################################################################
# @file        db_import_task.sh
# @brief       Bash script to simulate database import and timed execution task
# @description
#   - Accepts database credentials and data directory as input parameters.
#   - Validates input arguments and data directory.
#   - Simulates CSV file imports (or real imports can be added).
#   - Executes a 5-iteration timed loop (1-minute each).
#   - Calculates and displays total elapsed time in hh:mm:ss format.
#
# @usage
#   ./db_import_task.sh DB_USER DB_PASS DB_NAME DATA_DIR
#   Example:
#     ./db_import_task.sh myuser mypass myDB /path/to/data
#
# @author
#   Yashwanth Merugu
###############################################################################

# -------------------------------
# Function: print_duration
# Description: Prints total duration from start to current time.
# This function is called automatically on exit.
# -------------------------------
print_duration() {
  end_time=$(date "+%Y-%m-%d %H:%M:%S")
  end_sec=$(date +%s)
  duration=$(( end_sec - start_sec ))
  hours=$(( duration / 3600 ))
  minutes=$(( (duration % 3600) / 60 ))
  seconds=$(( duration % 60 ))

  echo "---------------------------"
  echo "END..."
  echo "Finished at: $end_time"
  printf "Total duration: %02d:%02d:%02d (hh:mm:ss)\n" "$hours" "$minutes" "$seconds"
}

# Ensure duration is printed even if script exits early
trap print_duration EXIT

# -------------------------------
# Validate Required Parameters
# -------------------------------
if [ "$#" -ne 4 ]; then
  echo "Usage: $0 DB_USER DB_PASS DB_NAME DATA_DIR"
  echo "Example: $0 myuser mypassword myDB /path/to/data/files"
  exit 1
fi

# -------------------------------
# Assign Parameters to Variables
# -------------------------------
DB_USER="$1"
DB_PASS="$2"
DB_NAME="$3"
DATA_DIR="$4"

# -------------------------------
# Print Runtime Parameters
# -------------------------------
echo "-----------------------------------------"
echo "✅ Runtime Parameters:"
echo "DB_USER  : $DB_USER"
echo "DB_PASS  : ******** (hidden for security)"
echo "DB_NAME  : $DB_NAME"
echo "DATA_DIR : $DATA_DIR"
echo "-----------------------------------------"

# -------------------------------
# Capture Start Time
# -------------------------------
start_time=$(date "+%Y-%m-%d %H:%M:%S")
start_sec=$(date +%s)

echo "START..."
echo "Starting at time: $start_time"

# -------------------------------
# Step 1: Validate Data Directory
# -------------------------------
echo "---------------------------"
if [ ! -d "$DATA_DIR" ]; then
  echo "❌ ERROR: Data directory '$DATA_DIR' does not exist."
  exit 2
fi

echo "📁 Found data directory: $DATA_DIR"

# -------------------------------
# Step 2: Timed Loop (Demo Task)
# -------------------------------
echo "---------------------------"
for i in {1..5}; do
  current_time=$(date "+%Y-%m-%d %H:%M:%S")
  echo "🕒 Loop count: $i | Current time: $current_time"
  sleep 5  # Sleep for 5 seconds
done

# -------------------------------
# Step 3: Process CSV Files
# -------------------------------
echo "---------------------------"
shopt -s nullglob  # Prevents literal *.csv if no files exist
csv_files=("$DATA_DIR"/*.csv)

if [ ${#csv_files[@]} -eq 0 ]; then
  echo "⚠️  No CSV files found in directory: $DATA_DIR"
  exit 0
fi

for file in "${csv_files[@]}"; do
  echo "🚀 Importing file: $file into database $DB_NAME"
  # Simulated import command:
  # mysql -u"$DB_USER" -p"$DB_PASS" "$DB_NAME" -e \
  #   "LOAD DATA LOCAL INFILE '$file' INTO TABLE my_table FIELDS TERMINATED BY ',' LINES TERMINATED BY '\n';"
  sleep 1  # Simulate time taken for import
done

echo "✅ All files processed successfully!"
echo "---------------------------"


# -------------------------------
# Script automatically ends — trap prints duration
# -------------------------------

Firewall Check

$ telnet github.com 443
Trying 140.82.118.3...
Connected to github.com.       [Firewal enabled]
telnet: connect to address 10.55.72.14: Connection timed out  [Firewal disabled/not-enabled]

To kill the process using port 8080 on Windows, you can use the following command in Command Prompt

ApplicationContextException: Failed to start bean 'webServerStartStop'; nested exception is org.springframework.boot.web.server.PortInUseException: Port 8084 is already in use

C:\Users\yashwanth>netstat -ano | findstr :8084
  TCP    0.0.0.0:8084           0.0.0.0:0              LISTENING       27884
  TCP    [::]:8084              [::]:0                 LISTENING       27884
 
C:\Users\yashwanth>taskkill /PID 27884 /F
SUCCESS: The process with PID 27884 has been terminated.
 
C:\Users\yashwanth>netstat -ano | findstr :8084
 
C:\Users\yashwanth>

How To Kill Process in Linux or Terminate a Process in UNIX / Linux Systems

Syntax

kill -[signal] PID
kill -15 PID
kill -9 PID
kill -SIGTERM PID
kill [options] -SIGTERM PID
[Yash777@devappsr001 bin]$ ps -ef|grep java

[Yash777@devappsr001 bin]$ kill -l
 1) SIGHUP       2) SIGINT       3) SIGQUIT      4) SIGILL       5) SIGTRAP
 6) SIGABRT      7) SIGBUS       8) SIGFPE       9) SIGKILL     10) SIGUSR1
11) SIGSEGV     12) SIGUSR2     13) SIGPIPE     14) SIGALRM     15) SIGTERM

[Yash777@devappsr001 bin]$ kill -9 2675
-bash: kill: (2675) - Operation not permitted

-- Switch to a group having permission to kill the process
[Yash777@devappsr001 bin]$ sudo su - tomcat

[Yash777@devappsr001 bin]$ kill -9 2675

Give group the right to send kill signals

The problem is limiting damage. You can get quite close with sudo. Consider this sudoers entry:

%group1 ALL = (user1) pkill -HUP <name of process>
Then members of group1 can do:

sudo -u user1 pkill -HUP <name of process>

PortQryUI - User Interface for the PortQry Command Line Port Scanner. support.microsoft

Portqry.exe is a command-line utility that you can use to help troubleshoot TCP/IP connectivity issues. Portqry.exe runs on Windows 2000-based computers, on Windows XP-based computers, and on Windows Server 2003-based computers. The utility reports the port status of TCP and UDP ports on a computer that you select.

Portqry.exe reports the status of a TCP/IP port in one of the following three ways:

  • Listening : A process is listening on the port on the computer that you selected. Portqry.exe received a response from the port.
  • Not Listening: No process is listening on the target port on the target system. Portqry.exe received an Internet Control Message Protocol (ICMP) "Destination Unreachable - Port Unreachable" message back from the target UDP port. Or if the target port is a TCP port, Portqry received a TCP acknowledgement packet with the Reset flag set.
  • Filtered: The port on the computer that you selected is being filtered. Portqry.exe did not receive a response from the port. A process may or may not be listening on the port. By default, TCP ports are queried three times, and UDP ports are queried one time before a report indicates that the port is filtered.

PuTTY is an SSH and telnet client


WinSCP Free SFTP, SCP and FTP client for Windows Documentation

WinSCP is an open source free SFTP client, FTP client, WebDAV client, S3 client and SCP client for Windows. Its main function is file transfer between a local and a remote computer. Beyond this, WinSCP offers scripting and basic file manager functionality.

WinSCP functionality

Main Features

  • Graphical user interface
  • Integrated text editor
  • All common operations with files
    1. Binary and text transfer modes
    2. File masks for selecting files
    3. Operation masks for changing filenames
  • Scripting and task automation
  • Translated into many languages
  • Advanced transfer settings

⚠️ **GitHub.com Fallback** ⚠️