How to Pass Arguments to a Bash-Script

You can write a bash script such that it receives arguments specified when the script is called from the command line. This method is used when a script has to perform a slightly different function depending on the values of input parameters (the arguments).

For example, you may have a script called “stats.sh” that performs a particular operation on a file, such as counting its words. If you want to be able to use that script on many files, it is best to pass the file name as an argument, so that you can use the same script for all the files to be processed.

Source: How to Pass Arguments to a Bash-Script (Lifewire)

How to Install and Configure Postfix as a Send-Only SMTP Server on Ubuntu 16.04

Introduction

Postfix is a mail transfer agent (MTA), an application used to send and receive email. In this tutorial, we will install and configure Postfix so that it can be used to send emails by local applications only — that is, those installed on the same server that Postfix is installed on.

Why would you want to do that?

If you’re already using a third-party email provider for sending and receiving emails, you do not need to run your own mail server. However, if you manage a cloud server on which you have installed applications that need to send email notifications, running a local, send-only SMTP server is a good alternative to using a 3rd party email service provider or running a full-blown SMTP server.

In this tutorial, you’ll learn how to install and configure Postfix as a send-only SMTP server.

Source: How to Install and Configure Postfix as a Send-Only SMTP Server on Ubuntu 16.04 (Digital Ocean)

Keep local Instant Messages on your local network with BeeBEEP (Secure Lan Messenger)

When you want to send an instant message to someone else that’s on the same local network as you are, whether that be another family member or a co-worker in your office, why use an offsite chat server that leaves your messages open to interception by the company running the chat server or some other third party? This software will allow you to keep your local IM’s in your local network, and for added safety it also encrypts them! Plus, it supports multiple operating systems, unlike the proprietary chat client that might have come with your computer. It’s NOT for chatting with people elsewhere on the internet; if you need to set up secure connections with offsite chat clients then you may need to set up a private Prosody IM server. But for secure IM chats with people on your local network, this looks like just the thing!

What is BeeBEEP?

BeeBEEP is an open source, peer to peer, lan messenger developed by Marco Mastroddi. You can talk and share files with all the people inside your local area network such of an office, home or internet cafe. You don’t need a server, just download, unzip and start it. Simple, fast and secure.

Main Features:

  • Free: BeeBEEP is free and always will be.
  • Multiple OS: there are releases for Windows, MacOSX, Linux, OS/2 and eComStation.
  • Easy to use: BeeBEEP is a serverless application. Download, unzip and start.
  • Secure: encryption based on Rijndael Algorithm (AES).
  • Instant Messaging: chat with all people connected, group or single user.
  • Groups: create your favorite group of people.
  • P2P: send or share your files and folders (also by drag and drop).
  • Offline messages: messages will be delivered to offline users when they will be online.
  • Message History: all messages can be saved.
  • Source: BeeBEEP (Secure Lan Messenger)

    How to Use SSH Pipes on Linux

    Like most commands on Linux, SSH can be used with input/output redirection via | (Unix Pipe). SSH can be used with this pipeline too. The basic concept here is understanding how the Unix pipeline works.

    When you understand the way pipes work, you can get seriously creative. This article covers what happens when you combine Unix pipes and SSH. It should be noted that since Unix pipes can be just about anything, there are no doubt going to be commands not on this list would also be useful.

    NOTE: Among other things, this article shows how to do remote hard drive backup and restoration, by creating an image (.img file) of a hard drive on a remote system, assuming that you have sufficient space on the remote backup drive for the image file.

    Source: How to Use SSH Pipes on Linux

    Series on Bash Scripts from Like Geeks

    Like Geeks recently published an interesting series on writing Bash shell scripts:

    Today we are going to talk about bash script or shell scripting actually, they are called shell scripts in general but we are going to call them bash scripts because we are going to use bash among the other Linux shells. There are zsh, tcsh , ksh and other shells, you can review the basic Linux commands before starting on bash script programming.

    Source: Bash Script Step By Step, You will love it

    In the previous post, we talked about how to write a bash script. And we’ve seen how bash scripting is awesome. In this post, we continue to look at structured commands that control the flow of your shell scripts. You’ll see how you can perform repeating processes; this post demonstrates for loop, while in bash scripts

    Source: Bash scripting the awesome guide Part2

    Today we will know how to retrieve input from the user and deal with that input so our script becomes more interactive.

    Source: Linux bash scripting the awesome guide part3

    On the previous post we’ve talked about parameters and options in detail and today we will talk about something is very important in shell scripting which is input & output & redirection.

    Source: Shell scripting the awesome guide part4

    On the last post, we’ve talked about input and output and redirection in bash scripting. Now you start building some Linux bash scripts, you may wonder how to run and control them on your Linux system. The only way we’ve run scripts is directly from the command line interface in real-time mode. This isn’t the only way to run Linux bash scripts in Linux.

    Source: Linux bash scripting the awesome guide part5

    If you get tired writing the same blocks of code over and over in your bash script. It would be nice to just write the block of code once and refer to that block of code anywhere in your bash script without having to rewrite it.

    The bash shell provides a feature allowing you to do just that called Functions.

    Bash functions are blocks of script code that you assign a name to and reuse anywhere in your code. Anytime you need to use that block of code in your script, you simply use the function name you assigned it.

    We are going to talk about how to create your own bash functions and how to use them in other shell scripts.

    Source: Bash scripting the awesome guide part6 Bash functions

    On the previous post we’ve talked about bash functions and how to use it from the command line and we’ve seen some other cool stuff I recommend you to review it, Today we will talk about a very useful tool for string manipulation called sed, sed Linux command is one of the most common tools that people use to work with text files like log files, configuration files, and other text files. If you perform any type of data manipulation in your bash scripts, you want to become familiar with the sed and gawk tools in this post we are going to focus on sed Linux command and see its ability to manipulate text which is very important step in our bash scripting journey

    Source: 31+ Examples for sed Linux command in text manipulation

    On the previous post we’ve talked about sed Linux command and we’ve seen many examples of using it in text processing and how it is good in this, nobody can deny that sed is very handy tool but it has some limitations, sometimes you need a more advanced tool for manipulating data, one that provides a more programming-like environment giving you more control to modify data in a file more robust. This is where awk command comes in.

    The awk command or GNU awk specifically because there are many extensions for awk out there takes stream editing one step further than the sed editor by providing a programming language instead of just editor commands.

    Source: 30 Examples for awk command in text processing

    In order to successfully working with the Linux sed editor and the awk command in your shell scripts you has to understand regular expressions or in short regex and to be accurate in our case it is bash regex, since there are many engines for regex you can use and we here in this regex tutorial will use the shell regex and see the bash power in working with regex.

    First, we need to understand what regex is then we will dive deep into using it

    Source: Regex tutorial for Linux

    In the last post, we’ve talked about regex and we see how to use them in sed and awk for text processing and we discussed before Linux sed command and awk command. During the series, we write small shell scripts but we didn’t mix things up, I think we should take a small step and write a shell script that can be some useful.

    The main reason for learning to write a shell script is to be able to create your own Linux utilities. Understanding how to write useful and practical scripts is important.

    However, sometimes it helps to do something fun to learn a concept or skill. The scripts in this post they can be lots of fun! And they help empower your script writing concepts.

    Source: How to write practical shell script

    In the previous post we’ve talked about writing practical shell scripts and we’ve seen how it is easy to write a shell script and we’ve used most of our knowledge we’ve discussed on the previous posts, today we are going to talk about a tool that does magic to our shell scripts,that tool is expect command or expect programming language.  Expect command or expect programming language is a language that talks with your interactive programs or scripts that require user interaction for input. Expect works by expecting input, and upon receiving the expected input, the Expect script will send the response without any user interaction, just like magic.

    Source: Expect command and how to automate shell scripts like magic

    Linux iptables Firewall Simplified Examples

    In the previous post, we’ve talked about how to Secure Linux Server Using Hardening Best Practices and some people ask me about firewall section which was a brief introduction about iptables firewall. Today we will discuss in detail the Linux iptables firewall and how to secure our servers traffic using that awesome tool.

    Source: Linux iptables Firewall Simplified Examples – Like Geeks

    How to Boot Up Raspberry Pi 3 from External Hard Disk

    Raspberry Pi is built to boot up and run from the SD card. This tutorial shows you the steps to boot up and run Raspberry Pi from an external hard disk.

    Source: How to Boot Up Raspberry Pi 3 from External Hard Disk – Make Tech Easier
    Related article: How to boot from a USB Mass Storage Device on a Raspberry Pi 3 – Raspberry Pi Documentation

    An Introduction to Useful Bash Aliases and Functions

    The more time you spend on the Linux command line, the more you will begin to realize that you tend to use the same commands, parameters, and sequences repeatedly. Luckily, bash allows you to create aliases and and bash functions to help reduce typing

    Source: An Introduction to Useful Bash Aliases and Functions | DigitalOcean