Linux Hint https://linuxhint.com Exploring and Master Linux Ecosystem Wed, 21 Nov 2018 16:06:35 +0000 en-US hourly 1 https://wordpress.org/?v=4.9.8 Ubuntu Killall Command https://linuxhint.com/ubuntu_killall/ Tue, 20 Nov 2018 08:40:40 +0000 https://linuxhint.com/?p=32705 Every single Linux distros is a collection of standard and something other tools at the core. Ubuntu, being one of the most popular ones, offers the most popular and powerful Linux tools in the wild. “killall” is such a powerful tool at your disposal. Let’s find out what you can do with “killall”. It’s just […]

The post Ubuntu Killall Command appeared first on Linux Hint.

]]>
Every single Linux distros is a collection of standard and something other tools at the core. Ubuntu, being one of the most popular ones, offers the most popular and powerful Linux tools in the wild. “killall” is such a powerful tool at your disposal. Let’s find out what you can do with “killall”. It’s just like “kill” but with a lot more power in the pocket. It’s a CLI tool. Caution is a must as a wrong command can completely render your system useless.

Killall command

“killall” follows the following structure –

killall [OPTIONS] name

According to the man page of “killall”, the tool sends a signal to the target processes. Without specifying the signal type, the default is SIGTERM. If “killall” is able to kill at least 1 process matching the requirements, it returns a zero return code. You can’t kill a “killall” process.

Killing a process

This is the most basic usage of “killall” command. All you have to do is just pass the name of the process.

For example, I’ve got GNOME Disks open, process name “gnome-disks”. For killing the process, run the following command –

killall gnome-disks

Asking for permission

When you’re running “killall” commands, there’s a pretty good chance that you’re about to kill something unintended. You have to use the “-i” flag.

killall -i gnome-disks

Case sensitivity

Generally, “killall” is a case-sensitive tool, so make sure that you type the name correctly.

# Wrong command
killall GNOME-disks

# Correct command
killall gnome-disks

If you want to force killall as case-insensitive, use “-I” flag.

killall -I GNOME-disks

Choosing the ENDING signal

There are different types of termination signal available. If you want to use a specific end signal, use the following structure –

killall -s

# OR
killall --signal

# OR
killall -SIGNAL

For finding out the available signal list, use the “-l” flag.

killall -l

Killing process by the time

You can also tell “killall” to terminate the processes depending on their time of running!

killall -o [TIME]

# OR
killall --older-than [TIME]

For example,

killall -o 2h

This command will kill all the processes that have been running for more than 2 hours.

killall -y [TIME]

# OR
killall --younger-than [TIME]

For example,

killall -y 2h

This command will kill all the processes that are younger than 2 hours.

Killing all the processes owned by a user

This is a very risky thing to do and may even render your system useless unless you restart it. Make sure that you have all your important tasks finished.

The structure goes like this –

killall -u [USERNAME]

For example,

killall -u viktor

This command will kill everything under the user “viktor”.

Other “killall” commands

There are a number of other available commands of “killall”. For the short list, use the following command –

killall --help

For an in-depth explanation of every single parameter and options, the man page is the best option.

man killall

You can export the man page to a separate text file for reading later.

man killall > ~/Desktop/killall.txt

Enjoy!

The post Ubuntu Killall Command appeared first on Linux Hint.

]]>
Raspberry Pi Connect to Wifi Using wpa_supplicant https://linuxhint.com/rasperberry_pi_wifi_wpa_supplicant/ Tue, 20 Nov 2018 08:24:58 +0000 https://linuxhint.com/?p=32691 The officially recommended operating system of Raspberry Pi is Raspbian. On Raspbian, you can configure Wi-Fi networks using wpa_supplicant very easily.  In this article, I will show you how to configure Wi-Fi on your Raspberry Pi single board computer with Raspbian installed. I will be using Raspberry Pi 3 Model B for the demonstration. But […]

The post Raspberry Pi Connect to Wifi Using wpa_supplicant appeared first on Linux Hint.

]]>
The officially recommended operating system of Raspberry Pi is Raspbian. On Raspbian, you can configure Wi-Fi networks using wpa_supplicant very easily.  In this article, I will show you how to configure Wi-Fi on your Raspberry Pi single board computer with Raspbian installed. I will be using Raspberry Pi 3 Model B for the demonstration. But this article should work on any other version of Raspberry Pi with Raspbian installed. So, let’s get started.

Connecting to Wi-Fi on Raspberry Pi Headless (Without Monitor):

If you don’t have a monitor and also don’t have an Ethernet cable that can assign IP addresses to your Raspberry Pi via DHCP automatically, then you may think you don’t have a way to connect Raspberry Pi to your Wi-Fi network. But don’t lose hope. There are people configuring Raspberry Pi headless (without monitor). You can too. First, insert your microSD card on your computer. Then, flash the microSD card with Raspbian OS using Etcher.

NOTE: I have written a dedicated article on installing Raspbian on Raspberry Pi. You should take a look at it here on LinuxHint.com if you’re having problems with installing Raspbian on Raspberry Pi.

Then, eject your microSD and insert it on your computer again. You will find a boot partition as shown in the screenshot below. Double click on it.

You will see many files inside this directory. You will have to create 2 more files in this directory.

The first file is ssh (no extension). You don’t have to add anything in this file. The ssh file will enable SSH service. Without SSH enabled, you won’t be able to connect to your Raspberry Pi remotely. It will be useless.

The second file is wpa_supplicant.conf

In this file, you will have to type in the required configuration to connect to the Wi-Fi network.  Just create a new file wpa_supplicant.conf and add the following lines to it. Be sure to make changes where necessary depending on your configuration. Finally, save the file.

country=US
ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
update_config=1

network={
ssid="WIFI_SSID"
scan_ssid=1
psk="WIFI_PASSWORD"
key_mgmt=WPA-PSK
}

NOTE: Don’t forget change WIFI_SSID to your Wi-Fi SSID, change WIFI_PASSWORD to your Wi-Fi password.

Now, eject the microSD card from your computer and insert it on your Raspberry Pi. Then, power on your Raspberry Pi. Your Raspberry Pi should be connected to the Wi-Fi network. You can find the IP address that is assigned to your Raspberry Pi via your Wi-Fi router from the control panel of your Router very easily. Mine is happen to be 192.168.2.16.

Now, your Raspberry Pi should be accessible remotely via SSH. The default username is pi and password is raspberry.  To connect to your Raspberry Pi using SSH for the first time, run the following command:

$ ssh pi@192.168.2.16

Now, type in yes and press <Enter>.

Now, type in the password raspberry and press <Enter>.

You should be connected to your Raspberry Pi remotely.

Re-configuring Wi-Fi Configuration on Raspberry Pi:

If you have network connectivity already and can connect to the Raspberry Pi remotely via SSH or VNC, and want to change the Wi-Fi configuration, then all you have to do is edit the wpa_supplicant configuration file /etc/wpa_supplicant/wpa_supplicant.conf

First, connect to your Raspberry Pi remotely via SSH or VNC.

Then, edit the /etc/wpa_supplicant/wpa_supplicant.conf configuration file with the following command:

$ sudo nano /etc/wpa_supplicant/wpa_supplicant.conf

The wpa_supplicant.conf configuration file should be opened as you can see in the screenshot below.

Now, modify your Wi-Fi connection details as required and save the file again by pressing <Ctrl> + x and then press y followed by <Enter>.  Now, reboot your Raspberry Pi, the changes should be applied.

Adding Backup Wi-Fi Network:

You can add details of multiple Wi-Fi network on your Raspberry Pi. That way, if any Wi-Fi SSID is not available, Raspberry Pi will try to connect to the next Wi-Fi SSID. If it fails, it will try to connect to the next one and so on. I think this is an awesome feature of wpa_supplicant.

To add a backup Wi-Fi network on your Raspberry Pi, just edit the configuration file /etc/wpa_supplicant/wpa_supplicant.conf with the following command:

$ sudo nano /etc/wpa_supplicant/wpa_supplicant.conf

Now, type in the lines as marked in the screenshot below in the order in which you want the Raspberry Pi to try to connect to the Wi-Fi network.

For example, let’s say you have Wi-Fi networks with the SSID CSE_LAB1 and HOME1 respectively. You want to connect to the Wi-Fi SSID HOME1 when you’re home. But when you’re at the university, you want to connect to the Wi-Fi SSID CSE_LAB1. So, here, HOME1 is your primary Wi-Fi SSID and CSE_LAB1 is your secondary Wi-Fi SSID. The wpa_supplicant.conf configuration file should look as follows in this case.

country=US
ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
update_config=1

network={
ssid="HOME1"
scan_ssid=1
psk="HOME1_PASS"
key_mgmt=WPA-PSK
}

network={
ssid="CSE_LAB1"
scan_ssid=1
psk="CSE_LAB1_PASSWORD"
key_mgmt=WPA-PSK
}

Make sure you reboot your Raspberry Pi for the changes to take effect. So, that’s how you configure Wi-Fi on your Raspberry Pi single board computer using wpa_supplicant. Thanks for reading this article.

The post Raspberry Pi Connect to Wifi Using wpa_supplicant appeared first on Linux Hint.

]]>
Make Raspberry Pi Thin Client https://linuxhint.com/raspberry_pi_thin_client/ Mon, 19 Nov 2018 16:07:36 +0000 https://linuxhint.com/?p=32651 A thin client is a low power computer that can connect to other powerful computers remotely usually via VNC or RDP protocol and then it shows the screen of the remote computer on the display connected to the thin client. The USB devices connected to the thin client is useable from the remote computer that […]

The post Make Raspberry Pi Thin Client appeared first on Linux Hint.

]]>
A thin client is a low power computer that can connect to other powerful computers remotely usually via VNC or RDP protocol and then it shows the screen of the remote computer on the display connected to the thin client. The USB devices connected to the thin client is useable from the remote computer that it is connected to. So, it’s a very great solution for companies. Instead of buying separate computers for each of their employees, they can set up a powerful virtualization server and set up low cost thin clients that will connect to the virtual machines hosted on the virtualization server. This solution also makes upgrade easier as the computers are in reality virtual machines.

Now you know how useful thin clients are. Raspberry Pi is a cheap single board computer that you can set up as a thin client very easily using WTware.  In this article, I will show you how to set up a Raspberry Pi thin client. I will be using Raspberry Pi 3 Model B, but it should work on any model of Raspberry Pi 2 or Raspberry Pi 3. So, let’s get started.

Things You Need:

To make a Raspberry Pi thin client, you need,

  • A Raspberry Pi 2 or Raspberry Pi 3 single board computer.
  • A microSD card.
  • Internet connection and a Windows computer.
  • A Monitor with HDMI cable.
  • An Ethernet cable.
  • A USB keyboard and a USB mouse.
  • An Android phone charger for powering up Raspberry Pi.

Downloading WTware for Raspberry Pi:

WTware for Raspberry Pi must be installed on Windows. Once you get it installed, you will be able to flash your microSD card, which then will work on Raspberry Pi.  To download WTware, first, go to the official website of WTware for Raspberry Pi at http://winterminal.com/ and click on Download as marked in the screenshot below.

WTware should start downloading.

Flashing WTware on microSD Card:

Once WTware is downloaded, you have to install it on your Windows computer for you to be able to flash your microSD card.

To install WTware, navigate to the directory where you just downloaded it and double click on the WTware installer.

Now, click on Next.

Click on Next.

Uncheck all the marked checkboxes and click on Next.

Now, click on Next.

WTware is being installed…

Once the installation is complete, click on Next.

Now, click on Finish.

Now, start WTware Configurator from the start menu.

WTware should start. Now, insert the microSD card on your computer and click on the SD card icon as marked in the screenshot below.

Now, select your microSD card and click on Next.

NOTE: At times, your microSD card may not show up here. In that case, you will have to format it using SD Card Formatter. You can download SD Card Formatter for free from https://www.sdcard.org/downloads/formatter_4/

Now, click on Next.

Click on Next.

Now, select Store terminal configuration file locally and click on Next as marked in the screenshot below.

Now, click on Next.

Now, check Save parameters into config.txt file checkbox and set the resolution of your Monitor that you will connect to the Raspberry Pi here. Once you’re done, click on Next.

Now, click on Write to SD card! icon as marked in the screenshot below.

Now, click on Yes. Your SD card will be erased and WTware will be flashed on it.

Once the microSD card is flashed, click on Close.

Now, eject the microSD card from your computer.

Booting WTware on Raspberry Pi:

Now,

  • Insert the microSD card on your Raspberry Pi.
  • Connect the HDMI cable on your Raspberry Pi.
  • Connect the Ethernet cable from your Router or Switch to your Raspberry Pi.
  • Connect USB mouse and USB keyboard to your Raspberry Pi.
  • Connect the Android phone charger on your Raspberry Pi.

Once you connect everything on your Raspberry Pi, power it on.

Just after you power it on, keep pressing the Delete key on your keyboard. You should see the following configuration window.

Now, use the <Down> arrow key to navigate to Edit configuration file and press <Enter>.

Now, type in the IP address of your Windows computer that has Remote Desktop enabled in the marked section of the screenshot below. Once you’re done, save the configuration file by pressing <F2> key on your keyboard.

Connecting to Windows Machines via RDP:

Now, use the <Up> arrow key on your keyboard to navigate to Connect for configurating as marked in the screenshot below and press <Enter>.

Now, you should see the following window. Just select the IP that you just configured and press <Enter>.

NOTE: If you want to add another server, just select Another server… from the list and type in the details and you should be connected to your desired Windows computer via RDP (Remote Desktop Protocol).

Now, type in your login username and password and press <Enter>.

You should be connected to your Windows computer via the Raspberry Pi thin client (WTware).

As you can see, I am connected to my Ryzen 5 2400G workstation via my Raspberry Pi thin client.

WTware for Raspberry Pi is not free. You can try it out for free. But the free version shows you EVALUATION COPY overlay messages on the screen as you can see in the screenshot below.

To get rid of this EVALUATION COPY messages from the screen, you will have to buy WTware for Raspberry Pi. To buy WTware for Raspberry Pi, visit the official website of WTware for Raspberry Pi at http://winterminal.com/index.html#buy

So, that’s how you make a Raspberry Pi thin client with WTware. Thanks for reading this article.

The post Make Raspberry Pi Thin Client appeared first on Linux Hint.

]]>
Python Dash Tutorial https://linuxhint.com/python_dash_tutorial/ Mon, 19 Nov 2018 13:37:54 +0000 https://linuxhint.com/?p=32626 Hey everybody, Welcome. Dash is the topic that we are going to discuss today. Dash is developed by Plotly. Some of you might have got an idea that Dash is perhaps about graphs because of Plotly. And yes, you are absolutely right. Dash is about representation of graphs in a web UI (user interface). Web […]

The post Python Dash Tutorial appeared first on Linux Hint.

]]>
Hey everybody, Welcome. Dash is the topic that we are going to discuss today. Dash is developed by Plotly. Some of you might have got an idea that Dash is perhaps about graphs because of Plotly. And yes, you are absolutely right. Dash is about representation of graphs in a web UI (user interface). Web UI doesn’t mean that Dash requires an active internet connection to run, rather it just needs a server and will run on “localhost” or “127.0.0.1”. Dash happens to run on port 8050 by default, so when you run your Dash application on your browser you would go on the address as “127.0.0.1:8050”.

First of all, we have to install Dash on our system. Hit Ctrl+Alt+T on your Ubuntu, it would open up terminal. In order to run Dash applications on our system, we would install 4 to 5 packages using following command:

$ sudo pip install dash dash-renderer dash-html-components dash-core-components plotly

OR

$ sudo -H pip install dash dash-renderer dash-html-components dash-core-components plotly

When you will add -H it would not issue a warning because you would get to the Home variable by using -H in the command. Even if you don’t use it, it would be okay as it would display a warning but Dash would get installed anyway.

Now, you would go on to create a python script. Our first example of code would just display a simple output in our web browser on the server address and port mentioned above.  In the example, first 3 lines would be the imports of dash, dash-core-components and dash-html-components respectively. Dash-core-components as dcc means that wherever we want to use dash-core-components we can use ‘dcc’ instead and similarly where we want to use dash-html-components, we can use ‘html’. Dash() is the built in class which holds the default code for Dash applications. ‘app.layout’ represents everything in web UI which means anything you want to display in the browser in Dash application, it has to be written in the operating zone of ‘app.layout’. Following our first simple code example which just displays a simple output:

Code Example#1:

import dash
import dash_core_components as dcc
import dash_html_components as html
 
app = dash.Dash()
 
app.layout = html.Div('LinuxHint YouTube Hi')
 
if __name__ == '__main__':
    app.run_server(debug=True)

Output:

Second example is about creating a graph. We would use ‘dcc’ which essentially means dash-core-components and we would create a graph using it. In our example, we have drawn an example graph of Energy and Time with random values of ‘x’ and ‘y’ by giving a type of ‘line’ to Energy and a type of ‘bar’ to Time. We would do all of that inside a method dcc.Graph() in which we would name our both axis of the graph and set the title of graph as well.

Code Example#2:

import dash
import dash_core_components as dcc
import dash_html_components as html
 
app = dash.Dash()
 
app.layout = html.Div(children=[
html.Div(children='LinuxHint Youtube Hi'),
dcc.Graph(
id='graphss',
figure={
'data': [
{'x':[1,2,3,4,5,6,7], 'y':[11,12,22,23,24,44,55], 'type':'line', 'name':'Energy'},
{'x':[1,2,3,4,5,6,7], 'y':[13,15,26,27,34,44,65], 'type':'bar', 'name':'Time'},
],
'layout': {
'title': 'Graph for Time and Energy'
}
}
)
])
 
if __name__ == '__main__':
    app.run_server(debug=True)

Output:

Pro Tip: While writing python script, use a python IDE or a smart text editor which indents the code automatically for you. Avoid using simple notepad or text editor for python scripts as indentation of code is an important factor in python while running it.

 

I will explain this in more details in video form as well.

The post Python Dash Tutorial appeared first on Linux Hint.

]]>
Install PDFtk on Ubuntu https://linuxhint.com/install_pdftk_ubuntu/ Mon, 19 Nov 2018 07:25:32 +0000 https://linuxhint.com/?p=32596 PDF is an integral part of our everyday life. It’s a document format that’s trusted by every single platform. Often times, important documents and books are in PDF format. It’s so widespread that without an appropriate PDF tool at hand, no system is complete. Ubuntu offers a great flexibility in terms of software availability. It’s […]

The post Install PDFtk on Ubuntu appeared first on Linux Hint.

]]>
PDF is an integral part of our everyday life. It’s a document format that’s trusted by every single platform. Often times, important documents and books are in PDF format. It’s so widespread that without an appropriate PDF tool at hand, no system is complete. Ubuntu offers a great flexibility in terms of software availability. It’s also one of the most popular Linux distros for being so simple yet powerful and fast, extremely suitable for new to moderate Linux users. Let’s grab PDFtk – the ultimate PDF toolkit you’ll ever need!

PDFtk

There are 2 versions of PDFtk available – Free, Pro ($3.99) and Server. The Pro version offers all the additional features like rotating the PDF, stamping etc. The Server version is the command-line utility for performing various tasks.

PDFtk is available in the default Ubuntu software repository. However, on the latest Ubuntu releases, it’s not accessible directly. You have to use a little trick to get in on your system.

Method 1

Run the following commands –

sudo add-apt-repository ppa:malteworld/ppa
sudo apt update

sudo apt install pdftk

Method 2

You can also download and build PDFtk by yourself. For doing so, you need the Java build tools and dependencies.

Run the following commands –

sudo apt install default-jre-headless libcommons-lang3-java libbcprov-java

sudo apt install git default-jdk-headless ant \
libcommons-lang3-java libbcprov-java

git clone https://gitlab.com/pdftk-java/pdftk.git
 
cd pdftk
mkdir libs
ln -st libs /usr/share/java/{commons-lang3,bcprov}.jar

ant jar
java -jar build/jar/pdftk.jar --help

Method 3 (recommended)

Install the PDFtk snap –

sudo snap install pdftk

Note that this is the “Server” version of PDFtk.

Using PDFtk

After the installation is complete, check out the app working perfectly –

pdftk

In fact, running this command will show a short guide you can use. For the long, in-depth guide, run the following command –

pdftk --help

For checking out the guide later, export it to a text file –

pdftk --help > ~/Desktop/pdftk.txt

Here are some of the most used tasks you can do with PDFtk.

Encrypt a PDF (128-bit encryption)

pdftk dummy.pdf output dummy.128.pdf owner_pw foo user_pw 123

Decrypt a PDF

pdftk dummy.128.pdf input_pw 123 output dummy.unsecured.pdf

Join multiple PDFs into one

pdftk dummy1.pdf dummy2.pdf cat output dummy_merged.pdf

You can also use wildcard –

pdftk *.pdf cat output combined.pdf

Rotate PDF document (must be 1 page document)

# 90° clockwise rotate
pdftk dummy.pdf cat 1east 2-end output dummy_90.pdf

# 180° rotate
pdftk dummy.pdf cat 1-endsouth output dummy_180.pdf

Enjoy!

The post Install PDFtk on Ubuntu appeared first on Linux Hint.

]]>
Install VMware Workstation Pro 15 on Ubuntu https://linuxhint.com/install_vmware_workstation_pro_ubuntu/ Mon, 19 Nov 2018 07:05:47 +0000 https://linuxhint.com/?p=32556 VMware Workstation Pro is a very powerful virtualization solution for Desktop users. You can virtualize many operating systems on VMware Workstation Pro such as Ubuntu/Debian, Windows 7, Windows 8, Windows 10 and many more. The user interface of VMware Workstation Pro is simple. I really like the simplicity of VMware Workstation Pro. VMware Workstation Pro […]

The post Install VMware Workstation Pro 15 on Ubuntu appeared first on Linux Hint.

]]>
VMware Workstation Pro is a very powerful virtualization solution for Desktop users. You can virtualize many operating systems on VMware Workstation Pro such as Ubuntu/Debian, Windows 7, Windows 8, Windows 10 and many more. The user interface of VMware Workstation Pro is simple. I really like the simplicity of VMware Workstation Pro.

VMware Workstation Pro 15 came out a few months ago. You can easily install VMware Workstation Pro 15 on Ubuntu. In this article, I will show you how to install VMware Workstation Pro 15 on Ubuntu. I will be using Ubuntu 18.04 LTS for the demonstration. But it should work on any modern version of Ubuntu. So, let’s get started.

Downloading VMware Workstation Pro 15:

In this section, I will show you how to download VMware Workstation Pro 15 on Ubuntu.

First, go to the official website of VMware Workstation Pro at https://www.vmware.com/in/products/workstation-pro.html and you should see the following page. Now, click on Download Now >> as marked in the screenshot below.

Now, you should see the following page. Click on the Download Now >> button of Workstation 15 Pro for Linux as marked in the screenshot below.

Your browser should prompt you to save the file. Just select Save File and click on OK.

Your download should start.

Enabling Hardware Virtualization:

Before you start installing VMware Workstation Pro on Ubuntu. I suggest you enable AMD-v if you’re using AMD processor or VT-x/VT-d if you’re Intel processor from the BIOS of your computer. Otherwise, VMware Workstation Pro 15 may not work properly.

Installing VMware Workstation Pro 15:

Once the download is complete, open up a Terminal (shortcut <Ctrl> + t) and navigate to the ~/Downloads directory with the following command:

$ cd ~/Downloads

As you can see, the VMware Workstation Pro 15 installer that I just downloaded is here.

Now, make the installer executable with the following command:

$ chmod +x VMware-Workstation-Full-15.0.1-10737736.x86_64.bundle

Now, run the VMware Workstation Pro 15 installer with the following command:

$ sudo ./VMware-Workstation-Full-15.0.1-10737736.x86_64.bundle

The VMware Workstation Pro 15 installer should start.

Select I accept the terms in the license agreement and then click on Next as marked in the screenshot below.

Select I accept the terms in the license agreement and then click on Next again.

If you want VMware Workstation Pro 15 to check for update every time it starts, then select Yes. Otherwise, select No. Then, click on Next.

If you want to join the VMware’s customer experience improvement program, then select Yes. Otherwise, select No. VMware’s customer experience program will automatically collect data necessary to improve VMware products.

Once you’re done, click on Next.

Click on Next.

If you want to change the directory for Shared Virtual Machines, just click on Browse and select a new directory. The default directory for Shared Virtual Machines is /var/lib/vmware/Shared VMs

Once you’re done, click on Next.

Now, click on Next.

If you’ve bought VMware Workstation Pro 15, then type in the license key here.

If you’re just trying out VMware Workstation Pro 15, then just leave it blank.

Once you’re done, click on Next.

Finally, click on Install.

VMware Workstation Pro 15 is being installed.

Once the installation is complete, click on Close.

Starting VMware Workstation Pro 15:

Now you can start VMware Workstation Pro 15 from the Application Menu of Ubuntu. Just search for vmware and click on the VMware Workstation Pro 15 icon as marked in the screenshot below.

If you see the following window when you start VMware Workstation Pro 15, then it means you don’t have the GCC compilers installed on your system. VMware Workstation Pro 15 needs GCC in order to compile the VMware Kernel Modules. It is easy to fix.

You can easily install GCC on Ubuntu as it is available in the official package repository of Ubuntu. First, update the APT package repository cache with the following command:

$ sudo apt update

Now, install GCC and all the required tools with the following command:

$ sudo apt install build-essential

Now, press y and then press <Enter> to continue.

GCC and all the required build tools should be installed.

Now, if you try to start VMware Workstation Pro 15, you may see the following window. Just click on Install.

Now, type in the password of your login user and click on OK.

As you can see, the VMware Kernel Modules are being built.

Now, you should see the welcome product registration screen of VMware Workstation Pro 15. If you have a valid license key, then type it in and click on OK.

If you just want to try out VMware Workstation Pro 15, then select I want to try VMware Workstation 15 for 30 days and click on OK.

VMware Workstation Pro 15 should start. Click on OK as marked in the screenshot below.

Now, you can start creating Virtual Machines with VMware Workstation Pro 15.

The About window of VMware Workstation Pro 15.

So, that’s how you install VMware Workstation Pro 15 on Ubuntu. Thanks for reading this article.

The post Install VMware Workstation Pro 15 on Ubuntu appeared first on Linux Hint.

]]>
Dual Boot Ubuntu and Windows https://linuxhint.com/dual_boot_ubuntu_windows/ Sun, 18 Nov 2018 04:17:43 +0000 https://linuxhint.com/?p=32524 For many people Windows is a very important operating system. Windows has programs that are very useful such as the Adobe suite. Not everyone has the hardware resource or technical expertise to run Windows as a KVM virtual machine with PCIE GPU pass-through and lots of memory (RAM). So, it’s not possible to play games […]

The post Dual Boot Ubuntu and Windows appeared first on Linux Hint.

]]>
For many people Windows is a very important operating system. Windows has programs that are very useful such as the Adobe suite. Not everyone has the hardware resource or technical expertise to run Windows as a KVM virtual machine with PCIE GPU pass-through and lots of memory (RAM). So, it’s not possible to play games or run productivity applications on Windows virtual machines in Linux. Windows and Linux dual booting is a great solution if you’re one of these people.  In this article, I will show you how to setup Ubuntu 18.04 LTS and Windows 10 dual boot. So, let’s get started.

Primary Operating System – Windows or Ubuntu?

If you’re going to dual boot Ubuntu and Windows, then the first question may be, which one do I install first? From my experience, it’s always a good idea to install Windows first and then Ubuntu. Otherwise, you won’t be able to boot into Ubuntu at all. Windows bootloader is not very Linux friendly as far as I know. But our favorite Linux bootloader GRUB can boot Linux and Windows without any problem. So, take my words and always install Windows first if you want to dual boot.

Preparing Windows 10 for Dual Booting:

Once you’re done installing Windows 10, you have to make room for Ubuntu 18.04 LTS installation. First, go to Start and search for partition. Now, click on the Create and format hard disk partitions as marked in the screenshot below.

The Windows 10 Disk Management tool should be opened. Now, you have to create at least one partition for Ubuntu. If you don’t need a partition, you can just delete it. If you have important data in every partition, then you can shrink one of the partitions to make room for Ubuntu. If you’re shrinking partitions, then make sure to shrink the one that has a lot of free spaces.

Let’s say, you have a partition label as E:/ in Windows 10, and you want to shrink it to make room for Ubuntu. Just right click on the partition and click on Shrink Volume… as marked in the screenshot below.

A Shrink window should be opened. Now, type in the space (in MB) that you want for the partition where you want to install Ubuntu and click on Shrink.

As you can see, about 20GB of disk space is freed (unallocated). You can install Ubuntu here.

If you want to delete a partition (let’s say E:/) completely, just right click on the partition and click on Delete Volume… as marked in the screenshot below.

Now, click on Yes.

As you can see, the partition is deleted and the disk space is now free (unallocated).

Now, you’re ready to install Ubuntu in dual boot configuration.

Installing Ubuntu Alongside Windows 10:

Now, download Ubuntu ISO image from the official website of Ubuntu and make a bootable USB thumb drive of Ubuntu using Rufus. Then, boot into Ubuntu Live media and select Try Ubuntu without installing from the GRUB menu.

Now, test and see if everything works on your machine. If it does and you plan to install Ubuntu, then click on Install Ubuntu 18.04.x LTS icon as marked in the screenshot below.

The Ubuntu installer should show up. Now, select the installer language and click on Continue.

Select your Keyboard layout and click on Continue.

Now, select and check the options depending on your need and click on Continue. I have written dedicated articles on how to install Ubuntu 18.04 LTS at LinuxHint.com. If you want to know what each of these options does, then you may take a look at it. I am focusing on Dual booting in this article.

Now, select Install Ubuntu alongside Windows Boot Manager and click on Install Now.

Now, click on Continue.

Now, select your location and click on Continue.

Now, type in your personal details and click on Continue.

As you can see, Ubuntu is being installed. Ubuntu will be installed on the unallocated disk spaces that you made from Windows 10.

Once Ubuntu is installed, click on Restart Now.

Your computer should reboot and you should be presented with the following GRUB menu. As you can see in the marked section of the screenshot below, you can now boot into either Ubuntu or Windows 10 (Windows Boot Manager). Just use the up and down arrow keys on your keyboard to navigate between Windows or Ubuntu and once you’re done, press <Enter>.

As you can see, the Ubuntu login screen showed up when I selected Ubuntu from the GRUB menu.

As you can see, I am using Ubuntu 18.04.1 LTS in dual boot configuration alongside Windows 10.

As you can see, I can also boot into Windows 10.

Windows 10 is working just fine in dual boot configuration.

So, that’s how you install Ubuntu alongside Windows 10 in dual boot configuration. Thanks for reading this article.

The post Dual Boot Ubuntu and Windows appeared first on Linux Hint.

]]>
Primer on Yum Package Management Tool https://linuxhint.com/yum_package_management_tool/ Sun, 18 Nov 2018 03:54:05 +0000 https://linuxhint.com/?p=32516 The Yum package management tool is very crucial to the management of Linux systems either you are a Linux systems admin or a power user. Different package management tools are available across different Linux distros and the YUM package management tool is available on the RedHat and CentOS Linux distros. In the background YUM (Yellowdog […]

The post Primer on Yum Package Management Tool appeared first on Linux Hint.

]]>
The Yum package management tool is very crucial to the management of Linux systems either you are a Linux systems admin or a power user. Different package management tools are available across different Linux distros and the YUM package management tool is available on the RedHat and CentOS Linux distros. In the background YUM (Yellowdog Updater Modified) is dependent on the RPM(Red Hat Package Manager), and was created to enable the management of packages as parts of a larger system of software repositories instead of individual packages.

How YUM Works

The configuration file for Yum is stored in the /etc/ directory, a file named yum.conf. This file can be configured and tweaked to suit certain needs of the system. Below is a sample of the contents of the yum.conf file:

[main]
cachedir=/var/cache/yum/$basearch/$releasever
keepcache=0
debuglevel=2
logfile=/var/log/yum.log
exactarch=1
obsoletes=1
gpgcheck=1
plugins=1
installonly_limit=5

This configuration file could be different from whatever you may get on your machine, but the configuration syntax follows the same rules. The repository of packages that can be installed with Yum are usually saved in the /etc/yum.repos.d/ directory, with each *.repo file in the directory serving as repositories of the various packages that can be installed.

The image below shows the structure of a CentOS base repository:

YUM works in a pattern similar to all Linux commands, using the structure below:

yum [options] COMMAND

With the command above, you can carry out all necessary tasks with YUM. You can get help on how to use YUM with the –help option:

yum --help

You should get a list of the commands and options that can be run on YUM, just as seen in the images below:

List of commands

List of options

For the rest of this article, we would be completing a couple of tasks with Yum. We would query, install, update and remove packages.

Querying packages with YUM

Let’s say you just got a job as a Linux system administrator at a company, and your first task is to install a couple of packages to help make your tasks easier such as nmap, top etc.

To proceed with this, you need to know about the packages and how well they will fit the computer’s needs.

Task 1: Getting information on a package

To get information on a package such as the package’s version, size, description etc, you need to use the info command.

yum info package-name

As an example, the command below would give information on the httpd package:

yum info httpd

Below is a snippet of the result from the command:

Name : httpd
Arch : x86_64
Version : 2.4.6
Release : 80.el7.centos.1

Task 2: Searching for existing packages

It is not in all cases you would know the exact name of a package. Sometimes, all you would know is a keyword affiliated with the package. In these scenarios, you can easily search for packages with that keyword in the name or description using the search command.

yum search keyword

The command below would give a list of packages that have the keyword “nginx” in it.

yum search nginx

Below is a snippet of the result from the command:

collectd-nginx.x86_64 :Nginx plugin for collectd
munin-nginx.noarch : NGINX support for Munin resource monitoring
nextcloud-nginx.noarch : Nginx integration for NextCloud
nginx-all-modules.noarch : A meta package that installs all available Nginx module

Task 3: Querying a list of packages

There are a lots of packages that are installed or are available for installation on the computer. In some cases, you would like to see a list of those packages to know what packages are available for installation.

There are three options for listing packages which would be stated below:

yum list installed: lists the packages that are installed on the machine.

yum list available: lists all packages available to be installed in from enabled repositories.

yum list all: lists all of the packages both installed and available.

Task 4: Getting package dependencies

Packages are rarely installed as standalone tools, they have dependencies which are essential to their functionalities. With Yum, you can get a list of a package’s dependencies with the deplist command.

yum deplist package-name

As an example, the command below fetches a list of httpd’s dependencies:

yum deplist httpd

Below is a snippet of the result:

package: httpd.x86_64 2.4.6-80.el7.centos.1
dependency: /bin/sh
provider: bash.x86_64 4.2.46-30.el7
dependency: /etc/mime.types
provider: mailcap.noarch 2.1.41-2.el7
dependency: /usr/sbin/groupadd
provider: shadow-utils.x86_64 2:4.1.5.1-24.el7

Task 6: Getting information on package groups

Through this article, we have been looking at packages. At this point, package groups would be introduced.

Package groups are collection of packages for serving a common purpose. So if you want to set up your machine’s system tools for example, you do not have to install the packages separately. You can install them all at once as a package group.

You can get information on a package group using the groupinfo command and putting the group name in quotes.

yum groupinfo “group-name”

The command below would fetch information on the “Emacs” package group.

yum groupinfo "Emacs"

Here is the information:

Group: Emacs
Group-Id: emacs
Description: The GNU Emacs extensible, customizable, text editor.
Mandatory Packages:
=emacs
Optional Packages:
ctags-etags
emacs-auctex
emacs-gnuplot
emacs-nox
emacs-php-mode

Task 7: Listing the available package groups

In the task above, we tried to get information on the “Emacs” package. However, with the grouplist command, you can get a list of available package groups for installation purposes.

yum grouplist

The command above would list the available package groups. However, some packages would not be displayed due to their hidden status. To get a list of all package groups including the hidden ones, you add the hidden command as seen below:

yum grouplist hidden

Installing packages with YUM

We have looked at how packages can be queried with Yum. As a Linux system administrator you would do more than query packages, you would install them.

Task 8: Installing packages

Once you have the name of the package you like to install, you can install it with the install command.

yum install package-name

Example:

yum install nginx

Task 9: Installing packages from .rpm files

While you have to install most packages from the repository, in some cases you would be provided with *.rpm files to install. This can be done using the localinstall command. The localinstall command can be used to install *.rpm files either they are available on the machine or in some external repository to be accessed by a link.

yum localinstall file-name.rpm

Task 10: Reinstalling packages

While working with configuration files, errors can occur leaving packages and their config files messed up. The install command can do the job of correcting the mess. However, if there is a new version of the package in the repository, that would be the version to be installed which isn’t what we want.

With the reinstall command, we can re install the current version of packages regardless the latest version available in the repository.

yum reinstall package-name

Task 11: Installing package groups

Earlier, we looked into package groups and how to query them. Now we would see how to install them. Package groups can be installed using the groupinstall command and the name of the package group in quotes.

yum groupinstall “group-name”

Updating packages with YUM

Keeping your packages updated is key. Newer versions of packages often contain security patches, new features, discontinued features etc, so it is key to keep your computer updated as much as possible.

Task 12: Getting information on package updates

As a Linux system administrator, updates would be very crucial to maintaining the system. Therefore, there is a need to constantly check for package updates. You can check for updates with the updateinfo command.

yum updateinfo

There are lots of possible command combinations that can be used with updateinfo. However we would use only the list installed command.

yum updateinfo list installed

A snippet of the result can be seen below:

FEDORA-EPEL-2017-6667e7ab29  bugfix     epel-release-7-11.noarch

FEDORA-EPEL-2016-0cc27c9cac  bugfix     lz4-1.7.3-1.el7.x86_64

FEDORA-EPEL-2015-0977       None/Sec.    novnc-0.5.1-2.el7.noarch

Task 13: Updating all packages

Updating packages is as easy as using the update command. Using the update command alone would update all packages, but adding the package name would update only the indicated package.

yum update : to update all packages in the operating system

yum update httpd : to update the httpd package alone.

While the update command will update to the latest version of the package, it would leave obsolete files which the new version doesn’t need anymore.

To remove the obsolete packages, we use the upgrade command.

yum upgrade : to update all packages in the operating system and delete obsolete packages.

The upgrade command is dangerous though, as it would remove obsolete packages even if you use them for other purposes.

Task 14: Downgrading packages

While it is important to keep up with latest package updates, updates can be buggy. Therefore in a case where an update is buggy, it can be downgraded to the previous version which was stable. Downgrades are done with the downgrade command.

yum downgrade package-name

Removing packages with YUM

As a Linux system administrator, resources have to be managed. So while packages are installed for certain purposes, they should be removed when they are not needed anymore.

Task 15: Removing packages

The remove command is used to remove packages. Simply add the name of the package to be removed, and it would be uninstalled.

yum remove package-name

While the command above would remove packages, it would leave the dependencies. To remove the dependencies too, the autoremove command is used. This would remove the dependencies, configuration files etc.

yum autoremove package-name

Task 15: Removing package groups

Earlier we talked about installing package groups. It would be tiring to begin removing the packages individually when not needed anymore. Therefore we remove the package group with the groupremove command.

yum groupremove “group-name”

Conclusion

The commands discussed in this article are just a little show of the power of Yum. There are lots of other tasks that can be done with YUM which you can check at the official RHEL web page. However, the commands this article has discussed should get anybody started with doing regular Linux system administration tasks.

The post Primer on Yum Package Management Tool appeared first on Linux Hint.

]]>
Install Slack on Ubuntu https://linuxhint.com/install_slack_ubuntu/ Sun, 18 Nov 2018 03:28:07 +0000 https://linuxhint.com/?p=32485 In today’s world, keeping a good collaboration with your team members is quite important. A good team collaboration yields the best result in everything, especially within the professional sector. Slack is a very powerful platform for keeping all the tasks of your new startup or business. Slack is an all-in-one collaboration platform for all sizes […]

The post Install Slack on Ubuntu appeared first on Linux Hint.

]]>
In today’s world, keeping a good collaboration with your team members is quite important. A good team collaboration yields the best result in everything, especially within the professional sector. Slack is a very powerful platform for keeping all the tasks of your new startup or business. Slack is an all-in-one collaboration platform for all sizes of teams and businesses. It offers records of previous conversations, “channel” divvied up by teams, clients, project(s) and others. Slack also integrates a number of handy tools at disposal. You can also connect services like Salesforce, JIRA, Zendesk, and even your proprietary software! Let’s check out on enjoying Slack on Ubuntu.

Installing Slack

There are various ways of installing Slack on your system.

Method 1

Fire up a terminal window and run the following command –

sudo snap install slack --classic

Method 2

Get the latest DEB package of Slack.

Now, run the following commands –

sudo dpkg -i slack-desktop-3.3.3-amd64.deb
sudo apt install -f

Using Slack

After the installation is complete, start Slack –

  • Creating a workspace

Let’s create a new workspace.

At first, enter your email.

Next, enter the confirmation code from your email.

Enter your full name.

Enter your password. Choose something strong.

Next, it’s time to choose your company name.

Now, choose your favorite Slack URL that will give you direct access to your Slack workspace.

Accept the “Terms and Conditions”.

You’re free to send invitations to whoever you like.

Voila! Your workspace is ready to enjoy!

This is the original window of your Slack desktop app.

  • Adding a channel

Channels are basically certain groups that’s specified for just one type of talk, for example, “#programming” for coders only, “#testing” for program testers only discussion etc.

Click the “+” icon after the “Channels” title.

Fill up the information for creating a new channel for your Slack workspace.

  • Integrating apps

On Slack, you are also free to add a number of additional online services from other service providers like Google Drive, Dropbox, Asana, Bitbucket, GitHub, and Trello etc.

Let’s enjoy Google Drive on our Slack.

Click the “+” icon after the “Apps” title.

Clicking “Install” button next to a listed app will redirect you on a browser.

From the browser, click “Install”.

Google Drive integration is complete! Now, you have to authenticate with your Google Drive account.

Enjoy!

The post Install Slack on Ubuntu appeared first on Linux Hint.

]]>
Ubuntu Change Password https://linuxhint.com/ubuntu_change_password/ Sat, 17 Nov 2018 13:43:07 +0000 https://linuxhint.com/?p=32455 In terms of security, Linux is definitely one of the tightest. The password system is one of the most important parts. Without the password, you’re not able to access a secure system and do anything. If you allow system access without a password, it is not secure. No password, no nothing, in terms of security. […]

The post Ubuntu Change Password appeared first on Linux Hint.

]]>
In terms of security, Linux is definitely one of the tightest. The password system is one of the most important parts. Without the password, you’re not able to access a secure system and do anything. If you allow system access without a password, it is not secure. No password, no nothing, in terms of security. However, you may also need to change your password at any point. Let’s have a look at changing the password of your system.

Changing the password

This is the password that you have to enter when you’re logging into your account. This password isn’t the “root” password. Let’s fire up a terminal and run the following command –

passwd

This will prompt you to enter your current password. Then, you have to type your new password 2 times.

Changing the “root” password

The “root” is the ultimate user account for any Linux system that offers the most control over the system, even allowing access to sensitive system files and other files. For changing the “root” password, run the following command –

sudo -s
passwd

# OR

sudo passwd

Then, restart your system.

Changing password without the current “root” access

In cases, you may not be able to access to your system because you forgot the “root” password. It’s also possible to change the password without having access to the system. Restart your system.

Keep holding “Shift” to access the GRUB menu.

Press “E” for editing the startup command.

Get to the line “linux /boot”.

At the end of “ro”, type the following text –

init=/bin/bash

Press “Ctrl + X” to boot with the modified startup command. Run the following commands –

mount -o remount,rw /
passwd

Enter your new password. After password changing is successful, run the following command for restarting your system –

reboot –f


Voila! Your password is changed successfully!

The post Ubuntu Change Password appeared first on Linux Hint.

]]>
Ubuntu Change Login Screen Background https://linuxhint.com/ubuntu_login_screen_background/ Sat, 17 Nov 2018 13:30:03 +0000 https://linuxhint.com/?p=32444 Whenever you login into your computer, you’re presented with a screen asking your credential to verify that it’s you. After you enter the password, you’re in your world. Each time you log in, you have to go through this process again and again. Doesn’t it feel boring to look at the face of that same, […]

The post Ubuntu Change Login Screen Background appeared first on Linux Hint.

]]>

Whenever you login into your computer, you’re presented with a screen asking your credential to verify that it’s you. After you enter the password, you’re in your world. Each time you log in, you have to go through this process again and again. Doesn’t it feel boring to look at the face of that same, plain screen? I bet you’re pretty tired of the system’s default login screen. Well, let’s add a splash of color! Having an awesome background would really rejuvenate your desktop experience, don’t you agree? Ubuntu is the most popular Linux distro for general users, no doubt. However, over the course of its lifetime, there’s that same, BORING login screen appearing. It’s time to change that.

Changing the login screen background

Ubuntu shifted from Unity to GNOME desktop environment and GDM as login agent. By default, Ubuntu allows you to modify your desktop wallpaper and lock screen background. However, there’s no direct option available for changing the login screen background. We’ll have to dig our way through various system tweaks.

At first, make sure that you have your background image ready.

Now, fire up a terminal and run the following commands –

sudo cp ~/Desktop/mybackground.png /usr/share/backgrounds

Or, you can also use the file manager to do the task.

xhost +local: && sudo nautilus /usr/share/backgrounds/

Now, you have to edit the CSS file that defines the login background.

Xhost +local: && sudo gedit /etc/alternatives/gdm3.css

Now, find out the following section –

Change the “background” entry –

#lockDialogGroup {
background: url(file:///usr/share/backgrounds/mybackground.png);
background-repeat: no-repeat;
background-size: cover;
background-position: center; }

Save the file.

Enjoying the effect

After everything is complete, restart your system.

Voila! Enjoy the most amazing login screen backgrounds of your entire life!

The post Ubuntu Change Login Screen Background appeared first on Linux Hint.

]]>
FreeBSD Mastery: ZFS https://linuxhint.com/book_review_freebsd_mastery/ Sat, 17 Nov 2018 13:08:25 +0000 https://linuxhint.com/?p=32439 The Book 7 in the series FreeBSD Mastery is one of the most informative and engaging tech-related book I have read. FreeBSD Mastery: ZFS serves as a gateway drug to novice users who are looking to adapt OpenZFS.As the title suggests, the book is about OpenZFS on FreeBSD, but most things that you will learn […]

The post FreeBSD Mastery: ZFS appeared first on Linux Hint.

]]>
The Book 7 in the series FreeBSD Mastery is one of the most informative and engaging tech-related book I have read. FreeBSD Mastery: ZFS serves as a gateway drug to novice users who are looking to adapt OpenZFS.As the title suggests, the book is about OpenZFS on FreeBSD, but most things that you will learn in this book are applicable to any ZFS system, in general. The FreeBSD specifics that are referenced, such as GEOM storage providers, are interesting concepts on their own and won’t put you off, in my opinion. Despite being the book 7 of a series, it is pretty self-contained.

Knowledge Not Memorizing Commands

I find that most “tech books” are filled with a tonne of commands and details that one can’t ever hope to cram in his/her head. Yet authors write, expecting the users to memorize whatever is mentioned in the text.

This book from Michael Lucas and Allan Jude is anything but a boring college textbook. You can enjoy this book on bright Sunday afternoon, in a coffee shop, without having a ZFS pool to actually work on. The writing incites visual imagination in the mind of the readers. How zpools are constructed, how disks are grouped into vdevs and how various datasets can share a given zpool you will learn about it all without having to memorize anything. When in doubt, the book serves as a decent reference text as well. Although I much prefer man pages because software gets updated whereas the books stay the same.

Without overwhelming the readers with a tonne of commands and tuneable parameters, FreeBSD Mastery: ZFS imparts knowledge. After reading this book, you would know what to do when confronted with the task of creating your own zpool and zfs datasets. The trade-offs between redundancy (offered via mirroring, RAID-Z, etc) and performance (read/write speed) is discussed at length, for example.

Experience

Both the authors of this book have had years of experience with various UNIX and Linux systems before they settled down with FreeBSD. The same is true with storage devices. From spinning disks to NVMe flash and from FAT32 to FFS they have dealt with it all, so you don’t have to.

“A wise man learns from the experience of others.” and this book provides the perfect opportunity for you to do so. Michael Lucas is not only an experienced sysadmin but also a seasoned writer (he writes both fiction and non-fiction), so the book is full of witty remarks and humor, unlike other texts which are all just dry passionless documentation of a system.

A Word for New Users

If you are young enough to not know anything about the state of computing back in late 90s and early 2000s, consider yourself lucky. This was the time when both the disk technology and file systems were constantly evolving. People created abstractions like Volume Manager to represent multiple disks as a single one. Vendors manufactured disks that would report different sector size in different scenarios and so on.

A lot of unclean ways were used to manage storage arrays, not the least of which were hardware RAID controllers which are often irreplaceable and act as a single point of failure — the one thing that they were supposed to mitigate.

There are references to the older technologies, mostly about things like volume manager, RAID controller, etc. Look in the web for these words if you don’t quite get what they mean, it will provide you with a nice contrast between the way ZFS treats your disks vs how traditionally they were treated.

An Overview

With sophisticated software like OpenZFS user often worry they won’t know what to do. However, sophistication doesn’t necessarily imply complication. The question users should be asking themselves is, “How does it work?” everything else will follow naturally. It designed to be easy enough that one can use it single-handedly, you know.

The first chapter gives an overview of ZFS, its history, its purpose, a few introductory commands and how the rest of the book is arranged. The second and third chapter dive into vdevs and zpools and takes you through the thought process before you arrange and format your disks with ZFS. What type of redundancy you may want striping, mirroring, raidz, etc? How will the performance be affected? And so on. These are ZFS specific abstractions and therefore its important for the beginners to understand them straight away. Fortunately, the writing is also unambiguous and paints a clear picture of everything that happens under the hood.

Once you have arranged and formatted the disks, the chapter on datasets (‘dataset’ is another term for filesystem in ZFS lingo) follows next. Here, you get to tune parameters on a filesystem level. Reserve spaces for dataset, restricting datasets from hogging up all of the space, setting up compression, etc can be learnt in here.

The chapters that follow after this are mostly on maintenance of your zpool. How to check for errors, what to do when a disk fails, etc. There’s also a chapter dedicated to snapshots and clones which is immensely helpful and takes full advantage of ZFS’ copy-on-write functionality.

Conclusion

If you just go through the first 4 chapters that is enough for you to get started with your own ZFS setup. You can treat the rest of the book as a useful reference material for when you need to look something up. However, I doubt if you will be able to stop at just chapter 4. The writing is entertaining and incites curiosity. You will be left wanting for some more action after you are done with the book

If you really want to go down the rabbit-hole of ZFS, there’s also “FreeBSD Mastery: Advanced ZFS” which is next on my reading list. If you want something more general than just storage, check out the author’s new Absolute FreeBSD, 3rd Edition.

The post FreeBSD Mastery: ZFS appeared first on Linux Hint.

]]>
Install Etcher on Linux https://linuxhint.com/install_etcher_linux/ Fri, 16 Nov 2018 13:41:22 +0000 https://linuxhint.com/?p=32406 Etcher is a free tool for flashing microSD card with the operating system images for Raspberry Pi single board computers. The user interface of Etcher is simple and it is really easy to use. It is a must have tool if you’re working with a Raspberry Pi project. I highly recommend it. Etcher is available […]

The post Install Etcher on Linux appeared first on Linux Hint.

]]>
Etcher is a free tool for flashing microSD card with the operating system images for Raspberry Pi single board computers. The user interface of Etcher is simple and it is really easy to use. It is a must have tool if you’re working with a Raspberry Pi project. I highly recommend it. Etcher is available for Windows, macOS and Linux. So you get the same user experience no matter which operating system you’re using.

In this article, I will show you how to install and use Etcher on Linux. I will be using Debian 9 Stretch for the demonstration. But this article should work on any other Debian based Linux distributions such as Ubuntu without any modification. With slight modification, it should work on other Linux distributions as well. So, let’s get started.

Downloading Etcher for Linux:

You can download Etcher from the official website of Etcher. First, go to the official website of Etcher at https://www.balena.io/etcher/ and you should see the following page. You can click on the download link as marked in the screenshot below to download Etcher for Linux but it may not work all the time. It did not work for me.

If that is the case for you as well, scroll down a little bit and click on the link as marked in the screenshot below.

Your browser should prompt you to save the file. Just, click on Save File.

Your download should start as you can see in the screenshot below.

Installing Etcher on Linux:

Now that you have downloaded Etcher for Linux, you are ready to install Etcher on Linux.  In order to run Etcher on Linux, you need to have zenity or Xdialog or kdialog package installed on your desired Linux distribution. On Ubuntu, Debian, Linux Mint and other Debian based Linux distributions, it is a lot easier to install zenity as zenity is available in the official package repository of these Linux distributions. As I am using Debian 9 Stretch for the demonstration, I will cover Debian based distributions here only.

First, update the package repository of your Ubuntu or Debian machine with the following command:

$ sudo apt update

Now, install zenity with the following command:

$ sudo apt install zenity

Now, press y and then press <Enter> to continue.

zenity should be installed.

Now, navigate to the ~/Downloads directory where you downloaded Etcher with the following command:

$ cd ~/Downloads

As you can see, the Etcher zip archive file is here.

Now, unzip the file with the following command:

$ unzip etcher-electron-1.4.6-linux-x64.zip

The zip file should be extracted and a new AppImage file should be generated as you can see in the screenshot below.

Now, move the AppImage file to the /opt directory with the following command:

$ sudo mv etcher-electron-1.4.6-x86_64.AppImage /opt

Now, run Etcher with the following command:

$ /opt/etcher-electron-1.4.6-x86_64.AppImage

You should see the following dialog box. Just click on Yes.

Etcher should start as you can see in the screenshot below.

Now, you don’t have to start Etcher from the command line anymore. You can start Etcher from the Application Menu as you can see in the screenshot below.

Using Etcher on Linux:

You can now flash microSD cards using Etcher for your Raspberry Pi.  First, open Etcher and click on Select image.

A file picker should be opened. Now, select the operating system image file that you want to flash your microSD card with and click on Open.

The image should be selected.

Now, insert the microSD card or USB storage device that you want to flash with Etcher. It may be selected by default.  If you do have multiple USB storage devices or microSD card attached on your computer, and the right one is not selected by default, then you can click on Change as marked in the screenshot below to change it.

Now, select the one you want to flash using Etcher from the list and click on Continue.

NOTE: You can also flash multiple USB devices or microSD cards at the same time with Etcher. Just select the ones that you want to flash from the list and click on Continue.

It should be selected as you can see in the screenshot below.

You can also change Etcher settings to control how Etcher will flash the microSD cards or USB storage devices as well. To do that, click on the gear icon as marked in the screenshot below.

The Etcher settings panel is very clear and easy to use. All you have to do is either check or uncheck the things you want and click on the Back button. Normally you don’t have to do anything here. The default settings are good. But if you uncheck Validate write on success, it will save you a lot of time. Because this option will check if everything is written on the microSD cards or USB storage devices correctly. That puts a lot of stress on your microSD cards or USB devices and takes a lot of time to complete. Unless you have a faulty microSD card or USB storage device, unchecking this option would do you no harm. It’s up to you to decide what you want.

Finally, click on Flash!

Etcher should start flashing your microSD card or USB storage device.

Once the microSD card or the USB storage device is flashed, you should see the following window. You can now close Etcher and eject your microSD card or USB storage device and use it on your Raspberry Pi device.

So that’s how you install and use Etcher on Linux (Ubuntu/Debian specifically). Thanks for reading this article.

The post Install Etcher on Linux appeared first on Linux Hint.

]]>
Installing and Using AWS CLI on Ubuntu https://linuxhint.com/install_using_aws_cli_ubuntu/ Fri, 16 Nov 2018 13:13:43 +0000 https://linuxhint.com/?p=32402 AWS offers an enormous range of services and to launch even the simplest of these services require numerous steps. You will soon find that time spent on AWS console (the Web UI) is time well wasted. While I don’t condone this design and wish for something simpler, I do realize that most of us are […]

The post Installing and Using AWS CLI on Ubuntu appeared first on Linux Hint.

]]>
AWS offers an enormous range of services and to launch even the simplest of these services require numerous steps. You will soon find that time spent on AWS console (the Web UI) is time well wasted. While I don’t condone this design and wish for something simpler, I do realize that most of us are stuck with AWS because our organization chose it as their platform for one reason or another.

Instead of complaining about it, let’s try and limit our attention to a small set of services that an organization typically uses. This may be ECS, AWS Lambda, S3 or EC2. One way of doing it is by using the AWS CLI. It offers you a way to easily integrate AWS interface with your everyday work flow. Once you get over the initial hurdle of setting up the CLI and getting used to a few commands, this will save you hours and hours of time. Time that you can spend on much more pleasant activities.

Prerequisites

This tutorial assumes that you already have an AWS account. This can be an IAM user account with programmatic access issued by your organization. If you have your own personal account with AWS then do not use your AWS root credentials for the CLI! Instead create an IAM user with programmatic access for all CLI related stuff. When deciding for policy that you will attach to this new user, think about what you want to do with this account.

The most permissive policy is that of Administrative Access, which I will be using. As you create an IAM user gets assigned a username, an Access ID and a Secret ID Key. Keep the latter two confidential.

For my local environment, I will be using Ubuntu 18.04 LTS.

Installing AWS CLI

Ubuntu 18.04 LTS comes with Python 3.6 preinstalled and you can install pip package manager to go with this by running (if you wish for an apt package for the CLI, read further below for a note on that):

$ sudo apt install python3-pip

If you are running Python 2.6 or earlier, then replace python3-pip with python-pip. AWS CLI is shipped as a pip package so we will need it. Once installed use pip to install the cli.

$ pip3 install awscli

Once again, if you are using Python 2, replace pip3 with pip. If you want you can use, sudo apt install awscli to install aws cli as well. You will be a couple of revisions behind but it is fine. Once it is installed relaunch the bash session.

Configuring the Environment

Assuming you don’t have your IAM access keys, you can either ask your organization’s AWS Root user to create one for you or if you are using your own personal account and are your own root admin, then open up the IAM Console in your browser.

Go to the “Users” tab and select the User Account you want to use to access the CLI. Go to “Security Credentials” and create access key and secret access key. Never share this key with anyone, and make sure you don’t push them along with your git commits, etc.

Use these keys as the command below prompts you to enter their respective values:

$ aws configure

Output:

AWS Access Key ID [None]: ADSLKFJAASDFKLJLGA
AWS Secret Access Key [None]: lkdsfh490IODSFOIsGFSD98+fdsfs/fs
Default region name [None]: us-west-2
Default output format [None]: json

The value for access key and secret key will obviously be different in your case. When it comes to region, choose the one that is closest to you (or your users). For output JSON format is fine. Once you have entered valid information for all the values your CLI is ready to interface with the AWS remotely.

The ID and secret as well as other config parameters are stored in a subdirectory inside your home directory ~/.aws. Make sure that it doesn’t get compromised. If it does get compromised, immediately revoke the ID and associated key using the IAM Console.

To login to different machines, you can always create more of these.

Using the CLI

This is the part where you need to do go through the man pages. Fortunately, the CLI is well-documented. Each service is its own command and then various actions that you can perform using that particular service are listed under its own help section.

To illustrate this point better, let’s start with:

$ aws help

If you scroll down in the output page, you will see all the services listed:

Output:

AVAILABLE SERVICES
o acm
o acm-pca
o alexaforbusiness
o apigateway
.
.
.
o dynamodb
o dynamodbstreams
o ec2
o ecr
o ecs
o efs
o eks

Now, let’s say you want to use Amazon EC2 service to launch your EC2 instances. You explore further by going to:

$ aws ec2 help

This will get you all sorts of subcommand that you could use for creating snapshots, launching fleets of VMs, managing SSH-keys, etc. However, what your application would demand is something that is for you to decide upon. Of course, the list of commands, subcommands and, valid arguments that can be used is in fact quite long. But you probably won’t have to use every option.

Conclusion

If you are just starting out, I’d recommend begin with the console for launching various instances and managing them. This will give you a pretty good idea of what option to look for when using the CLI. Eventually, as you use more and more of the CLI, you can start writing scripts to automate the entire resources creation, management and deletion process.

Don’t force yourself into learning about it. These things take time to sink in.

The post Installing and Using AWS CLI on Ubuntu appeared first on Linux Hint.

]]>
BASH command output to the variable https://linuxhint.com/bash_command_output_variable/ Thu, 15 Nov 2018 08:16:27 +0000 https://linuxhint.com/?p=32389 Different types of bash commands need to be run from the terminal based on the user’s requirements. When the user runs any command from the terminal then it shows the output if no error exists otherwise it shows the error message. Sometimes, the output of the command needs to be stored in a variable for […]

The post BASH command output to the variable appeared first on Linux Hint.

]]>
Different types of bash commands need to be run from the terminal based on the user’s requirements. When the user runs any command from the terminal then it shows the output if no error exists otherwise it shows the error message. Sometimes, the output of the command needs to be stored in a variable for future use. Shell command substitution feature of bash can be used for this purpose. How you can store different types of shell commands into the variable using this feature is shown in this tutorial.

Command Substitution Syntax:

variable=$(command)
variable=$(command [option…] argument1 arguments2 …)
variable=$(/path/to/command)

OR

variable=`command`
variable=`command [option…] argument1 arguments2 …`
variable=`/path/to/command`

***Note: Don’t use any space before and after the equal sign when using the above commands.

Single command output to a variable

Bash commands can be used without any option and argument for those commands where these parts are optional. The following two examples show the uses of simple command substitution.

Example#1:

bash `date` command is used to show the current date and time. The following script will store the output of `date` command into $current_date variable by using command substitution.

$ current_date=$(date)
$ echo "Today is $current_date"

Output:

Example#2:

`pwd` command shows the path of the current working directory. The following script stores the output of `pwd` command into the variable, $current_dir and the value of this variable is printed by using `echo` command.

$ current_dir=`pwd`
$ echo "The current directory is : $current_dir"

Output:

Command with option and argument

The option and argument are mandatory for some bash commands. The following examples show how you can store the output of the command with option and argument into a variable.

Example#3:

Bash `wc` command is used to count the total number of lines, words, and characters of any file. This command uses -c, -w and -l as option and filename as the argument to generate the output. Create a text file named fruits.txt with the following data to test the next script.
fruits.txt

fruits.txt
Mango
Orange
Banana
Grape
Guava
Apple

Run the following commands to count and store the total number of words in the fruits.txt file into a variable, $count_words and print the value by using `echo` command.

$ count_words=`wc -w fruits.txt`
$ echo "Total words in fruits.txt is $count_words"

Output:

Example#4:

`cut` is another bash command that uses option and argument to generate the output. Create a text file named weekday.txt with seven-weekday names to run the next script.

weekday.txt

Monday
Tuesday
Wednesday
Thursday
Friday
Saturday
Sunday

Create a bash file named cmdsub1.sh with the following script.  In this script, while loop is used to read the content of weekday.txt file line by line and read the first three characters of each line by using `cut` command. After cutting, the string value is stored in the variable $day. Next, If the statement is used to check the value of $day is ‘Sun’ or not. The output will print ‘Sunday is the holiday‘ when if the condition is true otherwise it will print the value of $day.

cmdsub1.sh

#!/bin/bash
filename='weekday.txt'
while read line; do
day=`echo $line | cut -c 1-3`
if [ $day == "Sun" ]
then
echo "Sunday is the holiday"
else
echo $day
fi
done<$filename

Run the script.

$ cat weekday.txt
$ bash cmdsub1.sh

Output:

Using command substitution in loop

You can store the output of command substitution into any loop variable which is shown in the next example.

Example#5:

Create a file named cmdsub2.sh with the following code. Here, `ls -d */` command is used to retrieve all directory list from the current directory. For loop is used here to read each directory from the output and store it in the variable $dirname which is printed later.

cmdsub2.sh

#!/bin/bash
for dirname in $(ls -d */)
do
echo "$dirname"
done

Run the script.

$ bash cmdsub2.sh

Output:

Using nested commands

How you can use multiple commands using pipe(|) is shown in the previous example. But you can use nested commands in command substitution where the output of the first command depends on the output of the second command and it works opposite of the pipe(|) command.

Nested command syntax:

var=`command1 \`command\``

Example#6:

Two commands, `echo` and `who` are used in this example as the nested command. Here, `who` command will execute first that print the user’s information of the currently logged in user. The output of the `who` command will execute by `echo` command and the output of `echo` will store into the variable $var. Here, the output of `echo` command depends on the output of `who` command.

$ var=`echo \`who\``
$ echo $var

Output:

Using Command path

If you know the path of the command then you can run the command by specifying the command path when using command substitution. The following example shows the use of command path.

Example#7:

`whoami` command shows the username of the currently logged in user. By default, this command is stored in /usr/bin/ folder. Run the following script to run `whoami` command using path and store in the variable, $output, and print the value of $output.

$ output=$(/usr/bin/whoami)
$ echo $output

Output:

Using Command Line argument

You can use the command line argument with the command as the argument in the command substitution.

Example#8:

Create a bash file named cmdsub3.sh with the following script. `basename` command is used here to retrieve the filename from the 2nd command line argument and stored in the variable, $filename. We know the 1st command line argument is the name of the executing script which is denoted by $0.

#!/bin/bash
filename=`basename $1`
echo "The name of the file is $filename."

Run the script with the following argument value.

$ bash cmdsub3.sh Desktop/temp/hello.txt

Here, the basename of the path, Desktop/temp/hello.txt is ‘hello.txt’. So, the value of the $filename will be hello.txt.

Output:

Conclusion:

Various uses of command substitutions are shown in this tutorial. If you need to work with multiple commands or depended commands and store the result temporary to do some other tasks later then you can use this feature in your script to get the output.

More info in the video:

The post BASH command output to the variable appeared first on Linux Hint.

]]>
Working with Raspberry Pi 3 GPIO with Python https://linuxhint.com/raspberry_pi_gpio_python/ Tue, 13 Nov 2018 11:26:21 +0000 https://linuxhint.com/?p=32371 Raspberry Pi is a single board computer that runs on Linux. It is mainly used for IoT (Internet of Things) projects. As it is very cheap, people also use it to learn about computers and programming.  Raspberry Pi has GPIO (General Purpose Input Output) pins used for controlling or interacting with electronic components and integrated […]

The post Working with Raspberry Pi 3 GPIO with Python appeared first on Linux Hint.

]]>
Raspberry Pi is a single board computer that runs on Linux. It is mainly used for IoT (Internet of Things) projects. As it is very cheap, people also use it to learn about computers and programming.  Raspberry Pi has GPIO (General Purpose Input Output) pins used for controlling or interacting with electronic components and integrated circuits. You can use Python programming language for interacting with the components connected to the GPIO pins of Raspberry Pi.

The version of Raspberry Pi I have is Raspberry Pi 3 Model B. It has 40 GPIO pin header and not all of them can be used for interacting with other electronic components. You will have to hook up your electronic components to the right pin number. Otherwise, you won’t be able to interact or control the electronic component connected to your Raspberry Pi. I will refer you to a diagram that you can use to find out which pin to use for what purpose. Don’t worry about it.

In this article, I will make a simple LED blinking project with Raspberry Pi using the GPIO pins. I will show you how to use Python to interact with the GPIO pins of Raspberry Pi. I will use Raspberry Pi 3 Model B for the demonstration as this is what I have. If you’re using another version of Raspberry Pi, then you may have to make necessary changes for it to work. So, let’s get started.

Things You Need:

To successfully build the Raspberry Pi LED blinking project with me, you need,

  • A Raspberry Pi 3 single board computer.
  • A microSD card with Raspbian OS flashed.
  • A micro USB adapter or Android phone charger for powering up Raspberry Pi.
  • A computer with internet connectivity and for connecting to the Raspberry Pi remotely.
  • A 220Ω or 1KΩ resistor.
  • A 5mm or 3mm LED.
  • Some male to female connecting wires.
  • A breadboard.

Circuit Diagram:

You should connect all the components to your Raspberry Pi 3 as shown in the circuit diagram below.

On breadboard it looks something like this.

Note that I connected one end of the resistor to the GPIO0 which is PIN 11 on Raspberry Pi 3, and one end of the red LED to the GND (ground) pin which is PIN 6 on the Raspberry Pi 3.

Connecting to the Raspberry Pi 3 Remotely:

If you own a Raspberry Pi and use Raspbian, then you most likely have SSH and VNC enabled already. If you’ve followed one of my articles on how to install Raspbian on Raspberry Pi, then you should know how to enable them. If you are in doubt on whether these are enabled, please read the article at (Link of the article Install Raspbian on Raspberry Pi).

If you prefer to work with the command line, then SSH into your Raspberry Pi 3 with the following command:

$ ssh pi@192.168.2.16

If you prefer to work graphically, use VNC Viewer to connect to your Raspberry Pi 3. Just type in the IP address of your Raspberry Pi and press <Enter>.

Now, type in pi as the username and the password that you set up while installing Raspbian as the password. Then click on OK.

You should be connected.

Writing Codes for the Raspberry Pi Blink LED Project:

First, open up a Terminal (if you’re using VNC Viewer) and create a new file blink.py

Now, open blink.py with a text editor (I will use nano) as follows:

$ nano blink.py

Now, type in the following lines of Python codes and save the file by pressing <Ctrl> + x and then press y followed by <Enter>.

Here, on line 1, I imported the the Python RPi.GPIO from the RPi library to work with the GPIO pins of Raspberry Pi.

On line 2, I imported the Python time and time library.

On line 4-6, I defined 3 variables.

  • ledPin variable is set to the pin number 11. This is where the red LED is connected to the Raspberry Pi 3.
  • blinkDelay is set to 5, which is 500ms. So, the LED will be on for 500ms and then off for 500ms and again on for 500ms and so on.
  • ledOn variable is set to True by default. When it’s True, the LED will be on, when it’s false, the LED will be off. ledOn logic is switched from True to False and False to True every 500ms (as defined in blinkDelay).

Line 9 is used to set up the GPIO pin ledPin which is pin 11 for output using the GPIO.setup() library function. GPIO.setup() accepts two arguments. One is the pin number, and the other is the mode at which this pin will work. In this case, it is GPIO.OUT or output mode. If you want to take inputs, then it should be GPIO.IN.

On line 11-19, a try-except block is used. So, when I stop the Python script, it will print the text Thanks for using blink.py (line 19) instead of error messages. I also made sure the GPIO pin is cleaned up in line 18 with GPIO.cleanup() library function.

The actual code for the Blink project is in line 12-16. Here, an infinite loop is used.

At each iteration of the loop,

  • Line 13 prints the status of the LED (whether it’s on or off) depending on logic of the ledOn
  • Line 14 uses the output() library function to either turn on or off the LED (in ledPin pin) depending on the logic of ledOn variable.
  • Line 15 is used to switch the logic value of ledOn
  • Finally, on line 16, sleep() library function is used to keep the LED on or off for blinkDelay time.

Once you’re done writing the code, run blink.py script with the following command:

$ python blink.py

As you can see, the LED statuses are being displayed every 500ms.

As you can see, the LED is blinking every 500ms.

[Include the video file in files/output.3gp]

If you want to stop the blink.py script, just press <Ctrl> + c.

As you can see, the script execution has stopped.

Raspberry Pi 3 Model B GPIO Pinouts:

You can find the Raspberry Pi 3 Model B GPIO pinouts at http://pi4j.com/pins/model-3b-rev1.html

Be sure to check it out.

So, that’s how you work with the GPIO pins of Raspberry Pi 3 with Python. Thanks for reading this article.

The post Working with Raspberry Pi 3 GPIO with Python appeared first on Linux Hint.

]]>
Install Plex on Raspberry Pi 3 https://linuxhint.com/install_plex_raspberry_pi/ Tue, 13 Nov 2018 11:15:31 +0000 https://linuxhint.com/?p=32340 Plex is a media server. You can store Movies, TV shows, Music etc on your local storage and stream them across all your devices on your home. It has a nice web based user interface for managing and streaming your media files.In this article, I will show you how to install Plex media server on […]

The post Install Plex on Raspberry Pi 3 appeared first on Linux Hint.

]]>
Plex is a media server. You can store Movies, TV shows, Music etc on your local storage and stream them across all your devices on your home. It has a nice web based user interface for managing and streaming your media files.In this article, I will show you how to install Plex media server on Raspberry Pi 3. I will be using Raspberry Pi 3 Model B for the demonstration. But it should work on Raspberry Pi 3 Model B+ as well. So, let’s get started.

Things You Need:

To successfully install Plex media server, you need,

  • A microSD card (16GB or more) with Raspbian OS image flashed.
  • A Raspberry Pi 3 single board computer.
  • A self-powered USB hard drive or large enough USB thumb drive for storing media files.
  • Internet connectivity on the Raspberry Pi using either Wi-Fi or LAN cable.
  • Raspberry Pi configured to connect to it remotely via either SSH or VNC Viewer.
  • An Android phone charger for powering up Raspberry Pi.

I’ve written articles on installing Raspbian on Raspberry Pi and enabling SSH and VNC on Raspberry Pi. Be sure to check them out here on LinuxHint.com if you need to.

Connecting to Raspberry Pi:

First, connect all the required components to your Raspberry Pi and power it up.

Now, to connect to your Raspberry Pi remotely via SSH, run the following command:

$ ssh pi@IP_ADDR_RPI

NOTE: Here, replace IP_ADDR_RPI with the IP address of your Raspberry Pi.

You can also connect to your Raspberry Pi via VNC if you want to interact with it graphically. To do that, you need to download and install VNC Viewer from RealVNC (https://www.realvnc.com/en/connect/download/viewer/).

Once you get it installed, just type in the IP address of your Raspberry Pi and press <Enter>.

Now, type in your credentials and click on OK.

You should be connected.

Mounting External Hard Drive or USB Thumb Drive:

Before you go any further, it’s a good time to mount the USB self-powered external hard drive or USB thumb drive on your Raspberry Pi 3 device.

First, insert the hard drive or USB thumb drive on your Raspberry Pi 3 single board computer.

If you’re using the Standard Raspbian OS (comes with graphical desktop environment), then the device should automatically be mounted. But if you’re using the minimal version of Raspbian, then it may not be the case. You will have to manually mount the storage device or block device.

If you’re using Raspbian minimal, first create a mount point (let’s say /media/pi/Media) with the following command:

$ sudo mkdir -p /media/pi/Media

Now, mount the external hard drive or USB thumb drive to /media/pi/Media as follows:

$ sudo mount /dev/sda1 /media/pi/Media

If you reboot your Raspberry Pi, then you will have to do these steps again. If you want it to mount your external hard drive or USB thumb drive automatically, then you can do so using the /etc/fstab file.

Just edit /etc/fstab file and add the following line to the end of the file.

/dev/sda1 /media/pi/Media vfat defaults 0 0

Here, vfat is the filesystem type. vfat is compatible with the FAT filesystem on Windows.

If you want, you can use other filesystems. I prefer vfat/FAT filesystem as it is compatible with Windows, Mac, Linux and Android. So you can add media files to your external hard drive from every device you have on your house.

Installing Plex on Raspberry Pi 3:

Now that you can connect to your Raspberry Pi remotely, let’s install Plex media server on it.

First, open up a Terminal and update the APT package repository cache with the following command:

$ sudo apt update

Now, install apt-transport-https package with the following command:

$ sudo apt install apt-transport-https -y

It may already be installed as in my case. If not, it will be installed.

Plex media server is not available in the official package repository of Raspbian. So, you have to install it from a third-party package repository Dev2Day.de.

Now, add the GPG key of the Dev2Day.de package repository with the following command:

$ wget -O - https://dev2day.de/pms/dev2day-pms.gpg.key | sudo apt-key add -

The GPG key should be added.

Now, add the Dev2Day package repository with the following command:

$ echo "deb https://dev2day.de/pms/ stretch main" |
sudo tee /etc/apt/sources.list.d/pms.list

Now, update the APT package repository cache again as follows:

$ sudo apt update

The APT package repository cache should be updated.

Now, install Plex media server with the following command:

$ sudo apt-get install plexmediaserver-installer

Plex media server is being installed.

Plex media server should be installed.

Accessing Plex Media Server:

Now that Plex media server is installed, you can access it from the web browser.

Open a web browser and visit http://IP_ADDR_RPI:32400/web

NOTE: Change IP_ADDR_RPI to the IP address of your Raspberry Pi.

You should be redirected to the following page. Here, you have to login to the Plex media server.

Once you’re logged in, click on GOT IT!.

Now, set up a name for your Plex media server and click on NEXT.

Now, you can add media files to your library. To do that, click on ADD LIBRARY.

Now, select the type of media that you want to add, type in a name and language and finally, click on NEXT.

Now, click on BROWSER FOR MEDIA FOLDER to select a directory where your external hard drive or USB thumb drive is mounted.

A file picker should show up. Just select the folder where you media files are located and click on ADD.

You can also click on the Advanced tab and configure some options for your media library. Once you’re done, click on ADD LIBRARY.

The library should be added as you can see. You can add as many libraries as you want. Once you’re done, click on NEXT.

Now, you should see the following page. You can click on GET PLEX APPS to download Plex application that runs natively on your computer or mobile devices. If you don’t want to do that, you can still access Plex media server from the web. Once you’re done, click on DONE.

Once you’re done, you should see the Plex media server dashboard as in the screenshot below. I have no media on my external hard drive at the moment, so it shows nothing. But it should list all the media files from your hard drive or USB thumb drive in a nicely formatted way here.

So, that’s how you install Plex media server on Raspberry Pi 3. Thanks for reading this article.

The post Install Plex on Raspberry Pi 3 appeared first on Linux Hint.

]]>
Install Raspbian on Raspberry Pi https://linuxhint.com/install_raspbian_raspberry_pi/ Mon, 12 Nov 2018 17:14:46 +0000 https://linuxhint.com/?p=32306 Raspberry Pi is an ARM based single board computer. Raspbian is a Debian based GNU/Linux distribution for Raspberry Pi. It is the officially supported and recommended operating system for Raspberry Pi devices.  In this article, I will show you how to install Raspbian OS on Raspberry Pi. I will be using Raspberry Pi 3 Model […]

The post Install Raspbian on Raspberry Pi appeared first on Linux Hint.

]]>
Raspberry Pi is an ARM based single board computer. Raspbian is a Debian based GNU/Linux distribution for Raspberry Pi. It is the officially supported and recommended operating system for Raspberry Pi devices.  In this article, I will show you how to install Raspbian OS on Raspberry Pi. I will be using Raspberry Pi 3 Model B for the demonstration as that’s what I have. But the procedures shown here should work for other versions of Raspberry Pi as well. So, let’s get started.

Things You Need:

To follow this article, you need the following components:

  • A Raspberry Pi 2 or Raspberry Pi 3 single board computer.
  • A microSD card (16 GB or more) for flashing Raspbian.
  • A HDMI cable and a monitor as a Display for Raspberry Pi.
  • A USB keyboard and a USB mouse for input.
  • A computer with internet connection for downloading and flashing Raspbian.
  • A good quality Android phone charger with micro USB cable for powering up Raspberry Pi.

Downloading Raspbian OS:

You can download Raspbian from the official website of Raspberry Pi.  First, Go to the download page of Raspbian at https://www.raspberrypi.org/downloads/raspbian/

Once the page loads, scroll down a little bit and you should see the section as marked in the screenshot below. There are two versions of Raspbian you can download from the official website of Raspberry Pi.  The Raspbian Lite image does not have any desktop environment pre-installed. The Raspbian with Desktop has a desktop environment pre-installed. Raspbian Lite image is smaller than Raspbian with Desktop image. You can download any one of these images depending on your need.

To download Raspbian OS image, just click on the Download ZIP button of the Raspbian OS version you need as shown in the screenshot below.

Your download should start. It may take a while to complete.

Flashing Raspbian on micoSD Card:

To flash Raspbian OS image to the microSD card, I am going to use Etcher in this article. Etcher is available to download and use for free on Windows, Mac and Linux. It is one of the best tool for flashing microSD card for Raspberry Pi. You can download Etcher from the official website of Etcher at https://www.balena.io/etcher .  If you’re using Linux, then it is out of the scope of this article to show you how to install Etcher on Linux. I will have a separate article on that. So, keep an eye on LinuxHint.com.

Anyway, once Etcher is installed, insert the microSD card on your computer and open Etcher.

Now, click on Select image as marked in the screenshot below.

A file picker should be opened. Now, select the Raspbian OS image that you just downloaded and click on Open.

Now, click on Select drive.

Now, select the microSD card device that you want to flash Raspbian OS image on and click on Continue.

Now, click on Flash! As marked in the screenshot below.

The microSD card is being flashed…

Once the microSD is flashed, you should see the following window. Now, eject the microSD card from your computer.

Setting Up Raspberry Pi and Booting into Raspbian:

Now,

  • Insert the microSD card on your Raspberry Pi.
  • Connect one end of the HDMI cable of your monitor to your Raspberry Pi.
  • Connect the USB keyboard and USB mouse on Raspberry Pi.
  • Connect the micro USB charger cable to your Raspberry Pi.

Finally, power on your Raspberry Pi and you should see the following window. Raspberry pi is booting.

Within a few seconds, Raspbian should be booted. As you’re using Raspbian for the first time, you will have to configure Raspbian. So, click on Next.

Now, select your country, language and time zone using the dropdown menu. Once you’re done, click on Next.

Now, type in the password that you would like to set on your Raspbian OS. Once you’re done, click on Next.

Now, you can connect to a Wi-Fi network if you want. The Wi-Fi network in your area should show up in the list. My Wi-Fi SSID is hidden, so it’s not showing up here. Besides, I will connect to internet using LAN cable anyway, so I don’t need Wi-Fi at the moment.

Once you have configured the network, you should see the following window. If you want to keep the software packages of your Raspberry Pi up to date, then click on Next. Otherwise, click on Skip.

Your Raspberry Pi should be ready. Finally, click on Done.

The Raspbian OS’s desktop environment.

Enabling SSH and VNC:

You may not want to use an external monitor every time you want to work with your Raspberry Pi. You can connect to your Raspberry Pi remotely using SSH or VNC. You should use SSH if you prefer to work on the command line. If you prefer to work using the graphical desktop environment, then enable VNC as well.

First, open the Raspberry Pi Configuration app as shown in the screenshot below.

Raspberry Pi Configuration app should be opened. Now, click on Interfaces.

Now, make sure SSH and VNC are Enabled as marked in the screenshot below. Then, click on OK.

SSH and VNC should be enabled.

When VNC is enabled, the marked logo should be displayed on the top bar of Raspbian OS.

Finding Out the IP Address Of Raspberry Pi:

Now, open up a Terminal as follows:

Now, to find out the IP address of your Raspberry Pi, run the following command:

$ ip a

The configured IP addresses should be listed. As you can see, my Raspberry Pi 3 Model B got the IP address 192.168.2.15 using DHCP on its LAN interface.

Remotely Connecting to Raspberry Pi using SSH and VNC:

Now that you know the IP address of your Raspberry Pi, you can connect to it remotely using SSH or a VNC Client software.  Remember, the default username of Raspberry Pi is pi and the password is the one that you set earlier while configuring Raspberry Pi.

To connect to your Raspberry Pi using SSH, you can run the following command from another computer:

$ ssh pi@192.168.2.15

To connect to your Raspberry Pi’s graphical desktop environment using VNC protocol, you can use VNC viewer app.

You can download VNC Viewer from the official website of RealVNC at https://www.realvnc.com/en/connect/download/viewer

So, that’s how you install Raspbian on Raspberry Pi. Thanks for reading this article.

The post Install Raspbian on Raspberry Pi appeared first on Linux Hint.

]]>
du Command on Linux https://linuxhint.com/du_command_linux/ Mon, 12 Nov 2018 16:34:26 +0000 https://linuxhint.com/?p=32289 Every Linux distro comes up with a number of tools integrated into the system. Each of the tools has their own purposes. “du” is such a tool that’s part of the standard Unix/Linux. This tool is used for getting info on disk usage and directories on machines. There are a number of available parameters that […]

The post du Command on Linux appeared first on Linux Hint.

]]>
Every Linux distro comes up with a number of tools integrated into the system. Each of the tools has their own purposes. “du” is such a tool that’s part of the standard Unix/Linux. This tool is used for getting info on disk usage and directories on machines. There are a number of available parameters that you can use for getting results in many formats. Here are some of the most useful commands of “du”.

“du” examples

  • Need to find out the disk usage summary of a directory? Run the following command –
  • du ~/Downloads/

In the output, the first column is the disk usage amount and the second column is the list of files present in that directory.

The first column shows the number of disk blocks the corresponding file is occupying.

  • Need the output in a format that human can understand? Use the “-h” option. It tells the “du” to show output in “Human Readable Format”.
  • du -h ~/Downloads

  • Use “-a” flag for displaying the disk usage of all the files and directories.
  • du -a -h ~/Downloads/

As you’ve noticed, you can use multiple flags together with “du”.

  • For identifying just how much disk space is a directory consuming, use “-s” flag.
  • du -sh ~/Downloads

  • You can also use the “-c” flag for getting the total size of the directory at the last line of the output.
  • du -ch ~/Downloads/

  • Need to check out the last time of file modification? You have to use “–time” flag.
  • du -ha --time ~/Downloads/

  • Are you interested in excluding specific file types, for example, MP4 or PDF? Then use the “–exclude=PATTERN” parameter.
  • du -ha --exclude=*.svg ~/Downloads/

More “du” commands

“du” offers a huge collection of features. You can find out all of them using the man page for “du”.

man du

Every time you need help, you don’t have to open up a terminal and run the command again. You can dump the guide into a text file. Run the following command –

man du > ~/Desktop/du.txt

Enjoy!

The post du Command on Linux appeared first on Linux Hint.

]]>
Install Ubuntu MATE on Raspberry Pi https://linuxhint.com/install_ubuntu_mate_raspberry_pi/ Mon, 12 Nov 2018 04:00:05 +0000 https://linuxhint.com/?p=32252 Ubuntu MATE is a lightweight Linux distribution that features the MATE desktop environment. Ubuntu MATE can be installed on Raspberry Pi 2 and Raspberry Pi 3. It is a great alternative to the Raspbian operating system that is widely used on Raspberry Pi devices. In this article, I will show you how to install Ubuntu […]

The post Install Ubuntu MATE on Raspberry Pi appeared first on Linux Hint.

]]>
Ubuntu MATE is a lightweight Linux distribution that features the MATE desktop environment. Ubuntu MATE can be installed on Raspberry Pi 2 and Raspberry Pi 3. It is a great alternative to the Raspbian operating system that is widely used on Raspberry Pi devices.

In this article, I will show you how to install Ubuntu MATE on Raspberry Pi. I am using Raspberry Pi 3 Model B for the demonstration. But the procedures are the same for any model of Raspberry Pi 2 and Raspberry Pi 3 single board computers. So, let’s get started.

Things You Need:

To follow this article, you need,

  • A Raspberry Pi 2 or Raspberry Pi 3 single board computer.
  • A microSD card (16GB or more).
  • Internet connectivity.
  • A computer for downloading and flashing Ubuntu MATE on the microSD card.
  • A HDMI cable and a monitor.
  • A good quality Android phone charger for powering up Raspberry Pi.
  • A USB keyboard and a USB mouse.

Downloading Ubuntu MATE for Raspberry Pi:

At the time of this writing, Ubuntu MATE has support for Raspberry Pi 2 and Raspberry Pi 3.

To download the Ubuntu MATE image for Raspberry Pi 2 or Raspberry Pi 3, go to the official website of Ubuntu MATE at https://ubuntu-mate.org/download/

When the page loads, click on Raspberry Pi architecture as marked in the screenshot below.

At the time of this writing, you can only install Ubuntu MATE 16.04 (Xenial Xerus) on Raspberry Pi 2 and Raspberry Pi 3. Click on the Ubuntu MATE 16.04.2 (Xenial) icon as marked in the screenshot below.

Now, click on the download link as marked in the screenshot below.

As you can see, the download has started. It should take a while to finish.

Flashing Ubuntu MATE to microSD Card:

You can flash Ubuntu MATE image to the microSD card very easily using Etcher. Etcher is available for Windows, Mac and Linux. It is free to download and use. You can download Etcher from the official website of Etcher at https://www.balena.io/etcher/

Once you download and install Etcher, you’re good to go.

First, insert the microSD card on your computer and open Etcher. Now, click on Select image.

A file picker should be opened. Now, select the Ubuntu MATE image that you just downloaded and click on Open.

Now, click on Select drive.

Now, select the microSD card from the list and click on Continue.

Now, click on Flash!.

Etcher should start copying all the necessary data on your microSD card. It may take a while to complete.

Once your microSD card is flashed, you will see the following window. Just close it and eject the microSD card from your computer.

Setting Up the Raspberry Pi and Booting into Ubuntu MATE:

Now you have to connect all the necessary components to your Raspberry Pi before you turn it on.

  • First, insert the microSD card on your Raspberry Pi.
  • Now, connect the HDMI cable to your Raspberry Pi.
  • Then, connect the USB keyboard and mouse to your Raspberry Pi.

Finally, connect the micro USB cable of your Android phone charger to you Raspberry Pi and power it on.

Fig: My Raspberry Pi 3 Model B after connecting all the components.

Your Raspberry Pi should boot as you can see in the screenshot below.

You should also see the Ubuntu MATE logo as follows.

The first time you boot into Ubuntu MATE, you should be presented with the System Configuration window as you can see in the screenshot below.

First, select your language and click on Continue as marked in the screenshot below.

Now, you can connect to your Wireless network (Wi-Fi) from here. If you don’t want to connect to your Wi-Fi network now, select I don’t want to connect to a wi-fi network right now and click on Continue.

Now, select your location and click on Continue.

Now, select your keyboard layout and click on Continue.

Now, type in your personal information and click on Continue.

As you can see, Ubuntu MATE is being configured…

The changes are being saved…

Once the configuration is saved, your Raspberry Pi should reboot. After a while, a login window should show up as you can see in the screenshot below.

Just type in the credentials and click on Log In.

Once you’re logged in, you should see the Ubuntu MATE welcome screen.

As you can see, I am running MATE desktop environment version 1.16.1.

The output of the lsb_release command:

As you can see, Ubuntu MATE on my Raspberry Pi 3 Model B is using only 261.9MB of RAM.

My Thoughts on Ubuntu MATE on Raspberry Pi:

If you want to install Ubuntu on your Raspberry Pi devices, you can go with Ubuntu Core, which is Ubuntu made specially for IoT projects. But the problem is, on Ubuntu Core, you can only install SNAP packages. There are not too many SNAP packages available. For example, if you want to set up a basic graphical desktop environment, then you can’t do it on Ubuntu Core.

So, if you like the traditional APT package manager and want to use a wide range of software available in the official Ubuntu package repository on your Raspberry Pi, then Ubuntu MATE is a great alternative. On Ubuntu MATE for Raspberry Pi, you get the APT package manager just like you have on your Ubuntu desktop. You don’t have to learn anything new here if you’ve already used Ubuntu before.

On Ubuntu MATE for Raspberry Pi, the Wi-Fi, Bluetooth drivers are pre-installed and works out of the box. Most of the things you need for your Raspberry Pi projects are included on Ubuntu MATE by default.

The MATE desktop environment is very responsive on Raspberry Pi 3 Model B, the one I have. I really like it. I tried different operating systems on my Raspberry Pi 3 Model B, and among them I found Ubuntu MATE to be the best.

So, that’s how you install Ubuntu MATE on your Raspberry Pi single board computer. Thanks for reading this article.

The post Install Ubuntu MATE on Raspberry Pi appeared first on Linux Hint.

]]>
How to Add and Remove PPA on Ubuntu https://linuxhint.com/add_remove_ppa_ubuntu/ Mon, 12 Nov 2018 03:25:56 +0000 https://linuxhint.com/?p=32237 If you’re using Ubuntu, you’re already familiar with the software repository. It’s a HUGE collection of all the necessary tools Ubuntu needs to run. The repository is always kept up-to-date with the latest versions of the software.  However, you’re already aware that all the software aren’t present in the repository. There are a number of […]

The post How to Add and Remove PPA on Ubuntu appeared first on Linux Hint.

]]>
If you’re using Ubuntu, you’re already familiar with the software repository. It’s a HUGE collection of all the necessary tools Ubuntu needs to run. The repository is always kept up-to-date with the latest versions of the software.  However, you’re already aware that all the software aren’t present in the repository. There are a number of essential tools that you need to get from other sources. Even after grabbing those apps, you have to make sure that they are up-to-date.  For solving this issue, Ubuntu features a great method – PPA.

What PPA is

A PPA (Personal Package Archive) is a special software repository that allows the APT (Advanced Packaging Tool) to automatically grab a specific software from that repository.  PPA offers an easier method of getting the latest software without any delay. All you have to do is command “apt” to upgrade your system. Most of the world’s PPAs are hosted on Launchpad. However, there are a number of private PPAs hosted on different sites.

How to add a PPA

At first, find out what PPA you need to add. For adding a PPA, it’s the easiest to use the terminal command. The command uses the following structure –

sudo add-apt-repository ppa:abc/xyz

Let’s have a quick breakdown of each part of the command.

  • sudo – Running the command with “root” privilege.
  • add-apt-repository – The tool for adding the PPA.
  • ppa:abc/xyz – The repository code.

For this example, we’ll be using the uGet official PPA.

Run the following command –

sudo add-apt-repository ppa:plushuang-tw/uget-stable

Installing the software

Now, your system is ready to get your target software. However, make sure that your “apt” repository database is up-to-date with the latest addition of the above PPA.

sudo apt update

Install uGet –

sudo apt install uget

Voila! uGet is installed!

Removing the PPA

If you don’t need a PPA anymore, it’s best to remove it from your system.

  • Method 1

The best way of removing a PPA is through the command.

Run the following command –

sudo add-apt-repository --remove ppa:plushuang-tw/uget-stable

Don’t forget to update your “apt” database cache –

sudo apt update

  • Method 2

You can also remove the PPA using the GUI method.

From the menu, search for “software”.

Open Software & Updates.

Open the “Other Software” tab.

Here, you’ll find out all the PPAs you added in your system over the lifetime.

Select the unwanted PPA(s) and hit “Remove”.

When closing, make sure that you reload the software repository database of “apt”.

Voila! PPA is removed!

Enjoy!

The post How to Add and Remove PPA on Ubuntu appeared first on Linux Hint.

]]>
Bash jq command https://linuxhint.com/bash_jq_command/ Sun, 11 Nov 2018 10:49:43 +0000 https://linuxhint.com/?p=32209 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 […]

The post Bash jq command appeared first on 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.

jq installation

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 "${JsonData}" | 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 "${JsonData}" | jq -'.[]'

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.

$ jq ‘.’ Students.json

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.

[ 40,34,12,67,45]

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.

$ jq '.[:4]' 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.

The post Bash jq command appeared first on Linux Hint.

]]>
Nginx Reverse Proxy https://linuxhint.com/nginx_reverse_proxy/ Sun, 11 Nov 2018 05:35:51 +0000 https://linuxhint.com/?p=32195 What is a reverse proxy? A proxy server is the one that talks to the Internet on your behalf. For example, if your college’s network has blocked https://www.facebook.com/ but the domain  https://exampleproxy.com is still accessible, then you can visit the latter and it will forward all your requests for Facebook servers to Facebook, and send […]

The post Nginx Reverse Proxy appeared first on Linux Hint.

]]>
What is a reverse proxy?

A proxy server is the one that talks to the Internet on your behalf. For example, if your college’s network has blocked https://www.facebook.com/ but the domain  https://exampleproxy.com is still accessible, then you can visit the latter and it will forward all your requests for Facebook servers to Facebook, and send by the responses from Facebook back to your browser.

To recap, a proxy sends requests on behalf of one of more clients to any servers out in the Internet. A reverse proxy behaves in a similar fashion.

A reverse proxy receives request from any and all clients on behalf of one or more servers. So if you have a couple of servers hosting ww1.example.com and ww2.example.com a reverse proxy server can accept requests on behalf of the two servers, forward those requests to their respective end points where the response is generated and sent back to the reverse proxy to be forwarded back to the clients.

The set up

Before we start tweaking Nginx config files and make a reverse proxy server. I want to set in stone what my setup looks like, so when you are trying to implement your design you, it would be less confusing.

I used DigitalOcean’s platform to spin up three VPS. They are all on the same network each with its own Private IP, and only one VPS has a static public IP (This will be our reverse proxy server.)

VM/Hostname Private IP Public IP Role
Reverseproxy 10.135.123.187 159.89.108.14 Reverse proxy, running Nginx
Node-1 10.135.123.183 N/A Running first website
Node-2 10.135.123.186 N/A Running second website

The two different websites that are running have domain names ww1.ranvirslog.com and ww2.ranvirslog.com and both of their A records point to the reverseproxy’s public IP, i.e, 159.89.108.14

The idea behind private IP is that, the three VMs can talk to one another via this private IP, but a remote user can only access the reverse proxy VM at its Public IP. This is important to keep in mind. For example, you can’t ssh into any of the VM using its Private IP.

Furthermore, both Node-1 and Node-2 have an Apache web server serving two distinct webpages. This will help us distinguish one from another.

The first website says “WEBSITE 1 WORKS!!!”

Similarly, the second website shows this:

Your websites may differ, but if you want to replicate this setup as a starting point, run apt install apache2 on Node-1 and Node-2. Then edit the file /var/www/html/index.html so that the web server says whatever you want it to say.

The reverseproxy VM is still untouched. All the VMs are running Ubuntu 18.04 LTS, but you are free to use any other OS that you want. You can even emulate this using Docker containers. By creating a user-defined Docker bridge network and spawning containers on it, you can assign each container a private IP and forward all the HTTP/HTTPS proxy to one container, which would be our Nginx reverse proxy container.

So far so good.

Nginx Default Configuration

Let’s begin by installing Nginx to the reverseproxy server, I am using Ubuntu so apt is my package manager:

$ sudo apt install nginx

Removing default configuration if you are using Debian-based distribution

Before we go any further a small note on Nginx’s configuration. All the various configuration files are stored in /etc/nginx including the nginx.conf file which is the main configuration file. If we look at the contents of this file (inside http block) you will notice the following two lines:

...
include /etc/nginx/conf.d/*.conf;
include /etc/nginx/sites-enabled/*;
...

The second line includes all the files in the sites-enabled directory to the Nginx’s configuration. This is the standard practice on most Debian-based distributions. For example the default “Welcome to Nginx” webpage has a corresponding file named default at the location /etc/nginx/sites-available/default with a symlink to /etc/nginx/sites-enabled/, but we don’t need this default webpage so we can safely remove the symlink. The original is still available at sites-available directory.

$ rm /etc/nginx/sites-enabled/default

But when we will create reverse proxy configuration we will do so in conf.d directory (with our file name having a .conf extension) this is universal, and works across all distributions not just Debian or Ubuntu.

Removing default configuration for other distros

If you are not using Debian-based distro, you will find the default Welcome Page configuration at /etc/nginx/conf.d/default.conf just move the file to some place safe if you want to use it in the future (since this is not a symlink)

$ mv /etc/nginx/conf.d/default.conf ~/default.conf

It can sometimes be found in /etc/nginx/default.d because people just can’t agree upon a single simple standard! So you would have to do a bit of digging in the /etc/nginx directory, to figure this out.

Adding Reverse Proxy Blocks

As stated before, the two different domain names I am hosting behind this proxy are

  1. ranvirslog.com (WEBSITE 1) with IP 10.135.123.183
  2. ranvirslog.com (WEBSITE 2) with IP 10.135.123.186

So let’s create one file per website in /etc/nginx/conf.d/ folder. So we are well-organized.

$ touch /etc/nginx/conf.d/ww1.conf
$ touch /etc/nginx/conf.d/ww2.conf

You can name the files whatever you wish, as long as it has a .conf at the end of its name.

In the first file ww1.conf add the following lines:

server {
listen 80;
listen [::]:80;
 
server_name ww1.ranvirslog.com;
 
location / {
proxy_pass http://10.135.123.183/;
proxy_buffering off;
proxy_set_header X-Real-IP $remote_addr;
}
}

The listen statements tells Nginx to listen on port 80 for both IPv4 and IPv6 cases. It then checks if the server_name is ww1.ranvirslog.com then the location block kicks in and proxies the request to http://10.135.123.183/ with buffering turned off. Moreover, the proxy_set_header…line ensures that the client’s original IP is forwarded to the proxied server. This is helpful in case you want to calculate the number of unique visitors, etc. Otherwise the proxied server would have only one visitor — the Nginx server.

The buffering option and set_header options are completely optional and are just added to make the proxying as transparent as possible. For the ww2.ranvirslog.com website, I added the following configuration at /etc/nginx/conf.d/ww2.conf:

server {
listen 80;
listen [::]:80;
 
server_name ww2.ranvirslog.com;
 
location / {
proxy_pass http://10.135.123.186/;
proxy_buffering off;
proxy_set_header X-Real-IP $remote_addr;
}
}

Save both the files and test whether the overall configuration is valid or not:

$ sudo nginx -t

If there are errors, the output of the above command will help you find and fix them. Now restart the server:

$ service nginx restart

And you can test whether it worked or not by visiting the different domain names in your browser and seeing the result.

Conclusion

Each individual’s use case is different. The configuration mentioned above may need a bit of tweaking to work for your scenario. Maybe you are running multiple servers on the same host, but at different ports, in that case the proxy_pass… line will have http://localhost:portNumber/ as its value.

These details depend very much on your use case. For further details about other options and tuneables see the official Nginx docs.

The post Nginx Reverse Proxy appeared first on Linux Hint.

]]>
Create your own Ubuntu Server on Google Cloud Platform https://linuxhint.com/ubuntu_server_google_cloud/ Sun, 11 Nov 2018 04:59:52 +0000 https://linuxhint.com/?p=32177 Google Cloud Platform offers a number of services ranging from App Engine, fully managed Kubernetes, Database as a Service, Function as a Service, Object store and much more. It is easy enough to get overwhelmed by all the functionalities, each as attractive as other. The Google Cloud Platform dashboard, in my opinion, doesn’t make it […]

The post Create your own Ubuntu Server on Google Cloud Platform appeared first on Linux Hint.

]]>
Google Cloud Platform offers a number of services ranging from App Engine, fully managed Kubernetes, Database as a Service, Function as a Service, Object store and much more. It is easy enough to get overwhelmed by all the functionalities, each as attractive as other. The Google Cloud Platform dashboard, in my opinion, doesn’t make it any easier for the user, either!

Sometimes, all we need is a simple VM. Despite the uprising of containers, VMs are still useful and simple. You don’t have to worry about giving your application permissions for a different Database service, an object store service etc. Everything from compute to storage can be contained within a single (scalable) VM.

In this post, let’s dive into how one can spin up a Ubuntu server in Google’s Cloud Platform.

Google Compute Engine (GCE)

GCE is the product that actually lets you configure and deploy virtual machines on Google’s infrastructure. Everything from the amount of resources to the networking capabilities, SSH-keys and Operating system are selected herein.

Login to your Google Cloud Platform dashboard, and search for GCE. At once Compute Engine will show up in the results, click on it.

Here’s an overview of Compute Engine:

As you can see, the side menu has a lot of options for managing your VMs and monitoring them. We will stick to VM instances for now. Since this lets us create a single VM. If you wish to create a group of them “Instance groups” might serve you better.

Let’s start by clicking on Create, as shown in the screenshot above.

A VM template with all the default values provided by Compute Engine will appear. Let’s configure a few of the defauls. I’ll leave the CPU to 1 vCPU and memory to 3.75 GB as those values are good enough for a demo. If you want more/less resources for optimal price and performance, feel free to tweak these parameters.

First thing I will tweak is the boot disk. We want Ubuntu, so, under boot disk, click on Change and select Ubuntu 18.04 LTS. This disk will have the OS installed and the remaining space is what you will use for your application, packages, etc. (unless you are adding extra block storage). So if you want more storage than the default 10GB, make sure to increase the size, as shown below.

Moreover, for better performance you can select SSD persistent disk. This is a significant improvement over standard persistent disk. Once the boot disk is selected to be Ubuntu, we can just create the VM and have a Ubuntu server installed in the cloud for us.

However, let’s configure, for convenience sake, Firewall and SSH keys.

If you wish to host an HTTP or HTTPS server, make sure to check the boxes saying “Allow HTTP Traffic” and “Allow HTTPS Traffic”. Most websites would need this, and so would most API servers, reverse proxy servers, etc. As for the Identity and API access parameters are concerned, you can leave that to default.

Now click on “Management, security, disks…” section to access more customization features. Within this dropdown go to Security and you can paste your public ssh key in here. The username within the key will also be created inside the VM. For example, the key

ssh-ed25519
AAAAC3NzaC1lZDI1NTE5AAAAIH31mVjRYdzeh8oD8jvaFpRuIgL65SwILyKpeGBUNGOT ranvir

Will create a user named ranvir with sudo access and place the SSH key within this user’s home directory (~/.ssh/authorized_keys) so you can access the VM remotely.

We are almost done. Review the monthly estimated price this VM will cost you as well as the region where it will be spun up, by scrolling all the way up again. Regions are a subjective, but important parameter. For someone trying to create a VPN, a VPN several time zones away is better suited. On the other hand, if you require lower latencies, you need to select a region nearest to you.

Then click on create and you have your Ubuntu VM up and running!

Post Configuration

In order to make sure that you can ssh into the VM reliably as well as point domain names to this VM, you would need a static public IP address. If you view the Compute Engine dashboard, you will see the status of your VM along with its external (public) IP.

But if you click on the VM’s name (instance-1 in my case) then you will notice that the IP is, in fact, ephemeral.

This means trouble, especially if you are using external domain name servers to point your FQDN towards this IP address. To change this to static, click on Edit, from the top menu. Scroll back to network interfaces (nic0, in our case) and edit it.

Click on Ephemeral under the External IP and select Create IP address.

It will open up a dialogue box asking you for a name to give to this new static IP.  Give it a reasonable name and click Reserve. You will notice that the external IP of the VM has indeed changed and, hopefully, for the last time.

You can now try to ssh into this VM via its external IP. Remember the username that was associated with your public SSH key? Just use that along with the static IP you obtain, like in my case it would be:

$ ssh ranvir@104.196.196.61

Your username and IP would be very different from mine, use those instead.

Next steps

When it comes to computation, automation is the name of the game. VMs are often created as a disposable entity in the cloud, especially if you just want to use them for a few hours of testing, or running batch processes, etc.

Now that you know how to create a VM using the GUI, try automating the process using the gcloud CLI or the REST API. Whatever actions you perform on the Compute Engine GUI, an equivalent HTTP request or gcloud command is available in the bottom of the page.

Use them to automate the tedious process of spinning up VMs. This will help you save an enormous amount of time.

The post Create your own Ubuntu Server on Google Cloud Platform appeared first on Linux Hint.

]]>