Tuesday, December 14, 2021

Remove Apps From MS Windows 10

Microsoft is push-installing many more applications in Windows 10. A user may remove some applications by clicking the Start button then right-click on an app and choose uninstall. The uninstall option is not available for many apps installed by Microsoft.

This list of MS Windows 10 PowerShell application removal lines can work on some versions of Windows, and may depend on the current naming and the build number of Windows. The following were tested on several versions of Windows 10, including Microsoft Windows 10 Pro version 10.0.19043 N/A Build 19043.

Right-click on the Start button and choose: Windows PowerShell

If you are not able to run PowerShell as administrator in order to remove the application packages for all users, you will receive an error:
Get-AppxPackage : Access is denied.
Access is denied.


You may instead run the following commands without this option: -Allusers
If the following commands are not working with "-Allusers", try do remove that and run the command again.


If you are looking for application package names to install, try this example for the Solitaire game:
> Get-AppxPackage | select-string  "solitaire"

Microsoft.MicrosoftSolitaireCollection_4.4.8204.0_x64__8wekyb3d8bbwe

Then use "solitaire" and remove the game:
Get-AppxPackage *solitaire* | Remove-AppxPackage



List of what you may want to remove. If you are not logged in as administrator, remove "-AllUsers" from the following:

Get-AppxPackage Microsoft.YourPhone -AllUsers | Remove-AppxPackage
# or
Get-AppxPackage *windowsphone* -AllUsers | Remove-AppxPackage


Get-AppxPackage *xbox* -AllUsers | Remove-AppxPackage


Get-AppxPackage *3dbuilder* -AllUsers | Remove-AppxPackage

Get-AppxPackage Microsoft.Microsoft3DViewer -AllUsers | Remove-AppxPackage


Get-AppxPackage *people* -AllUsers | Remove-AppxPackage
# or
Get-AppxPackage Microsoft.Windows.PeopleExperienceHost -AllUsers | Remove-AppxPackage
# or
Get-AppxPackage Microsoft.people -AllUsers | Remove-AppxPackage


# Cortana
Get-AppxPackage Microsoft.549981C3F5F10 -AllUsers | Remove-AppxPackage

Get-AppxPackage *Microsoft.GetHelp* -AllUsers | Remove-AppxPackage

Get-AppxPackage *windowsalarms* -AllUsers | Remove-AppxPackage

Get-AppxPackage *windowscommunicationsapps* -AllUsers | Remove-AppxPackage

Get-AppxPackage *skypeapp* -AllUsers | Remove-AppxPackage

Get-AppxPackage *officehub* -AllUsers | Remove-AppxPackage

Get-AppxPackage *getstarted* -AllUsers | Remove-AppxPackage

Get-AppxPackage *onenote* -AllUsers | Remove-AppxPackage

Get-AppxPackage *bingweather* -AllUsers | Remove-AppxPackage

Get-AppxPackage *windowscamera* -AllUsers | Remove-AppxPackage

Get-AppxPackage *windowsmaps* -AllUsers | Remove-AppxPackage

Get-AppxPackage Microsoft.WindowsFeedbackHub -AllUsers Remove-AppxPackage

Get-AppxPackage *music* -AllUsers Remove-AppxPackage

Get-AppxPackage *solitaire* -AllUsers | Remove-AppxPackage

Get-AppxPackage *portal* -AllUsers | Remove-AppxPackage

Get-AppxPackage *stickynotes* -AllUsers | Remove-AppxPackage

# Movies & TV

Get-AppxPackage *zunevideo* -AllUsers | Remove-AppxPackage

# Snip & Sketch
Get-AppxPackage *screensketch* -AllUsers | Remove-AppxPackage

# Sound Recorder
Get-AppxPackage *soundrecorder* -AllUsers | Remove-AppxPackage


Microsoft OneDrive may be removed from within the legacy "Control Panel" application. Press Start button, then begin typing "control panel".


After you have uninstalled applications, it is usually useful to create a Windows "restore point" to snapshot the current configuration. If you feel more advanced, you may want to explore the "Services" app to stop services you may not be using.

Monday, October 18, 2021

Disable Windows 10 Search Advertising

This post covers two topics which are similar though separate - File Explorer search box suggestions; and Start Button search advertising.

 

In Windows 10, the File Explorer shows suggestion pop-ups when you begin to type in the File Explorer search box. While tolerable, it becomes annoying if you frequently search. If you prefer for the File Explorer search box to return search results after you are done typing, the search pop-up functionality may be disabled.


If you have a Windows 10 version with group policy editor, press the Start Button and type: gpedit Run the Edit Group Policy application as administrator. In the group policy editor, go to User Configuration, Administrative Templates, Windows Components, File Explorer.
 



Edit the entry for "Turn off display of recent search entries in the File Explorer search box". Choose "Disabled" and press OK button.


The setting should now be Disabled.


 



A separate issue with Windows 10 is invasive keystroke monitoring and advertising. Press the Start Button and begin to type a program name or file name. Windows 10 will show matching program names, file names, and also provide search engine results. This is like a mini search engine in the Start Button based on your typing and geo-location. If you type "burgers", not only will it search for local programs and files named "burgers", but you will also get a review of where to locally purchase burgers and a map for local burger shops. Microsoft calls this feature Web search.  Many people call it "intrusive and annoying". There does not appear to be an intuitive and easy way to turn off this advertising.

 
This feature can be turned off with the registry editor. Press the Start Button and type: regedit
Run the Registry Editor application as administrator. The registry key will include Computer\HKEY_CURRENT_USER\SOFTWARE\Policies\Microsoft\Windows. (While it may appear the key Computer\HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows\Explorer can configure this for all users, it doesn't seem to work.)
Confirm this registry key exists, or add it: Computer\HKEY_CURRENT_USER\SOFTWARE\Policies\Microsoft\Windows\Explorer

Right-click on the "Explorer" key, and add a new DWORD 32-bit value with name: DisableSearchSuggestions


Set the value to 1.


Reboot the computer and test that the Start Button advertising functionality has been disabled.

Saturday, October 16, 2021

How to mine Monero on Ubuntu Linux

Please refer to the recent post about setting up a Monero pool miner on Microsoft Windows. That post provides some background information along with how to use wallet software.


Now let's focus on running a miner on Linux Ubuntu 20.04. We will use the same public key address as the previous post. We will simply change the identifier in the start file to allow both the Windows and Linux miners to be monitored on the same page at SupportXMR.com. 

Logon to the machine and determine which Ubuntu release is installed.

$ lsb_release -a

No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 20.04.3 LTS
Release:        20.04
Codename:       focal


# Create a new unix group and user.

$ sudo addgroup cryp

Adding group `cryp' (GID 1004) ...
Done.

$ grep cryp /etc/group
cryp:x:1004:

$ sudo adduser monero --ingroup cryp
Adding user `monero' ...
Adding new user `monero' (1005) with group `cryp' ...
Creating home directory `/home/monero' ...
Copying files from `/etc/skel' ...
New password:
Retype new password:
passwd: password updated successfully
Changing the user information for monero
Enter the new value, or press ENTER for the default
        Full Name []:
        Room Number []:
        Work Phone []:
        Home Phone []:
        Other []:
Is the information correct? [Y/n] y

# If you want the new monero Linux user to be able to log on to the machine remotely, add user monero to the "AllowUsers" line in /etc/ssh/sshd_config.
$ sudo vi /etc/ssh/sshd_config

# Now edit the config file and add the monero username.
$ grep monero /etc/ssh/sshd_config
AllowUsers install1 minec monero

# Restart ssh to apply the new configuration.
$ sudo systemctl restart ssh

# ssh into the machine as the monero user.
$ whoami
monero

$ groups
cryp

$ id
uid=1005(monero) gid=1004(cryp) groups=1004(cryp)


# Earlier we ran "lsb_release -a" it showed the name "focal" for the Ubuntu release. Get the monero software, with the matching Ubuntu release name, from https://github.com/xmrig/xmrig/releases.

$ wget https://github.com/xmrig/xmrig/releases/download/v6.15.2/xmrig-6.15.2-focal-x64.tar.gz 

$ gzip -d xmrig-6.15.2-focal-x64.tar.gz

$ tar -xvf xmrig-6.15.2-focal-x64.tar
xmrig-6.15.2/
xmrig-6.15.2/config.json
xmrig-6.15.2/SHA256SUMS
xmrig-6.15.2/xmrig

$ ls -l
total 8256
drwxr-x--- 2 monero cryp    4096 Oct  5 10:38 xmrig-6.15.2
-rw-r----- 1 monero cryp 8448000 Oct  5 11:30 xmrig-6.15.2-focal-x64.tar


# Go into the software directory and create a new (or replace the example) config.json.
$ cd xmrig-6.15.2
$ ls -l
total 8256
-rw-r----- 1 monero cryp    2351 Oct  5 10:38 config.json
-rw-r----- 1 monero cryp     150 Oct  5 10:38 SHA256SUMS
-rwxr-x--- 1 monero cryp 8441704 Oct  5 10:38 xmrig

# Put the following into file config.json. Note the "user" public key is on one line.
$ cat config.json
{
"autosave": true,
"cpu": true,
"opencl": false,
"cuda": false,
"pools": [
        {
                "url": "pool.supportxmr.com:443",
                "user": "44YkNzrdJnmAqwoTRMPV2e4fihv3AfZ5vMmrtaWCGQaxKuXp5eiZeRREzhPi9tVqGuA3VBRriNwKa2QxmZmRGmHVTkUSTMc",
                "pass": "runDemoB",
                "keepalive": true,
                "tls": true
        }
        ]
}


# Test it from the command line. Stop the program with ctrl-c after you verify it is working.
$ ./xmrig -c ./config.json




# Create and test a command file which will be used by the Linux process monitor so the miner will be started upon machine reboot.
$ cd ~
$ pwd
/home/monero

# Put these three lines into the command file named startminer.sh. Note the last command is all one line.
$ vi startminer.sh
#!/bin/sh
umask 026
/usr/bin/nice -n 15 /home/monero/xmrig-6.15.2/xmrig -c /home/monero/xmrig-6.15.2/config.json

# Make the file executable.
$ chmod +x startminer.sh

# Test the command file from the command line.
$ ./startminer.sh

# In another terminal window, run "top" and look at the "NI" column. It should be the "nice" value in the command file. This sets the process priority lower, so the machine can more easily prioritize other work (if there is other work).


# Configure the system services so the mining process will automatically start with the machine.
# For the following commands with sudo, log in with a unix account which is in the sudoers file.
$ cd /etc/systemd/system
$ sudo vi monero.service
[Unit]
Description=monero miner
After=network.target
[Service]
Type=simple
User=monero
Group=cryp
ExecStart=/home/monero/startminer.sh
KillMode=mixed
Restart=on-failure
Type=forking
TimeoutStartSec=120
TimeoutStopSec=30
RuntimeMaxSec=infinity
[Install]
WantedBy=multi-user.target

# Enable the service.
$ sudo systemctl enable monero.service
Created symlink /etc/systemd/system/multi-user.target.wants/monero.service → /etc/systemd/system/monero.service.

$ sudo systemctl start monero.service
$ sudo systemctl status monero.service

# Run top or htop to confirm the miner is running with the specified "nice" level.
# Reboot the machine to test the miner will restart automatically.
$ sudo shutdown -r

# After machine restarts, login and run the following to verify the service is running and that it is only running one.
$ top
$ htop
$ ps -fu monero

Let's look into the mining process a little closer, and focus on the number of tasks or processes that are run. From a defensive system administration standpoint, we may want to configure the service so it can not errantly consume thousands of processes.

With the miner running as a service, it is currently using just a handful of processes. This seems to be correct, as one process per CPU core (in this case 4 cores) is reasonable.

$ ps -fu monero
UID          PID    PPID  C STIME TTY          TIME CMD
monero      1046       1  0 15:02 ?        00:00:00 /lib/systemd/systemd --user
monero      1047    1046  0 15:02 ?        00:00:00 (sd-pam)
monero      1145    1043  0 15:02 ?        00:00:00 sshd: monero@pts/0
monero      1146    1145  0 15:02 pts/0    00:00:00 -bash
monero      1471       1  0 15:10 ?        00:00:00 /bin/sh /home/monero/startminer.sh
monero      1472    1471 99 15:10 ?        00:05:38 /home/monero/xmrig-6.15.2/xmrig -c /home/monero/xmrig-6.15.2/c
monero      1517    1146  0 15:12 pts/0    00:00:00 ps -fu monero

$ ps -fu monero | wc -l
9


# In another terminal window with a Linux user which has access to sudo.
$ sudo systemctl status monero.service
● monero.service - monero miner
     Loaded: loaded (/etc/systemd/system/monero.service; enabled; vendor preset: enabled)
     Active: activating (start) since Sun 2021-10-10 15:12:24 MDT; 1min 57s ago
Cntrl PID: 1531 (startminer.sh)
      Tasks: 10 (limit: 18964)
     Memory: 2.2G
     CGroup: /system.slice/monero.service
             ├─1531 /bin/sh /home/monero/startminer.sh
             └─1532 /home/monero/xmrig-6.15.2/xmrig -c /home/monero/xmrig-6.15.2/config.json
Oct 10 15:12:38 d990 startminer.sh[1532]: [2021-10-10 15:12:38.338]  net      new job from pool.>
Oct 10 15:12:38 d990 startminer.sh[1532]: [2021-10-10 15:12:38.338]  cpu      use argon2 impleme>
Oct 10 15:12:38 d990 startminer.sh[1532]: [2021-10-10 15:12:38.341]  msr      msr kernel module >
Oct 10 15:12:38 d990 startminer.sh[1532]: [2021-10-10 15:12:38.341]  msr      FAILED TO APPLY MS>
Oct 10 15:12:38 d990 startminer.sh[1532]: [2021-10-10 15:12:38.342]  randomx  init dataset algo >
Oct 10 15:12:38 d990 startminer.sh[1532]: [2021-10-10 15:12:38.342]  randomx  allocated 2336 MB >
Oct 10 15:12:45 d990 startminer.sh[1532]: [2021-10-10 15:12:45.958]  randomx  dataset ready (761>
Oct 10 15:12:45 d990 startminer.sh[1532]: [2021-10-10 15:12:45.958]  cpu      use profile  rx  (>
Oct 10 15:12:45 d990 startminer.sh[1532]: [2021-10-10 15:12:45.960]  cpu      READY threads 3/3 >
Oct 10 15:13:46 d990 startminer.sh[1532]: [2021-10-10 15:13:46.126]  miner    speed 10s/60s/15m >

$ systemctl show --property DefaultTasksMax
DefaultTasksMax=18964

# Note the service is using 10 tasks of the 18964 limit. It appears it uses the default maximum setting.
# Note the service is using 2.2 GB of memory.
# Since the service is running correctly and the machine has four CPU cores, let's ensure the service does not run away. Limit it to no more than 999 processes.

# Add two lines to the end of /etc/systemd/system/monero.service.
[Service]
TasksMax=999

# Reload the systemd configuration.
$ sudo systemctl daemon-reload

# Restart the mining process.
$ sudo systemctl restart monero.service

# Look at the Tasks limit for this mining process. It should use 999 from the monero.service file.
$ systemctl status monero.service | grep Tasks
      Tasks: 10 (limit: 999)

# Restart the machine to test the configuration.
$ sudo shutdown -r


Go to the SupportXMR.com website to monitor the mining activity. Enter the address from the config file at this website to see your miner activity.

Using top and htop, you may notice with four CPU cores that it seems only three are being used. The load average will be in the 3s rather than 4 (the number of cores). For this example on this four-core CPU, you may edit config.json and add the fourth core to the "rx" line, like this: "rx": [0, 1, 2, 3],

# Then restart the service.
$ sudo systemctl restart monero.service

# If you make this change to use more CPU, closely monitor if more hashes are being calculated. You may find that while more CPU is used, less hashes are performed due to CPU cache issues. Please read this tuning document and consider de-tuning to the prior setup. In short, hyper-threading (more logical processors than cores) usually does not scale CPU-bound processes.



To tune the OS settings, look into huge pages. First, get the current settings and monitor the current miner hash rate so you know the baseline before making tuning changes.

Without tuning, the OS may be configured like this:

$ grep -i huge /proc/meminfo
AnonHugePages:         0 kB
ShmemHugePages:        0 kB
FileHugePages:         0 kB
HugePages_Total:       0
HugePages_Free:        0
HugePages_Rsvd:        0
HugePages_Surp:        0
Hugepagesize:       2048 kB
Hugetlb:               0 kB

Stop the miner process, make temporary changes to OS kernel settings, and restart the miner to determine if the hash rate changes.

$ sudo sysctl -w vm.nr_hugepages=1280
$ grep -i huge /proc/meminfo
AnonHugePages:         0 kB
ShmemHugePages:        0 kB
FileHugePages:         0 kB
HugePages_Total:    1280
HugePages_Free:     1280
HugePages_Rsvd:        0
HugePages_Surp:        0
Hugepagesize:       2048 kB
Hugetlb:         2621440 kB

If the restarted miner process shows an increase in hashing, then make the kernel OS settings permanent.

$ sudo bash -c "echo vm.nr_hugepages=1280 >> /etc/sysctl.conf"

Reboot the machine and check the huge pages setting and the miner hash rate. For this example, the per second hash rate went from 965 to 1381 just by tuning huge pages.