Force Overwrite Files with Cp on Linux

Command to force “cp” to copy and overwrite files without confirmation: Call “cp” directly to prevent it from using the aliased version: /bin/cp -rf /source/* /destination/bin/cp -rf /source/* /destination Or use “yes” to auto-reply with “y” to confirmation: yes | cp -rf /source/* /destinationyes | cp -rf /source/* /destination

Netstat Count Active ESTABLISHED Connections

Count all active ESTABLISHED connections: netstat -anp | grep ESTABLISHED | wc -lnetstat -anp | grep ESTABLISHED | wc -l Count all active ESTABLISHED connections on port 80: netstat -anp | grep :80 | grep ESTABLISHED | wc -lnetstat -anp | grep :80 | grep ESTABLISHED | wc -l Count all active ESTABLISHED connections on […]

Copy Files Preserving Timestamps on Linux

You can use the parameter “-p” to preserve timestamps and modification date: -p same as –preserve=mode,ownership,timestamps-p same as –preserve=mode,ownership,timestamps Recursively (-R) copy a folder maintaining modification time (-p): cp -Rp folder destinationcp -Rp folder destination Copy all .log files maintaining modification time: cp -p *.log destinationcp -p *.log destination More information:

Javascript Get Window Location Hostname

Various example demonstration how to get URL on the address bar using Javascript, which include location.hostname,, window.location.origin, and more. In the example below I included also an example to remove the www. from the website address. Here is the script code to get various locations with Javascript var x = location.hostname; document.getElementById("demo1").innerHTML= x; var […]

Bash Script to Get Website IP Address

Simple bash script to get IP address of a website: #!/bin/bash # Usage: ./script ip="$(/usr/bin/dig A $1 +short)" echo $1 = $ip#!/bin/bash # Usage: ./script ip="$(/usr/bin/dig A $1 +short)" echo $1 = $ip Example output: root@server:~# ./ = ./ =

RAID1 vs RAID5 IOPS Write\Read Speed Benchmark

Here is a simple RAID1 vs RAID5 IOPS write\read speed benchmark test: RAID5 (3x120GB SSD) The server has the following characteristics: 2 x Intel Xeon E5 2620 12C/24T @2,00 GHz 3x120GB SSD (RAID5) 128GB RAM DDR32 x Intel Xeon E5 2620 12C/24T @2,00 GHz 3x120GB SSD (RAID5) 128GB RAM DDR3 The RAID controller type and […]

Rotate Nginx Logs and Append Date and Time

I needed to rotate Nginx logs and append the date and time, i.e: access.log => access.log-25-02-2017access.log => access.log-25-02-2017 So instead of adding a number like access.log.1 I need to add date. Here are two solutions that can be used: Use a custom bash script Here is a simple bash script that can do the work: […]

Determine RAID Controller Type and Model on Linux

First you need to install lshw and lspci: apt-get install lshw pciutilsapt-get install lshw pciutils Then type this command to get RAID controller details: lspci | grep -i raidlspci | grep -i raid It should display the RAID controller type and model, i.e: 04:00.0 RAID bus controller: Hewlett-Packard Company Smart Array Gen8 Controllers (rev 01)04:00.0 […]

Copy Files on Google Storage Buckets

You need to use gutils cp command: Example command to copy all .txt files to my-bucket: gsutil cp *.txt gs://my-bucketgsutil cp *.txt gs://my-bucket Example command to copy all .txt files to my-bucket/Folder/: *** Folder will be created if not existent *** gsutil cp *.txt gs://my-bucket/Folder/gsutil cp *.txt gs://my-bucket/Folder/

Install Megaclisas-status on Debian for LSI MegaRAID SAS

You can find the megaclisas-status Debian packages at this URL: Add this on /etc/apt/sources.list: deb jessie maindeb jessie main Make sure to install the PGP signature: wget -O – | apt-key add -wget -O – | apt-key add – Then update apt: apt-get updateapt-get update Now to install megaclisas-status […]