Thursday, May 7, 2020

Removing Files Whose Names Start with "-"

I wanted to remove files whose names begin with "-" on a Linux system. After some searches, I found out that the following method worked.

rm -- -foo
where the file name is -foo.

Sunday, April 26, 2020

Failed to Update EclEmma Tool for Eclipse

I have the following Eclipse installed,

Eclipse IDE for Enterprise Java Developers.

Version: 2020-03 (4.15.0)
Build id: 20200313-1211

When I attempt to update Eclipse, I encountered the following error,

An error occurred while collecting items to be installed
session context was:(profile=C__Applications_eclipse_latest_eclipse, phase=org.eclipse.equinox.internal.p2.engine.phases.Collect, operand=, action=).
No repository found containing: osgi.bundle,org.eclipse.eclemma.core,3.1.3.202003132300
No repository found containing: osgi.bundle,org.eclipse.eclemma.doc,3.1.3.202003132300
No repository found containing: osgi.bundle,org.eclipse.eclemma.ui,3.1.3.202003132300
No repository found containing: org.eclipse.update.feature,org.eclipse.eclemma.feature,3.1.3.202003132300

The solution to this problems is to update it via EclEmma's update channel at http://update.eclemma.org/. We can use the two methods to realize this solution,
  1. Update EclEmma via adding an Eclipse repository for EclEmma
    1. Click the "Help" menu
    2. Select the "Install New Software" submenu
    3. Click "Add" button to add a new repository
    4. In the popup windows, enter a name of the repository, e.g., EclEmma, and enter the URL, http://update.eclemma.org/
    5. Confirm it by clicking at the "Add" button on the popup window
  2. Update EclEmma via Eclipse Marketplace
    1. Click the "Help" menu
    2. Select the "Eclipse Marketplace" submenu
    3. Search "EclEmma" in the "Eclipse Marketplace"
    4. Eclipse should now show "EclEmma for Java Code Coverage" as "installed"
    5. Click at "installed", and then click at "update".

Friday, March 13, 2020

Setting up New Ethernet Interfaces on Debian Linux

I am running Debian Linux on Oracle VirtualBox virtual machines. The Linux system has only the command line interface, and has no GUI installed.  Below are the steps to add Ethernet interfaces to the Linux virtual machine and to get IP addresses via DHCP.
  1. Shut down  the Linux virtual machine
  2. Add and enable Ethernet interfaces to the virtual machine
  3. Boot the Linux virtual machine
  4. On the Linux virtual machine, view the Internet addresses
    
    ip address show
    
  5. Assume that we added two Ethernet adapters and the output of the command above shows that they are enp0s8 and enp0s9, we add the following lines to /etc/network/interfaces,
    
    allow-hotplug enp0s8
    iface enp0s8 inet dhcp
    
    allow-hotplug enp0s9
    iface enp0s9 inet dhcp
     
  6. Restart the networking service by running the following as root (or via sudo)
    
    systemctl restart networking
     
  7. Complete IP setting including assigning IP addresses via DHCP by running the following as root (or via sudo)
    
    dhclient
    

Monday, February 3, 2020

Changing IPMI User Password

I was wondering how I would reset or change IPMI user password. The solution is actually simple, i.e., to use ipmitool.

Here is an example. I have a FreeNAS system running a server with a ASROCK Rack IPMI, and would do the following to change a IPMI user's password,

  1. Query IPMI users ID
    
    sudo ipmitool  user list 1
    

    where "1" is the channel number. The outputs resembles the following,
    
    
    ID  Name             Callin  Link Auth  IPMI Msg   Channel Priv Limit
    1                    false   false      true       ADMINISTRATOR
    2   admin            false   false      true       ADMINISTRATOR
    3                    true    false      false      NO ACCESS
    4                    true    false      false      NO ACCESS
    5                    true    false      false      NO ACCESS
    6                    true    false      false      NO ACCESS
    7                    true    false      false      NO ACCESS
    8                    true    false      false      NO ACCESS
    9                    true    false      false      NO ACCESS
    10                   true    false      false      NO ACCESS
    

    where the admin user's ID is 2.

  2. Change IPMI user password. The following is to change the "admin" user's password to admin123.
    
    sudo ipmitool  user set password 2 admin123
    

    where "2" is the ID of the admin user. 

We can also do the above on a Linux system. Note that these are for the host's IPMI.

Friday, December 27, 2019

Is the Password to the Private Key Correct?

When we generate a public-private key pair for public key cryptography, such as, RSA, we can use a password to control access to the private key. We would know if it is the case by viewing the content of the key file, e.g.,

$ sudo head -1 myprivatekey.key
-----BEGIN ENCRYPTED PRIVATE KEY-----

The problem is that I don't know which password is correct because I have a few. If we are using openssh, we can easily verify if a password is correct by using ssh-keygen with the -y option -- the manual states,

-y      This option will read a private OpenSSH format file and print an
        OpenSSH public key to stdout.

Knowing this, we verify whether a password is correct or not by
ssh-keygen -y -f ./myprivatekey.key; echo "exit code is " $?
Enter passphrase: xxxxxxxx
Load key "./myprivatekey.key": incorrect passphrase supplied to decrypt private key
exit code is  255

which shows that the password I entered was incorrect. However, we entered a correct one, we would observe,

ssh-keygen -y -f ./myprivatekey.key; echo "exit code is " $?
Enter passphrase: yyyyyyyy
exit code is  0

Thursday, December 5, 2019

On a Debian-based Linux Distribution, Which Package Has a Given File?

We often wonder which package we should install to use a command. On Debian-based distributions, we can use apt-file to locate file that in packages that we have or haven't installed, and use dlocate to locate a file in packages that have been installed.

For example, to determine which package the ip command is in, we can run the following.

First, make sure we have installed apt-file

sudo apt-get install apt-file

Second, make sure we have packages indexed and up-to-date, be it installed or not.

sudo apt-file update

We can now determine which package has the ip command,


apt-file search ip

The result may be too long to be useful. To shorten the result, we apply heuristics. We know that the ip is a command, and it is probably in a bin directory, the name of the file should be ip,

apt-file search ip | grep "bin" | grep "/ip$"

Now the output is

iproute2: /bin/ip
iproute2: /sbin/ip

If we know that we have had the iproute2 installed, we can use dlocate as follows.
First, we make sure that we have installed dlocate.

sudo apt-get install dlocate

Next, we run dlocate with some heuristics as in,

dlocate ip | grep "bin" | grep "/ip$"

The output is,

iproute2: /bin/ip
iproute2: /sbin/ip

Wednesday, November 13, 2019

When SFC Cannot Fix Corrupted Windows Files, DSIM Comes to Rescue

Just as the title suggested, on a Windows 10 host, I encountered a case that SFC reported that it could not fix corrupted files, and DSIM in this case helped. Below is the screen transcript.

C:\WINDOWS\system32>sfc /scannow

Beginning system scan.  This process will take some time.

Beginning verification phase of system scan.
Verification 100% complete.

Windows Resource Protection found corrupt files but was unable to fix some of them.
For online repairs, details are included in the CBS log file located at
windir\Logs\CBS\CBS.log. For example C:\Windows\Logs\CBS\CBS.log. For offline
repairs, details are included in the log file provided by the /OFFLOGFILE flag.

C:\WINDOWS\system32>Dism /Online /Cleanup-Image /RestoreHealth

Deployment Image Servicing and Management tool
Version: 10.0.17763.771

Image Version: 10.0.17763.805

[==========================100.0%==========================] The restore operation completed successfully.
The operation completed successfully.

C:\WINDOWS\system32>sfc /scannow

Beginning system scan.  This process will take some time.

Beginning verification phase of system scan.
Verification 100% complete.

Windows Resource Protection found corrupt files and successfully repaired them.
For online repairs, details are included in the CBS log file located at
windir\Logs\CBS\CBS.log. For example C:\Windows\Logs\CBS\CBS.log. For offline
repairs, details are included in the log file provided by the /OFFLOGFILE flag.

C:\WINDOWS\system32>sfc /scannow

Beginning system scan.  This process will take some time.

Beginning verification phase of system scan.
Verification 100% complete.

Windows Resource Protection did not find any integrity violations.

C:\WINDOWS\system32>