Article Categories
- All Categories
-
Data Structure
-
Networking
-
RDBMS
-
Operating System
-
Java
-
MS Excel
-
iOS
-
HTML
-
CSS
-
Android
-
Python
-
C Programming
-
C++
-
C#
-
MongoDB
-
MySQL
-
Javascript
-
PHP
Bash Articles
Found 20 articles
Bash Function in Linux
Have you ever wondered how to accelerate your daily Linux system administration tasks in an efficient and simpler way? If yes, then you might probably heard that Bash (Your Daily Linux Shell) and as any interpreter out there has a lot which can be used to automate various Linux-related tasks. In this tutorial, we will explain how to use one of the built-ins in Bash (Functions) to get your task quickly done. Table of Contents What are Bash Functions? Benefits of using Bash Functions Getting started with ...
Read MoreHow to Create a File in Linux from the Command Line?
Before getting into the ways of creating a file using Bash, let's first understand how Linux treats its files. Linux organizes all its data into files and files are organized into directories. Further, the directories are organized into tree-like structures called the file system. When you have to work in a Linux environment, you would definitely have to spend a lot of your time working on different types of files. There are several different ways in which one can create a file in Linux. You can create a file from the Bash Shell or you can use the Desktop File ...
Read MoreHow to Get the IP Address of a Machine From Bash?
IP address stands for Internet Protocol address, which is a unique string of numbers assigned to each device connected to a computer network that uses the Internet Protocol for communication. A system needs an IP address for various networking tasks in Linux, like setting up network connections, configuring services like file sharing, SSH or FTP or troubleshooting network-related issues, etc. An IP address can be classified into two main categories, public and private. A public IP address usually can be accessed from the Internet, whereas private addresses are reserved for internal use within your private network without being directly exposed. ...
Read MoreHow to Convert an Image to Grayscale From Bash?
Converting images to grayscale is a common image processing task that can be easily accomplished using command-line tools in Bash. This tutorial will show you several methods to convert images to grayscale using popular image manipulation utilities. Using ImageMagick ImageMagick is one of the most powerful and widely used command-line tools for image manipulation. Before you can use it, you must install it on your system. In Ubuntu, you can install it using apt as − # Debian/Ubuntu $ sudo apt install imagemagick # RedHat/CentOS $ sudo dnf install ImageMagick After installation, here are some of the methods ...
Read MoreHow to Add File Extension to Files From Bash?
In an operating system, file extensions usually help identify file types and ensure proper handling by applications. When working with files in a Unix-like operating system including Linux, you may encounter situations where files sometimes lack extensions, making it difficult to identify their types or open them with the appropriate applications. Fortunately, Bash, the default shell on many Linux distributions, provides powerful tools to simplify the process of adding file extensions. This tutorial will guide you through various options that you can use to add file extensions to files using Bash. Adding File Extension using the mv Command The simplest ...
Read MoreHow to Use Comments in Bash Scripts?
Bash script is a language that has multiple functionalities and capabilities, and as a programmer, keeping track of and remembering all the language syntax, especially if it's not your day-to-day language, is hard. For this purpose, we use comments, which allow us to simplify and demonstrate what a part of the code does. Writing comments is not necessary or obligatory, but it's a good practice, and here's why we use comments in code − Remember the code − Sometimes you write code and forget it for some time. When you come back, you might not remember why you wrote ...
Read MoreHow to install Python in Ubuntu?
Python is a powerful, open-source and easy to learn programming language. It is one of the most popular modern programming languages with a huge community of developers and extensive documentation. It usually comes pre-installed on all latest Linux systems as it is one of the building blocks of many operating system tools. Though, based on user requirement, one can install specific version of Python from available sources. In this tutorial, we will show you two ways to install Python on an Ubuntu system − Installing Python using package manager (apt) Installing Python using its source code Using Package ...
Read MoreConditional Statements in Bash Script
Bash script, like other programming languages, has features such as if statements, loops, and other useful constructs that make the language powerful and versatile. One of the most important concepts to understand when working with bash, or on the path to mastering bash scripting, is conditional statements. Conditional statements allow us to execute certain code or operations based on a given condition. In this tutorial, we will learn how to use if statements in bash scripts with examples and explanations. What is a Conditional Statement? In general, a conditional statement allows us to perform an action based on the value ...
Read MoreHow to Run Bash Commands from a File?
Bash script is a scripting language like other languages that have an extension and a way to interpret it. To interact with the operating system through the command line, commands are used. There are a lot of commands on Linux, and new commands are added regularly. However, all these commands have a common way of working. All commands consist of three parts: the command itself, its parameters, and arguments. Bash Script File A bash script file is a file that contains a sequence of commands put together to do a certain task. If you have a lot of commands, it ...
Read MoreHow to Run a Bash Script as Daemon?
Sometimes, we need to run an automated process, and for this, we use a script that runs continuously in the background. These types are called "daemons" in Linux. These daemons allow us to run independently from the terminal session. This means that the script will keep running even if we close the session. In this tutorial, we will go through how we can turn a bash script into a daemon. What is a Daemon? A daemon is just a program or process that runs in the background continuously without needing any interaction from the user. In your day-to-day Linux tasks, ...
Read More