How to Install Chocolatey on Windows

Reading Time: 4 minutes


What is Chocolatey?

Chocolatey or Choco as it is sometimes referred to, is a free, open-source package manager for Windows that is very similar to Apt or DNF in the Linux realm. In other words, this is a program used for installing software via the Windows command line. It downloads a program, installs it, then it will check for updates, and installs those updates automatically if needed. Those who use Linux are quite familiar with the package management systems like this.

Some ask, “Why should we choose to use a program like this, since we can simply download the .exe or .msi software and install the program ourselves?

That is an excellent question. Here are several solid answers.

  • When we install a new operating system and want to use numerous programs, we must look for each program installer, download it, install it, and then regularly check for updates. The Chocolatey package manager this all by itself, when using automatic mode.
  • Instead of searching for an executable installer, we can install the program using the Chocolatey package manager and complete everything using the command line. It is much more convenient and faster.
  • We can conveniently and more comfortably control the application versions we need. Most often, when we go to download an executable for the application, it downloads the latest version for us, and we do not always need the latest version.
  • Chocolatey provides clear, simple commands which are almost identically used in all package management systems.

Prerequisites

  • Windows 7 or later / Windows Server 2003 or later
  • PowerShell v2 or later
  • .NET Framework 4 or later

(As an aside, the installation will attempt to install .NET 4.0 if you do not have it already installed.)

Installation

Let’s move on to the installation. There are two options for installing Chocolatey. We can install Chocolatey via the command line or through PowerShell. The option to use cmd is most often used for Windows, and PowerShell for running scripts. In this case, we can run both cmd and PowerShell, but as an administrator, for this installation.

Note:
Please inspect the Chocolatey installation script before running it to ensure safety. Chocolatey already knows it’s scripts are safe, but by default, you should verify the security and contents of any script you are not familiar with, before downloading and running it from the internet. This installation downloads a remote PowerShell script and execute it on your machine. We take security very seriously.

Install Using Powershell

When installing the software via PowerShell, we must ensure the local
Get-ExecutionPolicy
is not set to restricted. Chocolatey suggests using
Bypass
to bypass the policy to get things installed or
AllSigned
for increased security.

First, we need to run.
Get-ExecutionPolicy
If it returns
Restricted

Then we need to run
Set-ExecutionPolicy AllSigned
or
Set-ExecutionPolicy Bypass -Scope Process.

Now run the following command in the Windows shell.
Set-ExecutionPolicy Bypass -Scope Process -Force; [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))

If there are no errors, Chocolatey will be installed. We can verify the installation using one of the following commands.
choco
or
choco -?

Install Using Windows Cmd Shell

First, we need ensure that we are using an administrative shell.
Next, copy the following command to our cmd.exe shell.

@"%SystemRoot%\System32\WindowsPowerShell\v1.0\powershell.exe" -NoProfile -InputFormat None -ExecutionPolicy Bypass -Command " [System.Net.ServicePointManager]::SecurityProtocol = 3072; iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))" && SET "PATH=%PATH%;%ALLUSERSPROFILE%\chocolatey\bin"

And then press enter. 

The installation should look something like this.

Microsoft Windows [Version 10.0.18363.900]
(c) 2019 Microsoft Corporation. All rights reserved.
C:\WINDOWS\system32>@"%SystemRoot%\System32\WindowsPowerShell\v1.0\powershell.exe" -NoProfile -InputFormat None -ExecutionPolicy Bypass -Command " [System.Net.ServicePointManager]::SecurityProtocol = 3072; iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))" && SET "PATH=%PATH%;%ALLUSERSPROFILE%\chocolatey\bin"
Getting latest version of the Chocolatey package for download.
Getting Chocolatey from https://chocolatey.org/api/v2/package/chocolatey/0.10.15.
Extracting C:\Users\user\AppData\Local\Temp\chocolatey\chocInstall\chocolatey.zip to C:\Users\user\AppData\Local\Temp\chocolatey\chocInstall...
Installing chocolatey on this machine
Creating ChocolateyInstall as an environment variable (targeting 'Machine')
Setting ChocolateyInstall to 'C:\ProgramData\chocolatey'
WARNING: It's very likely you will need to close and reopen your shell
before you can use choco.
Restricting write permissions to Administrators
We are setting up the Chocolatey package repository.
The packages themselves go to 'C:\ProgramData\chocolatey\lib'
(i.e. C:\ProgramData\chocolatey\lib\yourPackageName).
A shim file for the command line goes to 'C:\ProgramData\chocolatey\bin'
and points to an executable in 'C:\ProgramData\chocolatey\lib\yourPackageName'.
Creating Chocolatey folders if they do not already exist.
WARNING: You can safely ignore errors related to missing log files when
upgrading from a version of Chocolatey less than 0.9.9.
'Batch file could not be found' is also safe to ignore.
'The system cannot find the file specified' - also safe.
WARNING: Not setting tab completion: Profile file does not exist at
'C:\Users\user\Documents\WindowsPowerShell\Microsoft.PowerShell_profile.ps1'.
Chocolatey (choco.exe) is now ready.
You can call choco from anywhere, command line or powershell by typing choco.
Run choco /? for a list of functions.
You may need to shut down and restart powershell and/or consoles
first prior to using choco.
Ensuring chocolatey commands are on the path
Ensuring chocolatey.nupkg is in the lib folder
C:\WINDOWS\system32>

Verify Installation

To verify that Chocolatey is installed, we will use the choco command.

C:\WINDOWS\system32>choco
Chocolatey v0.10.15
Please run 'choco -?' or 'choco -?' for help menu.

C:\WINDOWS\system32>

Excellent! Chocolatey is installed!

Basic Chocolatey Commands

Now let’s review some of the basic commands for using Choco. Choco commands can be used in both the Windows cmd shell and in PowerShell.

Install Program

To install a specific program, use the following command.
choco install <pkg|packages.config> [ ] []</pkg|packages.config>

For example:
choco install chrome

For a complete listing of install options, visit the Choco install page or run the following command.
choco install -h

Update Program

To update a program, we will use the following command.
choco upgrade <pkg|all> [ ] []</pkg|all>
For example:
сhoco upgrade chrome

Update All Programs

To update all programs, we need to use the following command.
cup <pkg|all> [ ] []</pkg|all>
or
choco upgrade all

If you noticed, the cup command is an alternative to using the choco upgrade command.

Search For a Program

To find a needed program for downloading and installation, we can enter the following command.
choco search chrome

See Installed Programs

Using the following command, you can see which programs are already installed using Choco.
choco list --local-only
Chocolatey v0.10.15
chocolatey 0.10.15
chocolatey-core.extension 1.3.3
kubernetes-cli 1.18.2
Minikube 1.10.1
vscodium 1.38.0
5 packages installed.

C:\WINDOWS\system32>

Update Chocolatey

We can update the Choco program itself using this command.
choco upgrade chocolatey

It is important to do this periodically because in previous versions, errors may be detected, and they need to be fixed so that there are no vulnerabilities.

Install the Chocolatey GUI

If someone is not comfortable using the command line, we can install the graphical user interface of Chocolatey using this command.
choco install chocolateygui

Conclusion

That’s it! As you can see, using Chocolatey is very simple. Overall, we have found that Chocolatey is an excellent tool in our local systems administration toolbox. It is reliable, definitive, and consistently updated. Overall, it is an exceptional product.

Docker For Beginners

Reading Time: 16 minutes

What is Docker?

31920.docker

Docker is a containerization software that is used for automating the deployment and management of applications within an isolated environment. This software allows us to “pack” and ship an application, along with all of its needed files, libraries, and dependencies, into a “docker container“. That container can then be easily ported to any Linux system that contain cgroups support within the kernel, and provides a container management environment. Docker is one of several containerization implementations (not to be confused with virtualization) based on this cgroups mechanisms built into the Linux kernel.

Continue reading “Docker For Beginners”

How to Install Yarn on Windows

Reading Time: 5 minutes

What is Yarn?

Yarn is an alternative npm-client used for working with JavaScript as a package manager that was developed by the Facebook team. It also allows us to share code with other developers around the world and use solutions from other developers. The code itself is distributed via packages, sometimes referred to as modules. The package contains a .package.json file which describes the contents, as well as all the associated distributed code. In comparison with npm, Yarn is considered to be a better alternative and surpasses NPM in the following parameters:

Continue reading “How to Install Yarn on Windows”

How to Install OBS on Linux, Windows and MacOS

Reading Time: 5 minutes

What is OBS?

obs_icon_small

OBS (Open Broadcaster Software) is a free and open-source video recording and livestreaming software program that is written in C, C ++, and Qt and developed by the OBS project and a community of independent developers. It is mainly used for streaming and recording videos. It supports a wide range of plugins to extend the functionality of the program.

Continue reading “How to Install OBS on Linux, Windows and MacOS”

JS frameworks: React, Angular, or Vue?

Reading Time: 5 minutes

Introduction

In this tutorial, we will discuss three of the most popular javascript frameworks: React, Angular, and Vue. We will look at the pros and cons of each, their usage statistics, discussions about which one to choose, and which one should be studied for future use. Because programming languages and frameworks are all tools in a developers tool belt, and each has its place. It is worth learning tools you find meaningful, useful to accomplish a task that’s not only convenient, but is suitable for specific tasks. Again, we should remind ourselves that because these changes occur rapidly, after a year and a half a year, the situation can radically change.

Continue reading “JS frameworks: React, Angular, or Vue?”

How to Install Jitsi Meet on Ubuntu 18

Reading Time: 9 minutes

What is Jitsi?

Jitsi is a set of open-source projects that allow you to create a secure video conferencing system for your team. It has features such as superior sound quality, excellent encryption and privacy, multi-platform and much more. The Jitsi client can work both in the application and in the web browser. You can broadcast your desktop as well as individual windows, and invite users using URL-link. We will be installing Jitsi on Ubuntu 18.04 server. We will install additional components such as Java’s OpenJdk, Nginx to correctly install, configure and use it. Let’s talk a bit about the components.

Continue reading “How to Install Jitsi Meet on Ubuntu 18”

How to Set Up and Manage Sudo Permissions

Reading Time: 7 minutes

What Is Sudo?

sudo-sudoers

credit to: XKCD

Sudo is a Linux program meant to allow a user to use root privileges for a limited timeframe to users and log root activity.  The basic thought is to give as few privileges as possible to a user while allowing  the user to accomplish a task. The term “Sudo” means substitute user, and do. It is a program used for managing of user permission based on a system configuration file. It allows users to run programs with the privileges of another user, by default, the superuser. The program is supplied for most UNIX and Linux-based operating systems.

Continue reading “How to Set Up and Manage Sudo Permissions”

How to Install Java on Ubuntu, Windows, and MacOS

Reading Time: 6 minutes

What is Java?

Java is considered one of the most popular programming languages. Java is a typed object-oriented programming language developed by Sun Microsystems (and subsequently acquired by Oracle). Development is mainly performed by a community organized through the Java Community Process. The language and the main technologies that implements it are distributed under the GPL but the trademark rights are owned by Oracle Corporation. Code written in Java (using the JVM – Java Virtual Machine) is transformed into bytecode and due to this, programs can run on any system where the JVM is installed. Therefore, Java is often called a cross-platform language. Most often, Java is used to develop backend programs and android applications.

Continue reading “How to Install Java on Ubuntu, Windows, and MacOS”

How To Install PyCharm on CentOS 7 and 8

Reading Time: 3 minutes

What is PyCharm?

PyCharm is an IDE (or Integrated Development Environment) for the Python programming language. It is a cross-platform development environment that is compatible with Windows, macOS, and Linux. It provides a tool that integrates code analysis, graphical debugging, unit testing, and also contains an integrated terminal that supports development on remote hosts and virtual machines.

Continue reading “How To Install PyCharm on CentOS 7 and 8”

How to Install and Configure Samba on Ubuntu 18

Reading Time: 9 minutes

What is Samba?

Samba is an open-source software package that is released under a GPL (General Public License). It allows us to access a shared network drive and printers across various operating systems using the SMB/CIFS protocol. Samba has both client and server components. Samba uses the SMB protocol, which is necessary when accessing assets on a file server from a Microsoft computer. Samba can also work as a domain controller that is compatible with Microsoft Active Directory. 

Continue reading “How to Install and Configure Samba on Ubuntu 18”