Open-source News

Advanced Copy Command – Shows Progress Bar While Copying/Moving Files in Linux

Tecmint - Wed, 12/21/2022 - 16:31
The post Advanced Copy Command – Shows Progress Bar While Copying/Moving Files in Linux first appeared on Tecmint: Linux Howtos, Tutorials & Guides .

Advanced-Copy is a powerful command line program that is very much similar, but a little modified version of the original cp command and mv tools. This modified version of the cp command adds a

The post Advanced Copy Command – Shows Progress Bar While Copying/Moving Files in Linux first appeared on Tecmint: Linux Howtos, Tutorials & Guides.

How to Copy Files and Directories in Linux [14 cp Command Examples]

Tecmint - Wed, 12/21/2022 - 16:26
The post How to Copy Files and Directories in Linux [14 cp Command Examples] first appeared on Tecmint: Linux Howtos, Tutorials & Guides .

Brief: In this easy-to-follow guide, we will discuss some practical examples of the cp command. After following this guide, users will be able to copy files and directories easily in Linux using the command

The post How to Copy Files and Directories in Linux [14 cp Command Examples] first appeared on Tecmint: Linux Howtos, Tutorials & Guides.

How to migrate your code from PHP 7.4 to 8.1

opensource.com - Wed, 12/21/2022 - 16:00
How to migrate your code from PHP 7.4 to 8.1 gilzow Wed, 12/21/2022 - 03:00

The end-of-life (EOL) for PHP 7.4 was Monday, November 28, 2022. If you’re like me, that date snuck up much faster than anticipated. While your PHP 7.4 code isn’t going to immediately stop working, you do need to begin making plans for the future of this codebase.

What are your options?

You could continue to remain on PHP 7.4, but there are several benefits to updating. The biggest are security risk and support. As we move farther and farther away from the EOL date, attackers will turn their focus to PHP 7.4 knowing that any vulnerabilities they discover will go unpatched in the majority of systems. Staying on PHP 7.4 drastically increases the risk of your site being compromised in the future. In a similar vein, finding support for issues you encounter with PHP 7.4 will become increasingly more difficult. In addition, you will most likely begin to encounter compatibility issues with third-party code/packages as they update their code to be compatible with later versions and drop support for 7.4. You’ll also be missing out on significant speed and performance improvements introduced in 8.0 and further improved in 8.1. But upgrading all that legacy code is daunting!

Where to start?

Luckily, PHP provides an official migration guide from PHP 7.4 to 8.0 to get you started (and an 8.0 to 8.1 migration guide as well). Be sure to read through the Backward Incompatible Changes and Deprecated Features sections. While these guides are incredibly handy, you may very well have tens of thousands of lines of code to check, some of which you may have inherited. Luckily there are some options to help pinpoint potential problem areas in the migration.

PHPCodeSniffer + PHPCompatibility sniffs

PHPCodeSniffer (PCS) is a package for syntax checking of PHP Code. It checks your code against a collection of defined rules (aka “sniffs”) referred to as “standards”. PHPCodeSniffer ships with a collection of standards you can use including PEAR, PSR1, PSR2, PSR12, Squiz, and Zend. Luckily, you can write your own collection of sniffs to define any set of rules you like.

PHPCompability has entered the chat

PHPCompatibility “is a set of sniffs for PHP CodeSniffer that checks for PHP cross-version compatibility” allowing you to test your codebase for compatibility with different versions of PHP, including PHP 8.0 and 8.1. This means you can use PHPCodeSniffer to scan your codebase, applying the rules from PHPCompability to sniff out any incompatibilities with PHP 8.1 that might be present.

Before I continue…

While PHP8.2 was released on December 8, 2022, and I encourage you to begin looking over the official 8.1 to 8.2 migration guide and begin making plans to upgrade, most of the checkers I mention in this article have not completed full support for 8.2 at this time. For those reasons, I’ll be focusing on migrating the code to PHP8.1, and not 8.2.

In the process of writing this article, I discovered PHPCompatiblity has a known issue when checking for compatibility with PHP 8.0/8.1 where it will report issues that should be Errors as Warnings. The only workaround for now is to use the develop branch for PHPCompatibility instead of master. While they state it is stable, please be aware that in this article, I’m using the non-stable branch. You may want to weigh the pros and cons of using the develop branch before implementing it anywhere else than in a local development environment. While I found PCS+PHPCompatibility to be the most straightforward and comprehensive solution for checking for incompatible code, if you do not want to use a non-stable version of PCS, see the section at the end of the article about alternative options.

For the purposes of this article, I’ll be using the 1.4.6 version of SimpleSAMLphp to test for incompatibilities. This is a six-year-old version of the code base. I do this not to pick on SimpleSAMLphp, but because I wanted something that would definitely have some errors. As it turns out, all of the platform.sh code I tested, as well as my own code was already compatible with PHP8.1 and required no changes.

Get started

To get started, first clone your codebase, and then create a new branch. You’ll now need to decide if you want to install the dependencies and run the scans on your local machine or in a local development environment using something like DDEV, Lando, or Docksal. In this demo, I’m using DDEV. I suggest using a local development environment vs running directly on your local machine because while it’s not required to use the version of PHP you want to test against, for the best results, it is recommended you do so. If you don’t have PHP installed, or don’t have the target version installed, a local development environment allows you to create an ephemeral environment with exactly what you need without changing your machine.

After setting up your environment for PHP 8.1, at a terminal prompt (in my case, I’ve run ddev start and once the containers are available, shell into the web app using ddev ssh), you need to add these new packages so you use them to test with. I’ll be adding them with composer, however, there are multiple ways to install them if you would prefer to do so differently. If your codebase isn’t already using composer, you’ll need to do composer init before continuing.

Because you'll be using the develop branch of PHPCompatibility there are a couple of extra steps to do that aren’t in the regular installation instructions. First is that the develop branch of PHPCompatibility requires an alpha version of phpcsstandards/phpcsutils. Because it is marked as alpha, you'll need to let composer know this one package is OK to install even though it is below your minimum stability requirements.

$ composer require --dev phpcsstandards/phpcsutils:"^1.0@dev"

Next, install PHPCompatibility targeting the develop branch

$ composer require --dev phpcompatibility/php-compatibility:dev-develop

The develop branch also installs dealerdirect/phpcodesniffer-composer-installer so you don’t need to add it manually or direct PCS to this new standard.

To verify our new standards are installed, you'll have PCS display the standards it is aware of.

$ phpcs -i The installed coding standards are MySource, PEAR, PSR1, PSR2, PSR12, Squiz, Zend, PHPCompatibility, PHPCS23Utils and PHPCSUtils

Now that you know your standards are available, you can have PCS scan our code. To instruct PCS to use a specific standard, use the --standard option and tell it to use PHPCompatibility. However, you also need to tell PHPCompatibility which PHP version you want to test against. For that, use PCS’ --runtime-set option and pass it the key testVersion and value of 8.1.

Before you start the scan, the one issue remaining is that code you want to scan is in the root of the project (.) but the vendor directly is also in the project root. You don’t want the code in vendor scanned, as those aren’t packages you necessarily control. PCS allows you to tell it to not scan files/directories with the --ignore option. Finally, you want to see the progress as PCS parses the file so you'll pass in the -p option.

Putting it all together:

$ phpcs -p . --standard=PHPCompatibility --runtime-set testVersion 8.1 --ignore=*/vendor/*

This kicks off PCS which will output its progress as it scans through your project’s code. W indicates Warnings, and E indicates Errors. At the end of the scan it will output: a full report with the file containing the issue, the line number where the issue occurs, whether the issue is a Warning or an Error, and the specific issue discovered.

In general, Errors are things that will cause a fatal error in PHP 8.1 and will need to be fixed before you can migrate. Warnings can be things that have been deprecated in 8.0/8.1 but not yet removed or issues that PCS ran into while trying to parse the file.

Given that the report might be long, and is output all at once into your terminal, there are numerous options for changing the information that is included in the report, as well as multiple reporting formats.

As you begin to fix your code, you can rerun the report as many times as needed. However, at some point, you’ll need to test the code on an actual PHP8.1 environment with real data. If you’re using Platform.sh, which is as easy as creating a branch, changing a single line in your configuration file, and pushing that branch to us. You can check out this video to see how easy it is!

There’s too much to fix!

Now that you have a solid idea of what needs to be updated before you can migrate, you might be facing an incredible amount of work ahead of you. Luckily, you have some options to help you out. PCS ships with a code fixer called PHP Code Beautifier and Fixer (phpcbf). Running phpcbf is almost identical to running phpcs and most of the options are identical. The other option is Rector. Usage of these tools is beyond the scope of this article, but as with any automation, you’ll want to test and verify before promoting changes to production.

Programming and development Red Hat Developers Blog Programming cheat sheets Try for free: Red Hat Learning Subscription eBook: An introduction to programming with Bash Bash shell scripting cheat sheet eBook: Modernizing Enterprise Java An open source developer's guide to building applications Alternative options

If for any reason you don’t feel comfortable using a non-stable version of PCS, you do have other options for checking your code.

Phan

Phan is a static code analyzer for PHP. It offers multiple levels of analysis and allows for incrementally strengthening that analysis.

“Static analysis needs to be introduced slowly if you want to avoid your team losing their minds.”

Phan doesn’t target just compatibility with newer versions, it can highlight areas of code that will error in later versions. However, there are some caveats when using Phan for checking compatibility:

  • Slower than PCS+PHPCompatibility.
  • Phan requires the ast php extension which is not available by default on Platform.sh (or in DDEV). You’ll need to install it in your local development environment and add it to your php.ini file. Alternatively, you can use the --allow-polyfill-parser option, but it is considerably slower.
  • Phan’s default reporting output isn’t as easy to read as other options
  • I came across an issue where if your code base sets a different vendor directory via composer’s [config:vendor-dir](https://getcomposer.org/doc/06-config.md#vendor-dir) option, it will error out stating it can’t find certain files in the vendor directory
  • As mentioned, Phan analyzes much more than just PHP8.1 compatibility. While certainly a strength in other situations, if your goal is to migrate from 7.4 to 8.1 as quickly as possible, you will have to parse through errors that are unrelated to version compatibility.
  • Requires you run it on the PHP version you want to target
PHPStan

Similar to Phan, PHPStan is a static code analyzer for PHP that promises to “find bugs without writing tests.” And a similar set of caveats apply:

  • Slower than either PCS or Phan
  • Analyzes much more than just PHP8.1 compatibility so depending on your current codebase, you will have to possibly parse through a bunch of errors that are unrelated to version compatibility
  • Requires you run it on the PHP version you want to target
PHP Parallel Lint

A very fast PHP linter that can lint your codebase for issues, but can also check for deprecations. While it is exceptionally fast, it is only a linter, and therefore can only surface deprecations that are thrown at compile time, not at runtime. In my example code, it only found 2 deprecations vs the 960 deprecations PCS uncovered.

Summary

Code migrations, while never fun, are crucial to minimizing organizational risk. Platform.sh gives you the flexibility to test your code using the same data and configurations as your production site, but in a siloed environment. Combine this with the tools above, and you have everything you need for a strong, efficient code migration.

This article originally published on the Platform.sh community site and has been republished with permission.

With the recent end-of-life for PHP 7.4, it's time to migrate your code. Here are a few options to do that.

Image by:

Opensource.com

Drupal Web development WordPress What to read next This work is licensed under a Creative Commons Attribution-Share Alike 4.0 International License. Register or Login to post a comment.

Open source solutions for EV charging

opensource.com - Wed, 12/21/2022 - 16:00
Open source solutions for EV charging jmpearce Wed, 12/21/2022 - 03:00

Maybe you hate pumping gas in the cold (or heat), or you care about the environment. Maybe the latest gas prices and general inflation has you thinking more about stretching your money. Perhaps you simply think electric vehicles (EVs) look cool. No matter the reason, you're excited about your next vehicle being an EV and you're not alone! The EV market share is set to expand to 30% by 2040. The US government provides a handy comparison tool to show that the cost of ownership of an EV easily beats owning and operating fossil fuel vehicles. Despite this, EV charging costs can still hit you hard in your wallet.

One of the most elegant ways to solve cost problems in general is to apply open source principles to accelerate innovation. Fortunately for you, this has been done in the EV charging area to find a way to get low-cost electricity and low-cost chargers.

To control the costs of EV charging, first you need low-cost electricity. In the old days, that would mean going from oil to coal, which is not a step up. Today, as it turns out, solar photovoltaic (PV) devices that convert sunlight directly into electricity normally provide the lowest-cost electricity. Coal companies are going bankrupt because they can no longer compete with clean solar power. This is also why solar power is seeing explosive growth all over the world. Many homeowners are putting solar panels on their roofs or on ground mounts in the backyard to cover all of their home’s electric needs. But how can you charge your EV with solar energy if you have limited roof area or a small backyard?

Open source PV parking canopy

One approach that major corporations are taking is to make a PV canopy over their parking lots. If you want to do this yourself, a new study provides a full mechanical and economic analysis of three novel open source PV canopy systems:

  1. Use an exclusively wood, single-parking-spot spanning system
  2. Use a wood and aluminum double-parking-spot spanning system
  3. Use a wood and aluminum cantilevered system

The designs are presented as 5-by-6 stall builds, but all three systems are scalable to any amount of parking spots required. This includes a 1-stall 6kW system to charge a single car at home (as shown below). All of the racks are rated for a 25-year expected lifetime to match the standard PV warranty.

Image by:

(Vandewetering, Hayibo, Pearce, CC-BY)

Explore open hardware What is open hardware? What is Raspberry Pi? What is an Arduino? Our latest open hardware articles

The open source PV canopies are all designed to withstand a brutal Canadian winter. They also follow Canada’s strict building codes. So if you live anywhere else, the system as designed should still work for you. The complete designs and bill of materials of the canopies are provided, along with basic instructions. They are released with an open source license that enables anyone to fabricate them following the spirit of the free book about DIY solar power collectors To Catch the Sun.

The results of the previously mentioned study show that open source designs are much less expensive than proprietary products. Single-span systems provide cost savings of 82-85%, double-span systems save 43-50%, and cantilevered systems save 31-40%.

Most importantly, the designs give you more than enough energy (if you have a normal commute) to cover your charging needs. In the first year of operation, PV canopies can provide 157% of the energy needed to charge the least efficient EV currently on the market.

Image by:

(OpenEVSE, CC-BY)

Open source EV chargers

Another way to cut the cost of EV ownership is to install an open source EV charger. OpenEVSE is an Arduino-based charging station composed of open source software and hardware which can be made DIY-style. They are small, lightweight, and portable, so you can use them at home or on the road.

OpenEVSE powers charging stations for many EV manufacturers all over the world. You can adapt it to fit your requirements. OpenEVSE is now quite mature and supports advanced features including adjustable current, temperature monitoring, and a real-time power display. You can buy the hardware pre-assembled and ready to go. If you want to save more money (and have more fun) buy a kit and build it yourself.

Image by:

(OpenEVSE, CC-BY)

I hope to see more designs of EV power solutions in the future. Keep your eyes open, roll up your sleeves for some DIY, and enjoy assembling your open source, solar-powered EV charging solutions!

Harness solar power, hardware, and open source to build your own electric vehicle charging station.

Image by:

Photo by Erik Witsoe on Unsplash

Sustainability Hardware What to read next Comparing solar power to traditional power generation the open way This work is licensed under a Creative Commons Attribution-Share Alike 4.0 International License. Register or Login to post a comment.

5 must-read resources for using the Linux command line

opensource.com - Wed, 12/21/2022 - 16:00
5 must-read resources for using the Linux command line Jim Hall Wed, 12/21/2022 - 03:00

In the beginning, there was the command line. While modern Linux distributions include graphical desktops like GNOME and KDE, the command line remains one of the power features of every Linux system. With the command line, you can leverage a rich set of instructions to edit and manipulate files, control your system, and automate processes.

This year, our contributors wrote a lot of great articles about the Linux command line. Here are five of my favorite topics.

12 essential Linux commands for beginners

Don Watkins writes about this list of twelve essential commands to navigate the Linux command line. If you're new to Linux and want to explore the command line, this is a great list to help you get started.

3 steps to create an awesome UX in a CLI application

Creating a command line program with a great user experience (UX) is a tall order, but Noaa Barki shares three actionable steps to make it work. If you're building your own command line program, Noaa's article will help you to design the commands, design the interface, and provide for backward compatibility.

More Linux resources Linux commands cheat sheet Advanced Linux commands cheat sheet Free online course: RHEL technical overview Linux networking cheat sheet SELinux cheat sheet Linux common commands cheat sheet What are Linux containers? Our latest Linux articles How I configure Vim as my default editor on Linux

Vim is the venerable visual editor for Linux systems. Expanded from the original vi editor, Vim (vi improved) is a powerful and flexible editor. David Both writes about why Vim is a great editor, and how to set other programs to use Vim for editing.

Tips for using the Linux test command

Add extra flexibility to your shell scripts using the test command. Seth Kenlon wrote about easy and common ways to control the flow of your shell scripts by using conditional execution. You can test for files, file types, attributes, numbers, and do other comparisons to make your scripts more flexible.

6 Linux metacharacters I love to use on the command line

Don Watkins shared this list of special command line characters, including * to select a group of files or > to redirect the output of a command. If you're experimenting with the Linux command line, you may want to learn these important metacharacters to expand your command line usage.

Take a look at some or all of these author's links. You are sure to learn something new. If you are rusty with command line concepts these articles will show you the way of the command line.

The Linux command line remains to be one of the system's most powerful and beloved features.

Image by:

Opensource.com

Linux Best of Opensource.com Command line What to read next This work is licensed under a Creative Commons Attribution-Share Alike 4.0 International License. Register or Login to post a comment.

My 4 favorite features of the 4pane file manager on Linux

opensource.com - Wed, 12/21/2022 - 16:00
My 4 favorite features of the 4pane file manager on Linux sethkenlon Wed, 12/21/2022 - 03:00

4Pane is a multi-pane file manager for Linux that allows for customized layout, and provides quick access to traditional desktop conveniences as well as common Linux tools. 4Pane aims for speed over visual effects, and places the way you want to work above all else. In honor of its name, I've got a list of my four favorite features of this fine file manager.

1. Flexible interface Image by:

(Seth Kenlon, CC BY-SA 4.0)

The most prominent feature of the 4Pane window is the same as its name: there are four panes in the window by default. In a way, though, there's actually only two, or said another way, each of the two panes is divided into two columns. The column on the left is a directory tree of your current location (home, by default.) Files are never displayed in the left column. It's only a directory tree.

The adjacent column displays the contents of the selected directory. When you double-click on a file, it opens in its default application. When you double-click on a directory, that directory is revealed in the left column and the right column displays its contents.

This same model is duplicated in the other window pane.

4Pane only has 4 panes by default, but it doesn't enforce that view. If you're overwhelmed by the four-pane view, click on the View menu and select Unsplit panes. This displays just one pane of two columns. It's a simplified view compared to what's possible, but it's a nice place to start while you're getting used to the column-style for browsing files.

Splitting panes

The advantage of a split view is that you don't have to open another window to drag and drop a file or folder from one location to another. This isn't the predominant model for file managers, but it's a popular subset. 4Pane is one of the few, in my experience, that recognizes that it's not always convenient to work laterally. If you prefer to have your second pane at the bottom of the window, go to the View menu and select Split panes horizontally (meaning that the split is horizontal, so the panes are situated vertically to one another).

Image by:

(Seth Kenlon, CC BY-SA 4.0)

2. Tooltip preview

One of my favorite features of 4Pane is the tooltip preview. To activate this, click the photo icon in the top toolbar. With this active, all you have to do is roll your mouse over a file to see a preview of its contents in a tooltip. It may not be a feature you want active all the time. The tooltips can be distracting when you're just browsing files. However, if you're looking for something specific or if you're just not sure exactly what's in a directory, a quick wave of your mouse to get an overview of the contents of several files is satisfyingly efficient.

More Linux resources Linux commands cheat sheet Advanced Linux commands cheat sheet Free online course: RHEL technical overview Linux networking cheat sheet SELinux cheat sheet Linux common commands cheat sheet What are Linux containers? Our latest Linux articles 3. Menu

The menu bar of 4Pane isn't quite like most file manager menu bars you may be accustomed to. There's a menu dedicated to archiving actions, mounting devices, and popular Linux commands such as grep and find.

For instance, in the Archive menu, you can choose to extract an archive or compressed file, create a new archive, add a file to an existing archive, compress a file, and more. I love Ark and similar utilities, but I also recognize how useful it is for a file manager to make those utilities unnecessary. Especially when you're on an old computer, the fewer applications you have to launch, the better.

Also impressive are the built-in front ends for grep and find. I'll admit that I probably won't use it often myself, but I never complain when a developer brings the power of Linux commands to users who aren't [yet] familiar with the terminal.

Image by:

(Seth Kenlon, CC BY-SA 4.0)

The locate front end is probably the most useful of the bunch. It's fast and effective. There's just one field in the dialogue box, so it makes a file system search fast.

For example, say you're searching for the file Zombie-Apocalypse-Plan-B.txt because Plan A fell through, but in the heat of the moment (what with zombies knocking down your door, and all) you can't remember where you saved it. Go to the Tools menu and select locate. Type zombie in the search field, click the -i box so that your system ignores capitalization, and click OK. This returns both Zombie-Apocalypse-Plan-A.txt and Zombie-Apocalypse-Plan-B.txt.

Maybe that's good enough for you, or maybe you need a little more precision. In addition to -i for case insensitivity, you can click the -r option to leverage the power of regex. Type zombie.B. to narrow your search to a file starting with zombie and containing the letter B somewhere in the filename.

Effective and fast.

4. Undo

Finally, my (other) very favorite feature of 4pane is the Undo button. When you right click on a file or folder and select Delete, the item is sent to a secret location (it's not actually secret, but it's out of sight and out of mind). The item isn't scrubbed from the hard drive until you close the 4pane window. Up until then, you can always click the Undo button in the top toolbar to reverse decisions you've come to regret.

This is a separate action from sending a file to your system trash, so it is meant to masquerade as an actual delete action. The difference is that it's a delayed delete. That may not suit you. Some users are disciplined enough to send files to the system trash, but others skip the trash. This feature is designed to protect you from yourself by delaying deletion until you close the window. I find it a reasonable and invaluable feature, and it's the one feature that I've already benefited from several times.

Install 4Pane on Linux

If you're sold on 4Pane, or at least curious about it, then you should install it and try it out! On Linux, your distribution may package 4Pane in its software repository. If so, you can use your package manager to install. For example, on Fedora, Mageia, OpenMandriva, and similar:

$ sudo dnf install 4pane

On Debian and Debian-based systems:

$ sudo apt install 4pane

If your distribution doesn't carry 4Pane, you can download it from 4pane.co.uk.

Once installed, launch 4Pane from your application menu.

4Pane is a multi-pane file manager for Linux that allows for customized layout, and provides quick access to traditional desktop conveniences as well as common Linux tools.

Linux What to read next This work is licensed under a Creative Commons Attribution-Share Alike 4.0 International License. Register or Login to post a comment.

8 Most Popular SSH Clients for Linux

Tecmint - Wed, 12/21/2022 - 13:20
The post 8 Most Popular SSH Clients for Linux first appeared on Tecmint: Linux Howtos, Tutorials & Guides .

Brief: SSH is a popular remote protocol for making secure remote connections. In this guide, we explore some of the most popular SSH clients for Linux. SSH (Secure SHell) ranks as one of the

The post 8 Most Popular SSH Clients for Linux first appeared on Tecmint: Linux Howtos, Tutorials & Guides.

Customer success: Highlights from our public customer stories in 2022

Red Hat News - Wed, 12/21/2022 - 08:00
<p>As this year draws to a close, we stop to reflect on what 2022 has meant to us. For many, it’s been a year that saw people returning to the office and other public venues, mingling with coworkers, family and friends—some of whom we haven’t seen in more than two years. Gatherings are becoming more frequent, restrictions are being lifted and fewer masks are worn in grocery stores and doctor’s offices, among a number of other things.</p> <p><strong><a href="https://www.redhat.com/en/summit">Red H

Fedora 38 Plots Path To Unified Kernel Support

Phoronix - Wed, 12/21/2022 - 02:50
Red Hat and Fedora engineers are plotting a path to supporting Unified Kernel Images (UKI) with Fedora Linux and for the Fedora 38 release in the spring they are aiming to get their initial enablement in place...

Pages