Showing posts from August, 2020

Digital Marketing

The jshell tool allows you to execute Java code, getting immediate results.

|  You can enter a Java definition (variable, method, class, etc), like:  int x = 8 |  or a Java expression, like:  x + x |  or a Java statement or import. |  These little chunks of Java code are called 'snippets'. | |  There are also the jshell tool commands that allow you to understand and |  control what you are doing, like:  /list | |  For a list of commands: /help jshell> /help |  Type a Java language expression, statement, or declaration. |  Or type one of the following commands: |  /list [<name or id>|-all|-start] |       list the source you have typed |  /edit <name or id> |       edit a source entry |  /drop <name or id> |       delete a source entry |  /save [-all|-history|-start] <file> |       Save snippet source to a file |  /open <file> |       open a file as source input |  /vars [<name or id>|-all|-start] |       list the declared variables and their values |  /methods [<name or id>|-all|-start] |       list the decla

Reset the password in Ubuntu for Windows WSL

In Windows admin command prompt ( Super + X ,  A ) change the default user to root: ubuntu config --default-user root Use  passwd  command in Bash to change the user password (the user whose password you want to reset): passwd your_username Change the default user back to your normal user in Windows command prompt ubuntu config --default-user your_username

Chrome Notification settings


Run SSH server on more than one ports

Edit sshd configuration file with your favourite text editor. $ sudo vi /etc/ssh/sshd_config Search for Port option and set the value to the ports that you desire. Port 22 Port 2222 Restart sshd $sudo systemctl restart sshd

Check PowerShell Version

PS C:\WINDOWS\system32> $PSVersionTable.PSVersion Major  Minor  Build  Revision -----  -----  -----  -------- 5      1      19041  1

Check OpenSSH version

ssh -V OpenSSH_for_Windows_7.7p1, LibreSSL 2.6.5

Install Windows 10’s SSH Client

The SSH client is a part of Windows 10, but it’s an “optional feature” that isn’t installed by default. To install it, head to Settings > Apps and click “Manage optional features” under Apps & features. Click “Add a feature” at the top of the list of installed features. If you already have the SSH client installed, it will appear in the list here. Scroll down, click the “OpenSSH Client” option, and click “Install”.

Install dig by dnf/yum

[root@ca34c0badae5 /]# dnf -y install dig Last metadata expiration check: 0:02:15 ago on Thu Aug 27 20:03:15 2020. No match for argument: dig Error: Unable to find a match: dig [root@ca34c0badae5 /]# dnf whatprovides '*bin/dig' Last metadata expiration check: 0:07:18 ago on Thu Aug 27 20:03:15 2020. bind-utils-32:9.11.17-1.fc32.x86_64 : Utilities for querying DNS name servers Repo        : fedora Matched from: Other       : *bin/dig bind-utils-32:9.11.22-1.fc32.x86_64 : Utilities for querying DNS name servers Repo        : updates Matched from: Other       : *bin/dig [root@ca34c0badae5 /]# dnf -y install bind-utils

Java new line

Use the %n conversion — the \n escape is not platform independent.

Java Byte streams should only be used for the most primitive I/O.

Java Suppressed Exceptions

An Java exception can be thrown from the block of code associated with the try-with-resources statement. If an exception is thrown from the try block and one or more exceptions are thrown from the try-with-resources statement, then those exceptions thrown from the try-with-resources statement are suppressed, and the exception thrown by the block is the one that is thrown by the mothod. Retrieve Java suppressed exceptions by calling the Throwable.getSuppressed method from the exception thrown by the try block.

Zoom tmux pane

Ctrl + b (prefix) + z works to zoom into a particular pane in tmux.  If you press Ctrl + b + z again, it zooms pane back to original size.

Remove a repository on Ubuntu

To delete a software repository from Ubuntu and its derivatives, just open the /etc/apt/sources.list file and look for the repository entry and delete it. 

Get public IP address of current instance

curl curl

Identifying the EBS device on EC2

Amazon Linux creates a symbolic link from the device name in the block device mapping  For example, /dev/sdf, to the NVMe device name. $ ll /dev/sdf lrwxrwxrwx 1 root root 7 May 18 21:08 /dev/sdf -> nvme1n1 With Amazon Linux AMI 2017.09.01 or later (including Amazon Linux 2), you can run the ebsnvme-id command as follows to map the NVMe device name to a volume ID and device name: [ec2-user ~]$ sudo /sbin/ebsnvme-id /dev/nvme1n1 Volume ID: vol-01324f611e2463981 /dev/sdf

Ansible: install Apache

  tasks:   - name: ensure apache is at the latest version     yum: name=httpd state=latest   tasks:     - name: install apache2       apt: name=apache2 update_cache=yes state=latest

Ansible local command example

$ ansible --connection=local -m command -a "/bin/echo hello world" localhost localhost | CHANGED | rc=0 >> hello world