Various Bash examples for redirecting standard output and standard error to the same file

Bash – Redirect both standard output and standard error to same file

The Bash shell is the most popular shell on Linux systems, and to use the shell efficiently, you need a little knowledge about Bash shell redirections. This is also an essential step in learning Bash scripting.

In this guide, we’ll show how to redirect standard output and standard error to the same file on the Bash shell command line. This will include several examples so you can pick the right method in any scenario.

In this tutorial you will learn:

  • How to redirect standard output and standard error to same file
  • How to redirect standard output and standard error to file and terminal
  • How to redirect standard output and standard error to /dev/null

Read more

routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed

Symptoms

Unable to connect to SMTP server using PHP and OpenSSL. The following related error messages may appear as part of troubleshooting output:

PHP Warning: fsockopen(): SSL operation failed with code 1. OpenSSL Error messages: error:14090086:SSL 
routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed
PHP Warning: fsockopen(): Failed to enable crypto 
PHP Warning: fsockopen(): unable to connect to ssl
PHP User Warning: Unable to connect to SMTP server 

Read more

How to disable NGINX logging on Linux system

The default configuration of Nginx webserver logging system is to log both access and error logs for all enabled sites into /var/log/nginx/access.log and /var/log/nginx/error.log respectively. This default behaviour is set by the following directives found within /etc/nginx/nginx.conf configuration file:

access_log /var/log/nginx/access.log;
error_log /var/log/nginx/error.log;

Read more

Moodle – Exception – Call to undefined function xml_parser_create()

Symptoms

The following error message occurs during moodle upgrade attempt whether it be on command line or admin back end:

# php moodle/admin/cli/upgrade.php 
Default exception handler: Exception - Call to undefined function xml_parser_create() Debug: 
Error code: generalexceptionmessage
* line 76 of /lib/xmlize.php: Error thrown
* line 307 of /lib/environmentlib.php: call to xmlize()
* line 355 of /lib/environmentlib.php: call to load_environment_xml()
* line 101 of /lib/environmentlib.php: call to get_latest_version_available()
* line 116 of /admin/cli/upgrade.php: call to check_moodle_environment()

!!! Exception - Call to undefined function xml_parser_create() !!!
!! 
Error code: generalexceptionmessage !!
!! Stack trace: * line 76 of /lib/xmlize.php: Error thrown
* line 307 of /lib/environmentlib.php: call to xmlize()
* line 355 of /lib/environmentlib.php: call to load_environment_xml()
* line 101 of /lib/environmentlib.php: call to get_latest_version_available()
* line 116 of /admin/cli/upgrade.php: call to check_moodle_environment()
 !!

Read more

Installation of missing php-mbstring on RHEL 7 Linux

The php-mbstring is part of Redhat’s server optional packages. If you have a current subscirption all you need to do is to enable this repository using:

[root@rhel7 ~]# subscription-manager repos --enable=rhel-7-server-optional-rpms

and use yum to install php-mbstring. In case that you do not have a current Redhat subscription you can install php-mbstring directly from IUS project repository:

[root@rhel7 ~]# wget http://dl.iuscommunity.org/pub/ius/stable/Redhat/7/x86_64/ius-release-1.0-13.ius.el7.noarch.rpm
[root@rhel7 ~]# wget http://dl.fedoraproject.org/pub/epel/7/x86_64/e/epel-release-7-2.noarch.rpm
[root@rhel7 ~]# rpm -Uvh *release*.rpm

Read more

GRUB boot loader for Linux

How to Fix Grub error: no such partition Grub Rescue

Grub is a boot loader for many Linux distributions which basically tells your system where it can find installed operating system(s) on one or more hard drives. Your PC needs this information in order to boot into your Linux distro successfully. If grub becomes corrupted, one such error you may come across is “error: no such partition grub rescue.”

This error most commonly arises when resizing or rearranging the partitions of a hard drive, as is necessary with dual boot in Ubuntu or dual boot in Manjaro, for example. If you’ve received this error out of the blue (i.e. you haven’t made any recent changes to your hard drive), it could be a sign of the hard drive going bad.

Regardless of the cause, we’ve written this guide to help you get your Linux system back up and running. In this article, we’ll give you the step by step instructions to fix the dreaded “no such partition” grub error.

In this tutorial you will learn:

  • How to fix grub error: no such partition grub rescue

Read more

Kali Linux repository update error

Kali Linux – Failed to fetch InRelease – Repository Fix

Symptoms

Unable to use standard Kali Linux provided repository for updating the Kali Linux system as well for new software installations.

The following error message appears when attempting to run the apt update command:

Err:1 http://http.kali.org/kali kali-rolling InRelease
  403  Forbidden [IP: 192.99.200.113 80]
Reading package lists... Done
E: Failed to fetch http://http.kali.org/kali/dists/kali-rolling/InRelease  403  Forbidden [IP: 192.99.200.113 80]
E: The repository 'http://http.kali.org/kali kali-rolling InRelease' is not signed.
N: Updating from such a repository can't be done securely, and is therefore disabled by default.
N: See apt-secure(8) manpage for repository creation and user configuration details.

Read more

E: Could not get lock /var/lib/apt/lists/lock – open (11: Resource temporarily unavailable)

Could not get lock var lib dpkg lock – Ubuntu/Debian

This error message is fairly common on any Ubuntu or any other Debian based Linux system.

The meaning of the Could not get lock message is rather simple. At the time you attempt to install new software or update your operating system, there is another software installation or software upgrade underway which runs in the background and was launched on another remote or local terminal by other user with administrative privileges.

Read more

Ubuntu 20.04 GPG error: The following signatures couldn't be verified

Ubuntu 20.04 GPG error: The following signatures couldn’t be verified

The Ubuntu 20.04 GPG error: The following signatures couldn't be verified is a most common error when attempting to include third party package repositories to the apt package manager.

The GPG error should rather be treated as a warning against potential package installation from unknown sources. Therefore, the GPG error message prompts the user to verify and manually import the third party signature belonging to relevant package developer.

In this tutorial you will learn:

  • How to import public key signature

Read more