Pages

Tuesday, March 9, 2021

Test WinRm connection to Windows Env

To check if WinRM (Windows Remote Management) is enabled in a Windows Server, you can use the following commands:

Test-NetConnection -ComputerName XX -Port 5986

This command tests the connection to port 5986, which is the default port used by WinRM over HTTPS.

Test-NetConnection -ComputerName XX -Port 5985

This command tests the connection to port 5985, which is the default port used by WinRM over HTTP.

If the above commands return successful results, it means that WinRM is enabled and running on the specified server.

Additionally, you can also use the following command to check if WinRM is configured properly on a remote server:

Test-WSMan -ComputerName XX

This command tests the Windows Remote Management (WinRM) service on a remote server and returns the current configuration status of WinRM.

Sed Command in MAC

The sed command is used to manipulate and edit text in Unix-based operating systems like macOS.

Method to use Sed in Mac

sudo sed -i "/kube/d" /etc/hosts

give error sed: 1: "/etc/hosts": extra characters at the end of h command


In the first command you provided, sudo sed -i "/kube/d" /etc/hosts, the -i option tells sed to edit the file in place, and /kube/d is the command that tells sed to delete any lines containing the string "kube" in the /etc/hosts file. However, this command does not work on macOS as it requires the -i option to have a backup file extension specified. The error message "sed: 1: "/etc/hosts": extra characters at the end of h command" is indicating that the command is not properly formatted for macOS.

To fix this, you can use the following command: sudo sed -i '' '/kube/d' /etc/hosts. The empty quotes after -i specify that no backup file should be created, and the '' is necessary for macOS to recognize the command properly. The /kube/d command remains the same and tells sed to delete any lines containing the string "kube" in the /etc/hosts file.

Following Syntax Worked. 
sudo sed -i '' '/kube/d' /etc/hosts


Sunday, August 16, 2020

Converting Text Case in Linux: Exploring Powerful Command-Line Tools

In the realm of command-line utilities, Linux offers a plethora of versatile tools that empower users to perform a wide range of tasks efficiently. One such task involves converting the case of text within a file. Whether you're looking to transform text to lowercase or uppercase, Linux provides multiple command-line options to achieve this. In this article, we'll delve into the process of converting text case using four prominent tools: dd, awk, perl, and sed.


Converting Text to Lowercase

Using dd

The dd command, renowned for its data manipulation capabilities, can also be employed to convert text to lowercase.

$ dd if=input.txt of=output.txt conv=lcase

Leveraging awk

awk, a versatile text processing tool, offers a succinct way to convert text to lowercase.

$ awk '{ print tolower($0) }' input.txt > output.txt

The Magic of perl

Perl enthusiasts can harness the power of this scripting language to achieve case conversion.
$ perl -pe '$_= lc($_)' input.txt > output.txt

Transforming with sed

For those who appreciate the elegance of sed, this command can seamlessly convert text to lowercase.

$ sed -e 's/\(.*\)/\L\1/' input.txt > output.txt

Converting Text to Uppercase

dd for Uppercase Conversion

Using dd to convert text to uppercase is equally achievable.

$ dd if=input.txt of=output.txt conv=ucase

awk for Uppercase Transformation

awk enthusiasts can employ its capabilities for converting text to uppercase.

$ awk '{ print toupper($0) }' input.txt > output.txt

Uppercase Conversion with perl

Perl's power shines again in transforming text to uppercase.

$ perl -pe '$_= uc($_)' input.txt > output.txt

sed for Uppercase Conversion

Converting text to uppercase using sed is both efficient and effective.

$ sed -e 's/\(.*\)/\U\1/' input.txt > output.txt