Skip to main content

Posts

Find duplicate or unique values in a column using Excel formula

Recent posts

AWS view instance store volume - ephemeral storage

Instance store volume in AWS is not like the EBS Volume (ebs - elastic block storage). The main difference between EBS and instance store volume, is EBS data or its contents will persist after reboot or shutdown. And for EBS volume you can take snapshot, create image do a backup or simply attached the EBS volume to another instance. Where as for instance store volume, which is physically attached to the host. It can't be search or can't be found on the "Volume" navigation pane. Thus, snapshot or taking backup is not possible. Instance store volume is some sort of a RAMDisk, in which it is indeed process data quite fast. However, if the instance is rebooted or shutdown all data is gone. Ideal only for dynamic data processing, that once data is process on the fly; data can be discarded or not needed anymore. How to view or check whether the instance you have got instance store volume? In a Linux instance, type the command below on a Terminal window: lsblk -o +...

Convert column data as single row with comma - excel

Converting column values to a single row separated by commas, is needed by some applications to iterate thru the values. Some automation tools, require such format. Example image below, shows A1 to A35 a list of Server Name. 35 rows is just an example or a demonstration it can easily become hundred of rows or more depending on the actual servers or data in the environment. To convert the rows to a single row separated by a comma, can easily be done using Excel. Excel 2019 and above is needed for the TEXTJOIN formula. Example image below, shows how to convert the Column values to a single row with comma as a delimiter. Formula is: =TEXTJOIN(",", TRUE, A1:A35) "," means separate the data with a comma "TRUE" means don't include empty spaces A1:A35 the range of values that will be converted to a single row with comma as a delimiter Image below shows the output after the formula process the data. Once you have the data as desired...

Reading uncommented line in Linux and Windows

Reading uncommented line is almost a daily live for most Linux and Windows Sys Admin. Uncommented in .conf or .ini lines are the active or the lines that are currently in used for the loaded configuration. In Linux, it's quite straight forward to do it using grep. grep ^[^#] service_file.conf The above command uses regex, to search for lines in the .conf file that doesn't start with #. In regex ^ means the first character, but if it is inside the brackets it has other meaning. It negates whatever character that follows. So, the regex means search the first character that doesn't start with #. Technically, it's teling grep to search for uncommented lines. Yes, the above solution is for Linux. How can we do it in Windows? Well, it turns out to be almost the same but with a little twist of course since its a different operating system. So, here's how we can do it in Windows. findstr /b /v ^# file.txt Hopefully, it makes life easier and the above commands...

Windows CLI grant Full access to a folder

icacls is a command line utility tool that allows system admin to grant or deny access permissions to a folder or path. Example below grants the user "TheAdminUser1" to the Desktop path specified below. icacls C:\Users\admin\Desktop /grant TheAdminUser1:F To check whether the permissions has been applied or not. cd to the path, like C:\Users\admin\Desktop, then type: icacls . . >> means the current path Once everything is ok a similar output like the image below will be shown, and there should be an "F" access list which means Full Access Permissions. If the output shows "successfully processed 1 files" and failed processes shows "0" files then permission has been applied without any issues. For more complex scenarios, and if the system has PowerShell cmdlets installed like Get-Acl and Set-Acl might offer more flexibility. Cast all your anxieties on him, for he cares about you. - 1 Peter 5:7 Don't let your heart b...

Python example to use zip built-in function

Python code below use zip built-in function to display the list and display the sequence. The code below just display the list, but using subprocess or fabric module it can be expanded to connect or do remote tasks on the specified servers. Here's an example code on how to use zip built-in function. def main_func(): xservers = ["WebServer", "MailServer", "MonitoringServer", "KibanaServer", "DatabaseServer", "TestServer", "NetboxServer"] xips = ["192.168.25.1", "192.168.25.2", "192.168.25.3", "192.168.25.4", "192.168.25.5", "192.168.25.6", "192.168.25.7"] for indexx, itemx in enumerate(zip(xservers, xips), start=1): print(indexx, itemx[0], "=", itemx[1], " ==> VM with platform services") if __name__ == "__main__": main_func() itemx[0] ===> refers to xservers itemx[1...

Python example using multiprocessing module

With the era of multi-core CPU, parallel, concurrency or multiprocessing is quite possible now. Below is an example of a Python code that shows how to use multiprocessing module to run multiple commands. import multiprocessing import subprocess # Shell command/s Function def multi_run_command(command): try: result = subprocess.run(command, shell=True, capture_output=True, text=True) return f"Command: {command}\nOutput:\n{result.stdout}" except Exception as e: return f"Command: {command}\nError: {e}" if __name__ == "__main__": # List of dig commands to run / Replace the commands as desired commands = ["dig @1.1.1.1 google.com", "dig @8.8.4.4 yahoo.com", "dig @9.9.9.9 bing.com"] # Create and specify limit of pool worker processes with multiprocessing.Pool(processes=3) as pool: #limit to 3 cores or workers results = pool.map(multi_run_command, commands) #use the m...

Python Fabric module run local commands

Fabric is a Python library that simplifies the use of SSH for system administration tasks by running remote commands on remote system. It can be used as well to run local commands on the system. Example code below shows on how to use Fabric module to execute local commands. Below is an example on how to use Fabric. from fabric import Connection # Create a connection to the localhost connx = Connection('localhost') # Run local commands def run_local_commands(): print(f"Executing on {connx.host} as {connx.user}") # Command 1: Get the system name result_uname = connx.local("uname -s", hide=True) print("Output of 'uname':") print(result_uname.stdout) # Command 2: Get memory on the system result_mem = connx.local("free -h", hide=True) print("Output of 'system memory':") print(result_mem.stdout) # Command 3: Display ip route result_ipr = connx.local("ip r", ...