Category » Linux

How to set up HTTP authentication with nginx

We will demonstrate you how to setup HTTP Authentication with Nginx on Ubuntu in this article. We are using Ubuntu 16.04.1 and have nginx version: nginx/1.10.0 installed in our machine.

“htpasswd” is used to create and update the files used to store usernames and password for basic authentication of HTTP users.

Following are the steps that we need to follow:

  1. apache2-utils
  2. Create username and password
  3. Update Nginx configuration
  4. Reload the Nginx Configuration

Continue reading »

Shell script – how to find out the directory in which it resides?

Shell Script

My shell script samplescript.sh resided in the directory /home/projects/sampleproject/scripts and in the shell script I included a configuration file relatively as below:

#!/bin/bash

CONF="../config/common.conf"
. $CONF

Continue reading »

How to change the system timezone in Linux

World Clock

In Linux, the system time zone is determined by the symbolic link /etc/localtime. This symbolic link points to a time zone data file located at either /usr/share/zoneinfo or /usr/lib/zoneinfo depending on Linux distribution. So changing the system timezone is just a simple job of updating this symbolic link.

Run the following command to view the list of regions

ls -l /usr/share/zoneinfo

Continue reading »

How to include a file in a bash shell script

Linux

I had written few shell scripts for a project. All these scripts were using some common configuration parameters so I decided to put them in a common file and include it in the scripts file so that when I move the script files from the development to the production environment, I have to change the values in only one file.

My configuration file “config.conf” contained variables like:

DB_HOST=127.0.0.1
DB_PORT=3306
DB_USER=testuser
DB_PASS=test123

Continue reading »

13 Linux wget command usage examples

Download using wget

Wget is a computer software package for retrieving content from web servers using HTTP, HTTPS and FTP protocols. It is a non-interactive commandline tool, so it may easily be called from scripts, cron jobs, terminals without X-Windows support, etc. Its features include recursive download, conversion of links for offline viewing of local HTML, and support for proxies.

Lets have a look at some examples of using wget:

1. Download a webpage


$ wget http://www.examplewebsite.com/

2. Download a file from ftp server


$ wget ftp://ftp.examplewebsite.com/source-code.tar.gz

If you specify a directory, Wget will retrieve the directory listing, parse it and convert it to html


$ wget ftp://ftp.examplewebsite.com/

Continue reading »

17 Linux curl command usage examples

curl

cURL is a computer software project and it produces two products – libcurl and curl.

libcurl

A free and easy-to-use client-side URL transfer library, supporting DICT, FILE, FTP, FTPS, GOPHER, HTTP, HTTPS, IMAP, IMAPS, LDAP, LDAPS, POP3, POP3S, RTMP, RTSP, SCP, SFTP, SMTP, SMTPS, TELNET and TFTP.

libcurl supports HTTPS certificates, HTTP POST, HTTP PUT, FTP uploading, kerberos, HTTP form based upload, proxies, cookies, user+password authentication, file transfer resume, http proxy tunneling and more!

curl

A command line tool for getting or sending files using URL syntax. Since curl uses libcurl, curl supports the same wide range of common Internet protocols that libcurl does.

Continue reading »

How to install .deb packages in Ubuntu?

Ubuntu

Debian (.deb) packages are the packages that are used in Ubuntu. You need to have administrative privileges to install a .deb file.

To install .deb files from shell/command prompt you can use the dpkg command. dpkg is a package manager for Debian based systems. It can install, remove, and build packages, but unlike other package management system’s it can not automatically download and install packages and their dependencies.

Continue reading »

What is better, curl or wget?

curl vs wget

Both cUrl and Wget can be used to download files, but the question comes which one to use. cUrl and Wget have some similarities and as well as differentiating factors, the one to use depends on your need.

Continue reading »

Back to top