Bash jq command | Linux Hint

JSON data are used for various purposes. But JSON data can’t be read easily from JSON file by using bash script like other normal files.

jq

tool is used to solve this problem.

jq

command works like

sed

and

awk

command, and it uses a domain specific language for working with JSON data.

jq

is not a built-in command. So, you have to install this command for using it. How you can install and apply

jq

command for reading or manipulating JSON data is shown in this tutorial.

Run the following command to install jq on Ubuntu.

$ sudo apt-get install jq

Reading JSON data

Suppose, you have declared a JSON variable named JsonData in the terminal and run jq command with that variable to print the content of that variable.

$ JsonData='[{“Book”:”PHP 7″}, {“Publication”:”Apress”},
{“Book”:”React 16 Essentials”},{“Publication”:”Packt”} ]’
$ echo “$” | jq ‘.’

Reading JSON data with –c option

-c option uses with jq command to print each JSON object in each line. After running the following command, each object of JsonData variable will be printed.

$ echo “$” | jq -c ‘.[]’

Reading a JSON file

jq command can be used for reading JSON file also. Create a JSON file named Students.json with the following content to test the next commands of this tutorial.

Students.json

[

{“roll”: 3,

“name”

:

“Micheal”,
“batch”

:

29,
“department”

:

“CSE”

},{“roll”: 55,

“name”

:

“Lisa”,
“batch”

:

34,
“department”

:

“BBA”

},{“roll”: 12,

“name”

:

“John”,
“batch”

:

22,
“department”

:

“English”

}]

Run the following command to read Students.json file.

Reading JSON file with ‘|’

You can use ‘|’ symbol in the following way to read any JSON file.

$ cat Students.json | jq ‘.’

Reading single key values

You can easily read any particular object from a JSON file by using jq command. In Students.json, there are four objects. These are roll, name, batch, and department. If you want to read the value of department key only from each record then run jq command in the following way.

$ jq ‘.[] | .department’ Students.json

Reading multiple keys

If you want to read two or more object values from JSON data then mention the object names by separating comma (,) in the jq command. The following command will retrieve the values of name and department keys.

$ jq ‘.[] | .name, .department’ Students.json

Remove key from JSON data

jq command is used not only for reading JSON data but also to display data by removing the particular key. The following command will print all key values of Students.json file by excluding batch key. map and del function are used in jq command to do the task.

$ jq ‘map(del(.batch))’ Students.json

Mapping Values

Without deleting the key from JSON data, you can use map function with jq command for various purposes. Numeric values of JSON data can be increased or decreased by map function. Create a JSON file named Number.json with the following content to test the next commands.

Run the following command to add 10 with each object value of Numbers,json.

$ jq ‘map(.+10)’ Numbers.json

Run the following command to subtract 10 from each object value of Numbers,json.

$ jq ‘map(.-10)’ Numbers.json

Searching values by index and length

You can read objects from JSON file by specifying the particular index and length. Create a JSON file named colors.json with the following data.

[“Red”,”Green”,”Blue”,”Yellow”,”Purple”]

Run the following command to read two values starting from the third index of colors.json file.

$ jq ‘.[2:4]’ colors.json

You can specify the length or starting index to read data from JSON file. In the following example, the number of data value is given only. In this case, the command will read four data from the first index of colors.json.

You can specify the starting point only without any length value in jq command and the value can be positive or negative. If the starting point is positive then the index will count from the left side of the list and starting from zero. If the starting point is negative then the index will count from the right side of the list and starting from one. In the following example, the starting point is -3. So, the last three values from the data will display.

$ jq ‘.[-3:]’ colors.json

When you will work with JSON data and want to parse or manipulate data according to your requirements then jq command will help you to make your task easier.

Source

How to Install MariaDB on Ubuntu 16.04

How to install MariaDB on Ubuntu 16.04

How to install MariaDB on Ubuntu 16.04

installing mariadb on ubuntu 16.04MariaDB is a community-developed fork of MySQL. It is a free and open source, very fast, stable and scalable database server, which makes it one of the most used database servers in the world. It is an improved, drop-in replacement for popular MySQL Database Server. In this tutorial, we will show you how to install MariaDB on Ubuntu 16.04. Installing MariaDB on Ubuntu 16.04 is an easy task, and if you carefully follow the steps of this tutorial, you should have it installed on your system in less than 10 minutes. Let’s get started.

1. Connect to your server

First, you will need to login to your server via SSH as user root:

ssh root@IP_ADDRESS -p PORT_NUMBER

and replace “IP_ADDRESS” and “PORT_NUMBER” with your actual server IP address and SSH port number.

2. Update your system

Before we start, let’s make sure your system is up-to-date by running the following commands:

apt-get update
apt-get upgrade

3. Install MariaDB on Ubuntu 16.04

Before we start with the MariaDB Server installation, you will need to add the official MariaDB repository.

First, install the software-properties-common package to your server with the following command:

apt-get install software-properties-common

Next, import the MariaDB GnuPG signing key to your system, by executing the following command:

apt-key adv –recv-keys –keyserver hkp://keyserver.ubuntu.com:80 0xF1656F24C74CD1D8

And finally, add the MariaDB repository with:

add-apt-repository ‘deb [arch=amd64,arm64,i386,ppc64el] http://mirror.nodesdirect.com/mariadb/repo/10.3/ubuntu xenial main’

To be able to initiate the MariaDB installation from the newly added repository, you will now need to update the package list with:

apt-get update

You can now install MariaDB on your server with:

apt-get install mariadb-server

Once the installation is complete, the MariaDB service will be started automatically. To verify if the service is running on your system, you can run the following command:

systemctl status mariadb

You should see the following output on your screen:

● mariadb.service – MariaDB 10.3.10 database server
Loaded: loaded (/lib/systemd/system/mariadb.service; enabled; vendor preset: enabled)
Drop-In: /etc/systemd/system/mariadb.service.d
└─migrated-from-my.cnf-settings.conf
Active: active (running) since Sat 2018-10-27 13:37:11 CDT; 1h 3min ago
Docs: man:mysqld(8)
https://mariadb.com/kb/en/library/systemd/
Main PID: 15152 (mysqld)
Status: “Taking your SQL requests now…”
CGroup: /system.slice/mariadb.service
└─15152 /usr/sbin/mysqld

And to check the MariaDB version you can type:

mysql -V
mysql Ver 15.1 Distrib 10.3.10-MariaDB, for debian-linux-gnu (x86_64) using readline 5.2

4. Securing your MariaDB installation

After the installation is complete, you can improve the security of your MariaDB server, by running the mysql_secure_installation script, using the following command:

mysql_secure_installation

You will be asked to enter your current password for the MariaDB root user. If you did not set any password during the installation, you can just leave it blank and press Enter:

In order to log into MariaDB to secure it, we’ll need the current
password for the root user. If you’ve just installed MariaDB, and
you haven’t set the root password yet, the password will be blank,
so you should just press enter here.

Enter current password for root (enter for none):

You can then choose to change your root password or leave it as it is.

Setting the root password ensures that nobody can log into the MariaDB
root user without the proper authorisation.

You already have a root password set, so you can safely answer ‘n’.

Change the root password? [Y/n]

After this, you will get asked a couple of more questions and it is recommended that you answer ‘yes’ to all of them:

Remove anonymous users? [Y/n]

Disallow root login remotely? [Y/n]

Remove test database and access to it? [Y/n]

Reload privilege tables now? [Y/n]

Once you complete all the steps, the following output will be displayed on your screen:

All done! If you’ve completed all of the above steps, your MariaDB
installation should now be secure.

Thanks for using MariaDB!

5. Connect to MariaDB

Now after you are done with installing and securing MariaDB, you can type the following command to connect to your MariaDB server:

mysql -u root -p

You will be asked for your MariaDB root password that has been set during the installation or during the mysql_secure_installation script.

This will grant you access to the MariaDB shell:

Welcome to the MariaDB monitor. Commands end with ; or g.
Your MariaDB connection id is 21
Server version: 10.3.10-MariaDB-1:10.3.10+maria~xenial-log mariadb.org binary distribution

Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.

Type ‘help;’ or ‘h’ for help. Type ‘c’ to clear the current input statement.

MariaDB [(none)]>

install mariadb on ubuntu 16.04Of course, you don’t have to install MariaDB on Ubuntu 16.04, if you use one of our MariaDB Hosting services, in which case you can simply ask our expert Linux admins to install and configure MariaDB for you. They are available 24×7 and will take care of your request immediately.

PS. If you liked this post on how to install MariaDB on Ubuntu 16.04, please share it with your friends on the social networks using the buttons below or simply leave a reply. Thanks.

Source

Linux Today – FFmpeg 4.1 “al-Khwarizmi” Open-Source Multimedia Framework Officially Released

Nov 09, 2018, 15:00

Dubbed “al-Khwarizmi”, the FFMpeg 4.1 release comes six months after the April 2018 debut of the FFmpeg 4.0 “Wu” series. It’s a major update that adds lots of new filters, decoders and encoders of all kinds, as well as some exciting new features and enhancements to make FFmpeg the best free multimedia backend on the market. Highlights of the FFmpeg 4.1 “al-Khwarizmi” release include support for the highly efficient AV1 codec in the MP4 container, an AV1 parser for parsing AV1 encoded streams, Transport Layer Security (TLS)-based mbedTLS support, a SER demuxer, as well as a libtensorflow backend for DNN-based filters like srcnn.

Complete Story

Source

Apple’s new bootloader won’t let you install GNU/Linux

Locking bootloaders with trusted computing is an important step towards protecting users from some of the most devastating malware attacks: by allowing the user to verify their computing environment, trusted computing can prevent compromises to operating systems and other low-level parts of their computer’s operating environment.

But as with every security measure, there’s a difference between “secure for the user” and “secure against the user.” Bootloader protection that doesn’t allow an owner to decide which signatures they trust is security against the user: security that prevents the user from overriding the manufacturer, and so allows the manufacturer to lock the user in.

Apple’s latest bootloader protection, the controversial T2 chip, is a good example of this. The chip comes with a user-inaccessible root of trust that allows for the installation of Apple and Microsoft operating systems, but not GNU/Linux and other open and free alternatives.

There’s no reason it has to be this way: Google’s flagship Pixel Chromebooks come with hardware switches that can be activated during the bootup to allow their owners to change which signatures the system trusts (users can initialize these systems with passwords that prevent others from covertly altering the trusted root later). This gives users the best of both worlds: a system that, by default, protects them from malware, and, with should the user choose, allows them to nominate parties other than Google to decide whom they trust.

To make things worse, publishing tools to allow for bootloader overrides is legally risky under section 1201 of the DMCA, which provides for 5 year prison sentences and $500,000 fines (for a first offense) for anyone who trafficks in tools to override access controls for copyrighted works.

Apple’s T2 documentation makes it clear and explicitly mentions Linux:

NOTE: There is currently no trust provided for the the Microsoft Corporation UEFI CA 2011, which would allow verification of code signed by Microsoft partners. This UEFI CA is commonly used to verify the authenticity of bootloaders for other operating systems such as Linux variants.

In other words, until Apple decides to add this certificate or the T2 chip otherwise is cracked so it could be fully disabled or allowed to load arbitrary keys, good luck even being able to boot Linux distributions on the new Apple hardware.

Gorgeous, illustrated Japanese fireworks catalogs from the early 1900s

The Yokohama Board of Education has posted scans of six fantastic catalogs from Hirayama Fireworks and Yokoi Fireworks, dating from the early 1900s. The illustrated catalogs are superb, with minimal words: just beautiful colored drawings depicting the burst-pattern from each rocket.

READ THE REST

Evolutionary Space Invaders: shoot the aliens as a genetic algorithm modifies them

InvaderZ is a Space Invaders variant that incorporates a genetic algorithm that mutates the invaders as you shoot at them, with survival for a fitness function: the longer an invader lasts before being blasted out of the sky, the more its behaviors are carried over into the next wave (here’s a playable live version). (via […]

READ THE REST

Analyst: Apple’s poor earnings will recover now they’ve switched from innovating to rent-seeking

Apple just had a really poor Q3 earnings report, with hardware sales falling off as people figure out that they just don’t need to get a new phone every year or so; writing in Bloomberg, Leonid Bershidsky tries to soothe investors by pointing out that Apple is still seeing growth in “services” and that there’s […]

READ THE REST

Write with a pen, save your notes online with this futuristic notebook

Note-taking just caught up to the digital age. For most of us, writing freehand is quicker and more convenient than pecking away on a tablet, but what to do when you need those scribbles on file? Grab a Rocketbook Everlast Reusable Notebook, which seamlessly fuses analog and digital notes. Just jot down your thoughts, journals […]

READ THE REST

Easily create professional-grade 2D animation from any image

Remember the cartoons of your youth? There’s a good reason. Nothing sparks the imagination like well-done animation. And whether you need a logo in motion or just want to bring your own imagination to life, CrazyTalk Animator 3 Pro is the tool that can take you there. Easy enough for casual users but with all […]

READ THE REST

Subscribe to Scribd for unlimited access to books, articles and more

For readers, Scribd has long been a fount of content, and it’s only growing. With 40 million titles to choose from, this service has plenty to offer to its more than 750,000 subscribers. Whether you’re into audiobooks, novels, nonfiction or magazines, Scribd is the only subscription service with access to titles from all “Big 5” global […]

READ THE REST

Source

The Performance Impact Of Spectre Mitigation On POWER9

Over the past year we have looked extensively at the performance impact of Spectre mitigations on x86_64 CPUs but now with having the Raptor Talos II in our labs, here are some benchmarks to see the performance impact of IBM’s varying levels of Spectre mitigation for POWER9.

 

 

By default, Raptor Computing Systems ships their system in the safest mode of providing full kernel and user-space protection against Spectre Variant Two. But by editing a file from the OpenBMC environment it’s possible to control the Spectre protections on their libre hardware. Besides the full/user protection against Spectre there is also kernel-only protection that is more akin to the protection found on x86_64 CPUs. Additionally, there is the ability to completely disable the protection for yielding the greatest performance (or what would be considered standard pre-2018) but leaving your hardware vulnerable to Spectre. More details on controlling the Spectre protections on Talos II hardware can be found via the RaptorCS.com Wiki.

This weekend are some benchmarks for reference of the Talos II Secure Workstation with dual 22-core POWER9 CPUs when tested in the default mode of kernel/user protection, kernel protection only, and then no protection at all for seeing how the performance compares — just as we have done many times over the past year for Intel and AMD CPUs too.

These reference benchmarks were done via the Phoronix Test Suite. If you want to see how your own Linux system(s) compare to the performance of this fully open-source system with libre firmware in its various Spectre configurations, simply run phoronix-test-suite benchmark 1811098-SK-TALOSIIDU15.

Source

Sourcegraph: An Open-Source Source Code Search Engine

Last updated November 11, 2018

In a recent announcement, a Code Search and Navigation tool named Sourcegraph was declared Open Source. As it makes navigating through Source Code much more convenient, the tool itself going Open Source is definitely a big plus for developers!

We’ve looked into its features and also tried to find out how it can be so helpful for developers who are used to navigate through code hosts like GitHub, GitLab and others quite regularly.

Sourcegraph Features

As stated on their GitHub page, Sourcegraph has the following features:

  • Fast global Code search
  • Intelligent Code recognition
  • Code host Enhancement on GitHub, GitLab and more
  • Extension API for easier third-party integration

You can deploy Sourcegraph on your server and configure it to work with your or your organization’s Git repositories. Once that’s done, you get a search engine where you can search all the codes.

But if you are a lone developer, like me, you can still use Sourcegraph on GitHub or GitHub alternatives like GitLab.

I am going to quickly show you how to use Sourcegraph for a better code navigation on GitHub.

Using Sourcegraph on GitHub

Let’s find out how you can easily try this tool with a Firefox or Chrome extension. Here, we’ve used Firefox:

Sourcegraph Firefox add-on

This is how it looks like with the Sourcegraph extension installed and when you view a file on the Vim repository on GitHub:

Sourcegraph source code engine

Sourcegraph extension on GitHub

Note how we can see the new Sourcegraph buttons within the GitHub interface, thanks to the installed extension. One thing to note is that one need not even login into GitHub to navigate through hosted Code and their repositories in order to make use of the helpful features of Sourcegraph.

When you click on “View File”, the entire look changes and the file is opened for you in a completely new interface within the browser itself:

Sourcegraph extension on GitHub

Without Sourcegraph, if you want to look for files with a particular format, say C++ .cpp files in this example, it is very difficult to filter and view them if we try to use GitHub’s own search engine within this repository:

Sourcegraph extension on GitHub

But once you are using this extension, see how easily you can view all such files in one go within the repository:

Sourcegraph extension on GitHub

Sourcegraph extension on GitHub

Sourcegraph can narrow down through Code Search very intelligently as explained in this video:

Code intelligence in Sourcegraph is powered by Lang Server, which enables identifying the type of Programming Language you are using:

Language support Sourcegraph

Learn more about its usefulness in the following video:

Bonus Tip on using Sourcegraph

Even without installing an extension on your browser, you can directly use Sourcegraph as an IDE on top of any repository on GitHub by just adding “sourcegraph.com/” as a prefix to the repository URL.

For example, the URL for the official Vim repository is:

github.com/vim/vim

To view the same through Sourcegraph, modify the URL as below and you’re good to go:

sourcegraph.com/github.com/vim/vim

I’ve also tested this method with GitLab and it works there too! You can try other repositories as well!

Sourcegraph Developers have a master plan behind declaring it Open Source:

Make basic code intelligence ubiquitous (for every language, and in every editor, code host, etc.)

Make code review continuous and intelligent

Increase the amount and quality of open-source code

Here are the ways they suggest you can contribute to its Development:

So this was a brief look into how Sourcegraph can make the developer’s life a lot more easier and hassle-free.

Are you a Developer? Would you like to adopt this new Open Source Tool in your day-to-day programming tasks? Let us know in the comments section below.

Source

Download Haguichi Linux 1.4.1

Haguichi is an open source application that provides users with a graphical front-end for the Hamachi (now known as LogMeIn) zero-configuration virtual private network (VPN) software under any GNU/Linux operating system.

A quick overview of its features

Key features include a straightforward, modern and easy-to-use graphical user interface, completely customizable commands, system tray integration, pop-up notifications, rich tooltips, as well as collapsible and sortable network list.

The program is translated into more than 15 languages, supports a wide range of open source desktop environments and Linux-based operating systems, and allows users to easily backup and restore their Hamachi configurations.

It sports a familiar graphical user interface that allows users to connect with a single mouse click. It features supports for both IPv4 and IPv6 protocols, automatic connection during startup, automatic reconnection when the connection is lost, custom commands, and much more,

Under the hood and availability

Under the hood, we can report that the application is written in the Vala programming language. It is also very important to mention that you will need to download and install the Hamachi client before installing this software on your Linux box. Be aware that Hamachi is now know as LogMeIn.

Officially supported Linux distributions include Ubuntu, Arch Linux, openSUSE, Linux Mint, elementary OS, Fedora, and Debian GNU/Linux, for which the developers offer binary installers. A source archive is also available for download, allowing experienced users to configure, compile and install the application under any Linux-based operating system.

Bottom line

In conclusion, Haguichi is a very good graphical user interface for the Hamachi service. It supports a multitude of distributions and desktop environments, and it’s probably the only one that can offer a modern Hamachi client on GNU/Linux.

Source

How to Install VMware Workstation on Ubuntu 18.04 LTS

What is VMware Workstation?

VMware Workstation is a virtualization software developed by the company VMware company, established in 1998. VMware Workstation was launched in 2001 as a platform to install multiple instances of different operating systems, especially the client and server systems. It supports hardware compatibility for hard disks, CD Roms and USB devices, and provides a bridge between the host and virtual machines. The purpose of building such a platform was to enable system administrators to test and verify the client-server environment for software and hardware. The VMware administrator can also switch between different virtual machines at the same time.

Install VMware Workstation

This article shows how to install and launch VMware Workstation on your Ubuntu system. The commands and procedures used in this article describe the installation of VMware Workstation 15 on a Ubuntu 18.04 LTS system.

Step 1: Download the official VMware binary package

The most stable and latest version of the VMware Workstation can be downloaded from their official website. Open your Ubuntu command line, the Terminal, either through the system Dash or the Ctrl+Alt+T shortcut. Then, enter the following wget command in order to download the binary package to your system:

$ wget -O ~/vmware.bin https://www.vmware.com/go/getWorkstation-linux

This command will download the package to the current user’s home folder in a file named vmware.bin.

Step 2: Install Build Essential to your system

In order to install the VMware Workstation, you first need to have a prerequisite called Build Essential on your system. The Built Essential includes a reference to all the packages needed to compile a Ubuntu binary installation package.

Run the following command as sudo in order to install it:

$ sudo apt install build-essentialInstall Build Essential

The system will prompt you with a Y/n option to continue the installation procedure. Please enter Y to continue.

Step 3: Launch the VMware Installer

We will now launch the graphical VMware Installer through the command line, that will guide you through the rest of the installation procedure. Please run the following command to launch the installer:

$ sudo bash ~/vmware.bin

The installer will launch as follows:VMWare Workstation installer

The installer will let you make some custom settings such as specifying the default administrator for VMware, selecting the installation folder and choosing an HTTP port for the workstation server. You will be also asked to provide a License Key. You may provide this key if you have it or even wish to skip the step simply by clicking the Next button.

The following window will indicate the successful end of the Installation procedure.Installation successful

Step 4: Launch the VMware Workstation

You can launch the VMWare Workstation both through the command line and the GUI.

Enter the following command as sudo in order to launch VMware, as only the administrator can use it:Launch vmware with sudo

Or enter the VMware keyword in your system Dash and then click on VMWare Workstation icon from the search results.Start VMWare from Desktop

When you first launch VMware, it will ask if you want to enter the license key, buy it, or use the trial version of the software for 30 days.Enter license key

Select your choice and click OK.

As mentioned before, you need to be an administrator to use the VMware Workstation. Thus, the following authentication dialog will appear asking you to provide your password.

Enter the password and click the Authenticate button to start VMware.VMWare Workstation started

Click the OK button on the Information dialog.VMWare Workstation pro installed

Here, you can perform the operations such as creating and opening a new, connecting to a remote server and other customizations as an administrator.

Through the step by step installation instructions mentioned in this article, you can install the VMware Workstation through the official binary package and then launch it as an administrator on your Ubuntu system.

Source

Linux Today – How To Install Kali Linux Tools In Ubuntu

Nov 09, 2018, 19:00

Today I am going to do a quick demonstration of how to easily install a suite of security testing tools from Kali Linux onto a Ubuntu machine. For a bit of background information, Kali Linux is a distribution derived from Debian. Its sole purpose is to provide a suite of tools for penetration testing (pentesting) and forensics. It is provided by Offensive Security, an organization dedicated to providing security training. There is a very long list of tools available for Kali. Such tools include (but are not limited to) forensics, vulnerability checks, access checks, and stress testing.

Complete Story

Source

Download GNOME Control Center Linux 3.30.2

GNOME Control Center is an open source project that allows GNOME users to control various aspects of their desktop environment, as well as of the Linux operating system on top of which GNOME is installed. The application provides a single, easily accessible place where users can interact with GNOME’s settings. It is integrated into the GNOME desktop environment and can be accessed through the system tray area.

Easy access to main GNOME settings

The program is comprised of three main settings categories, such as Personal, Hardware and System. The Personal section includes the Background, Notifications, Online Accounts, Privacy, Region & Language, and Search entries. The Hardware category includes Bluetooth, Color, Displays, Keyboard, Mouse & Touchpad, Network, Power, Printers, Sound and Wacom Tablet. Lastly, the System category include Date & Time, Details, Sharing, Universal Access and Users.

Designed for new and experienced users

It can be easily used by new and experienced users alike, so they can successfully configure various aspects of the GNOME desktop environment. Therefore, users will be able to change the desktop wallpaper, add or remove online accounts, change privacy, language and notification settings, configure the integrated search function, enable Bluetooth support, and configure their peripheral devices.

Additionally, the application can be used to change the color profile and settings of your monitor, configure network connections, printers, wacom tablet, sound and power settings. Also, you can use it to change the default applications, set the date and time, add and remove users, or enable sharing.

Also known as Unity Control Center

Several well known Linux-based operating system forked the GNOME Control Center application, transforming it into their very own control center app. A popular example is the Ubuntu distribution, where GNOME Control Center is present in the form of Unity Control Center. Any GNOME user has interacted with the GNOME Control Center in a form or another to set various hardware components, change the wallpaper or even to add new users on their Linux system.

Source

WP2Social Auto Publish Powered By : XYZScripts.com