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: http://www.unix.com/man-page/Linux/1/cp/

Javascript Get Window Location Hostname

Various example demonstration how to get URL on the address bar using Javascript, which include location.hostname, window.top.location, 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 google.com ip="$(/usr/bin/dig A $1 +short)" echo $1 = $ip#!/bin/bash # Usage: ./script google.com ip="$(/usr/bin/dig A $1 +short)" echo $1 = $ip Example output: root@server:~# ./getip.sh google.com google.com = 172.217.16.78root@server:~# ./getip.sh google.com google.com = 172.217.16.78

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: https://cloud.google.com/storage/docs/gsutil/commands/cp 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: http://hwraid.le-vert.net/wiki/DebianPackages http://hwraid.le-vert.net/debian/pool-jessie/ Add this on /etc/apt/sources.list: deb http://mirror.rackspace.com/hwraid.le-vert.net/debian/ jessie maindeb http://mirror.rackspace.com/hwraid.le-vert.net/debian/ jessie main Make sure to install the PGP signature: wget -O – https://hwraid.le-vert.net/debian/hwraid.le-vert.net.gpg.key | apt-key add -wget -O – https://hwraid.le-vert.net/debian/hwraid.le-vert.net.gpg.key | apt-key add – Then update apt: apt-get updateapt-get update Now to install megaclisas-status […]