Skip to main content

Posts

How to use Rsync to copy file one after another at a limited bandwidth

Copying files at the same time will ultimately consume all the bandwidth. So, to avoid such issue it would be good to tell Rsync to copy only once the other previous Rsync has finished copying. Copying or transferring files from one system to another location without impacting the bandwith or consuming all available bandwidth, when using Rsync. Using Rsync in Linux to copy files and folders is a common task for Sys Admin. When using Rsync and limiting the upper bandwith or telling Rsync the maximum bandwidth to use can be achieved using the "--limit" option. --limit is in KBps (Kilo Bytes per second and not Kilo bits) --partial is another good option if there is frequent disconnection this will tell Rsync to pick-up or include the files that has been transferred or copied Here's the command on how to use Rsync in Linux to limit the bandwidth when copying: rsync -Pz --limit=30000 <source> <destination> -P = will show the progress -z = tells Rsync to compress fi...

PowerShell check device uptime since last reboot

Checking how long the machine or server is running since last reboot or maintenance is sometimes necessary. To measure the device performance or stability of the server or computer. In Windows, PowerShell is quite handy to to check the uptime of the server. Here's a simple code snippet to do check how long the server has been running since its last reboot. $Last_reboot_time = Get-WmiObject win32_operatingsystem | select csname, @{LABEL='LastBootUpTime';EXPRESSION={$_.ConverttoDateTime($_.lastbootuptime)}} $Today = Get-Date $uptime = NEW-TIMESPAN –Start $Last_reboot_time.LastBootUpTime –End $Today $xdays=$uptime.Days $xhours=$uptime.TotalHours $xhours=[math]::Round($xhours,2) write-output ("Computer is up since last reboot for: $xdays day/s and  $xhours  hours") Sample output of the code below: Computer is up since last reboot for: 1 day/s and  45.98  hours Cheers! Take care. Till next Time. Stay safe! and Keep things up!  Do ASAP,  A lways  S ay  ...

Reset Azure SSH Key because of SSH Key Refused error

SSH Key Refused error, is a common error if the Private key is not accepted by the system in which the other end wants to connect with or communicate. In Microsoft Azure, the VM will through an error in Putty or any application software that will be used to connect or login to the VM on Azure cloud. If the private key is not recognized or accepted by the VM. Luckily, MS Azure provides an option to reset the SSH key and generate a new one. However, when the VM is created a PEM file will be generated and the user must download this file and keep it securely. Using PuttyGen or Putty Generator the PEM can be file can be used to generate a Public Key and a Private Key. To reset SSH or resolve the Server Key Refused error, a Public Key is needed or required by Azure. Screen shot below shows, on how to reset the SSH Public key. First, select the Virtual Machine that the SSH key needs to be resetted or changed. Upon selecting the Virtual Machine, choose or select the "Reset Password"...

WMIC restart wireless network via command line in Windows

How to restart WiFi or Wireless using command line in Windows? If the wireless devices, laptops or computers are connected to a domain such as active directory, or a centralized control. The command below can be created using a batch file and deploy to all controlled devices or computers. The command below, has been tested on a Windows 11 laptop and works fine. If nothing goes wrong, the command executes very fast. Here's the command, must be executed on an elevated command prompt or administrator prompt. wmic service where caption="WLAN AutoConfig" call stopservice && timeout 3 && wmic service where caption="WLAN AutoConfig" call startservice Timeout command is used in between stop and start, as this would give the first command to stop the service and after 3 seconds, another command is executed to start the service. Without the timeout command, the second command might not run  properly, since the first is still executed on the background. Jus...

How to view windows folder in GB or MB or in human readable sizes

With the era of WSL, Windows Subsystem for Linux is quite helpful. You can now run Linux commands on Windows with ease, or without installing any virtualization software. Of course, having VirtualBox installed with Linux is a different story, since you can have a pure Linux environment. Anyway, WSL provides an easy way to view size or capacity of Windows folder without any scripting using PowerShell or installing any Sysinternal tools. How to view folder sizes in human readable format in Windows using WSL? If WSL has been installed and working correctly, open Windows Terminal an awesome command-line shell application, in which you can run multiple Windows in one screen. And you can also position different windows terminal, either horizontally or vertically and Terminals can be resized the way you wan it. Grab windows terminal from Microsoft Store and for the prize of free. Once the Windows Terminal is open, just cd or browse to the directory where you need to check folder sizes. Just p...

How to rip or convert old auido CDs to MP3 or digital format

Old habits are hard to break as they said, however, music of your generation old favorites music of yesteryears will always stay with you. Such music, are hard to forget since the mold your young life or even such songs inspired you to get through difficult times and be who you are today. Or just simply a music of wonderful memories with friends and love ones. Anyway, how to convert or rip CDs to digital format such MP3, WMA,  M4A or any other format that the converter supports. To convert CDs, a CD drive or reader is needed. A built-in CD drive or an external USB-Disk Drive that can read CDs or DVDs. In Windows 11 or Windows 10, these are the steps: Step 1: Insert the Audio CD to the drive Step 2: In the search are beside the windows logo, type: Media and from the search result choose or select the "Media Player". Step 3: In the top left hand side of the Media Player, you will see the Album of the insert CD, it will either show the album name, or if Media Player will not be ...

PowerShell query event log last reboot or shutdown

Querying when was the last time the server  or computer is  essential in troubleshooting or auditing the server. Or in production system, computers or servers, must scheduled a downtime and let stakeholders know that at this specific date and time there will be a down time and services will not ne available at the said time and date. Even in development servers or computers, checking when was the last time the computer restarted or shutdown is quite essential. If the application is buggy,  or has some memory leak or other issues then it will cause the system to reboot, shutdown or crash. PowerShell comes in handy in querying event log; when was the last time the computer has shutdown or rebooted. Of course, event log can be checked manually. But scrolling through the 100 or thousands of event logs is quite tedious. So, PowerShell comes to a rescue  and avoid the tedious, manual finding of the event log. Here's a sample code snippet on how to query Windows event log w...

PowerShell Compare and Get Hash File

 Hash File comparison is a good thing to do, to make sure that file in transit, transferred, downloaded, or copied over is not corrupted or has been altered or modified. PowerShell has a built-in module to do this that makes life easier and an easy task to do. Here's an example code snippet to do this: #Path location of the file $file="C:\Users\User1\Downloads\Win10_22H2_EnglishInternational_x64.iso" # Get the file hash $hashSrc = Get-FileHash $file -Algorithm "SHA256" write-output $hashSrc #copy the Hash file  $Display_hash_only = $hashSrc | Select-Object -Property Hash | ft -HideTableHeaders Write-Output $Display_hash_only Output of the write-output $hashSrc command, will show the Algorithm used, the Hash of the file and path location of the file. Algorithm : SHA256  Hash: AC5522F9DB9F4F432A1AADE69FEF268C8C0B5FD3F22D3A6987719752F8A7108   Path : C:\Users\User1\Downloads\Win10_22H2_EnglishInternational_x64.iso  After getting the Hash File run this code...