How to Fix “sudo unable to open read-only file system” Error

How to Fix “sudo unable to open read-only file system” Error

The post How to Fix “sudo unable to open read-only file system” Error first appeared on Tecmint: Linux Howtos, Tutorials & Guides .

The Linux filesystem is a built-in layer that manages how files are stored and retrieved on a Linux system and other storage devices. It provides

The post How to Fix “sudo unable to open read-only file system” Error first appeared on Tecmint: Linux Howtos, Tutorials & Guides.

Mastering Text Manipulation With the Sed Command

Mastering Text Manipulation With the Sed Command
by George Whittaker

The Linux command line interface provides a wealth of tools for text processing, and one of the most powerful among them is the sed command. Sed, an abbreviation for Stream EDitor, is a versatile tool that allows for complex manipulation of text files and streams​​.

What is Sed?

Sed is a non-interactive text editor that operates on piped input or text files. By providing it with instructions, you can make it modify and process text in files or streams. The most common use cases of sed include operations like selecting text, substituting text, modifying an original file, adding lines to text, or deleting lines from the text. It can be used from the command line in Bash and other command-line shells​.

Sed Command Syntax

The syntax of the sed command comprises three main parts:

  1. Options: These control the output of the command.
  2. Script: This contains a list of commands to run.
  3. Input file: This is the file you’re using the sed command on.

In the absence of a filename, the script operates on the standard input data. You can also run the sed command without any options. The basic syntax looks like this:

sed OPTIONS [SCRIPT] [INPUTFILENAME]​​

Sed Vs. Awk

Sed isn’t the only text processing tool in the Linux ecosystem. Another powerful utility is awk. While both of them work with text, they have some key differences:

  • Sed excels at parsing and transforming text in a compact and simple language, making it simple and limited but easy to use.
  • Awk, on the other hand, is a tool for text processing and writing potent programs in the form of statements. It’s complex, versatile, and more powerful than sed, but also more complicated to use​​.

Exploring Sed with Examples

Let’s dive deeper into the workings of sed with some practical examples. For all these examples, assume that we have a file called ik.txt. Note that sed does not alter the original file by default. All changes will appear in the output, but the original file will remain unmodified.

Substituting Text

One of the most common operations in sed is text substitution. This is done using the s command. For example, to replace the first instance of a pattern abc with another pattern def, use:

sed s/abc/def/ ik.txt

Here, only the first instance of abc in each line is substituted with def. If you want to replace the third instance of a pattern, you can use:

sed s/abc/z/3 ik.txt

Global Substitutions

In a global substitution, all instances of a pattern are replaced. This is achieved by appending g to the substitute command. To replace all instances of abc with XYZ, use:

5 Node.js Managers To Install Multiple Node.js Versions

5 Node.js Managers To Install Multiple Node.js Versions

The post Node.js Version Managers – Install and Run Multiple Node.js Versions first appeared on Tecmint: Linux Howtos, Tutorials & Guides .

Node.js version managers, also known as “environment managers” are tools that enable developers or system administrators to install and manage several Node.js versions on their

The post Node.js Version Managers – Install and Run Multiple Node.js Versions first appeared on Tecmint: Linux Howtos, Tutorials & Guides.

Multipass - Run Virtual Ubuntu Instances in Linux

Multipass – Run Virtual Ubuntu Instances in Linux

The post Multipass – Launch and Run Virtual Ubuntu Instances in Linux first appeared on Tecmint: Linux Howtos, Tutorials & Guides .

Multipass is a cross-platform, lightweight Ubuntu virtual machine (VIM) manager that runs on Linux, Windows, and macOS. It builds cloud-style Ubuntu VMs, allowing developers to

The post Multipass – Launch and Run Virtual Ubuntu Instances in Linux first appeared on Tecmint: Linux Howtos, Tutorials & Guides.

Linux Lite - An Ubuntu-Based Distribution for Linux Newbies

Linux Lite – An Ubuntu-Based Distribution for Linux Newbies

The post Linux Lite – A Beginner-Friendly Linux Distribution for Windows Users first appeared on Tecmint: Linux Howtos, Tutorials & Guides .

Linux Lite is a free, easy-to-use, and open-source Linux distribution based on the Ubuntu LTS series of releases. By design, it is a lightweight and

The post Linux Lite – A Beginner-Friendly Linux Distribution for Windows Users first appeared on Tecmint: Linux Howtos, Tutorials & Guides.

8 Best Lightweight Linux Distributions For Older Computers

8 Best Lightweight Linux Distributions For Older Computers

The post 8 Best Lightweight Linux Distributions For Older Computers first appeared on Tecmint: Linux Howtos, Tutorials & Guides .

Lightweight Linux distributions share similar characteristics with their desktop-oriented counterparts. They give us the best of both worlds but with a slightly modified user experience.

The post 8 Best Lightweight Linux Distributions For Older Computers first appeared on Tecmint: Linux Howtos, Tutorials & Guides.

The Power of the Select Command to Automate Tasks in Bash

The Power of the Select Command to Automate Tasks in Bash
by George Whittaker

Introduction

The select command in Linux is a versatile tool primarily used for menu creation in bash scripts. The command retrieves data from a specified list, which can be an array or other data source, and generates a menu from this data. Depending on the complexity of your task, you can create various types of menus such as a menu based on directory list or even a menu derived from file content.

Basic Syntax

The basic syntax of the select command is as follows:

select v in data_list

do

statement1

statement2

statement3

done 

Here, each menu item is created from the data_list. The data retrieved from this list is stored in a variable to create the menu. You can also use the select command with the case command to create more complex menus.

Creating a Simple Menu

In a simple scenario, you might want to create a menu of mobile brands. You can easily achieve this by creating a bash file with the select command. After executing the script, the user will see a menu of brands and be asked to choose one. The name of the selected brand will then be printed on the screen​.

Using Select Command with a Case Statement

To create a bash menu with a case statement, you can use the select command in conjunction with a case statement. After running the script, the user selects any menu item, and the case statement will match the selected value with its cases. If none of the case values matches the selected menu item, the script will print an “Invalid entry” message and terminate​.

Creating Nested Bash Menus

The select command can also be used to create nested menus. This involves creating a menu under another menu. You can implement nested menus using two or more select and case statements. In this case, the parent menu contains multiple items and a sub-menu contains additional items. When a user selects an item, the script will display the corresponding message or submenu​.

Creating a Bash Menu with an Array

Arrays in bash can store multiple data points, making them an excellent data source for creating bash menus. You can use an array with the select statement to create a menu. In this scenario, a bash subroutine is used to create a menu from the array. The script will check if the selected menu item number is within the appropriate range. If it’s not, the script will prompt the user to select a number within the valid range​.

How to Fix “E: Unable to locate package” Error on Ubuntu

How to Fix “E: Unable to locate package” Error on Ubuntu

The post 5 Ways to Fix “E: Unable to locate package” Error on Ubuntu first appeared on Tecmint: Linux Howtos, Tutorials & Guides .

Sometimes, when installing a package on Ubuntu using the APT package manager, you might bump into the error “E: Unable to locate package“. This might

The post 5 Ways to Fix “E: Unable to locate package” Error on Ubuntu first appeared on Tecmint: Linux Howtos, Tutorials & Guides.

How to Fix SSH Permission Denied (Public key) Error

How to Fix SSH Permission Denied (Public key) Error

The post How to Fix SSH Permission Denied (Public key) Error in Linux first appeared on Tecmint: Linux Howtos, Tutorials & Guides .

SSH, an acronym for Secure Shell, is a remote protocol that is widely used to make remote connections to servers, network devices, and other remote

The post How to Fix SSH Permission Denied (Public key) Error in Linux first appeared on Tecmint: Linux Howtos, Tutorials & Guides.

Install Google Chrome on Ubuntu [Using PPA and DEB]

Install Google Chrome on Ubuntu [Using PPA and DEB]

The post Install Google Chrome on Ubuntu, Debian and Linux Mint first appeared on Tecmint: Linux Howtos, Tutorials & Guides .

Google Chrome Browser developed by Google Inc. is a freeware web browser licensed under Google Chrome Terms of Service. As per Wikipedia (as of February

The post Install Google Chrome on Ubuntu, Debian and Linux Mint first appeared on Tecmint: Linux Howtos, Tutorials & Guides.

How to Install Ubuntu Restricted Extras Package

How to Install Ubuntu Restricted Extras Package

The post How to Install Ubuntu Restricted Extras first appeared on Tecmint: Linux Howtos, Tutorials & Guides .

Ubuntu Restricted Extras is a software bundle for the Ubuntu operating system that allows users to install software that isn’t currently included for ethical or

The post How to Install Ubuntu Restricted Extras first appeared on Tecmint: Linux Howtos, Tutorials & Guides.

How to Install Google Chrome on Linux Desktops

How to Install Google Chrome on Linux Desktops

The post How to Install Google Chrome in Linux [RHEL-based Distros] first appeared on Tecmint: Linux Howtos, Tutorials & Guides .

Google Chrome is a most popular, fast, secure, and easy-to-use free cross-platform web browser developed by Google, and was first released in 2008 for Microsoft

The post How to Install Google Chrome in Linux [RHEL-based Distros] first appeared on Tecmint: Linux Howtos, Tutorials & Guides.

8 Cut Command Examples [Cut Parts of Lines in File]

8 Cut Command Examples [Cut Parts of Lines in File]

The post 8 Cut Command Examples [Cut Sections of Line in File] first appeared on Tecmint: Linux Howtos, Tutorials & Guides .

As Linux users, we interact with the text files on a regular basis. One of the common operations we perform on these files is text

The post 8 Cut Command Examples [Cut Sections of Line in File] first appeared on Tecmint: Linux Howtos, Tutorials & Guides.

How to Install and Configure VNC Server in CentOS and RHEL

How to Install and Configure VNC Server in CentOS and RHEL

The post How to Install and Configure VNC Server in CentOS and RHEL first appeared on Tecmint: Linux Howtos, Tutorials & Guides .

In this guide, we’ll explain how to install and configure VNC Remote Access in CentOS 7/8 and RHEL 9/8/7 desktop edition via the tigervnc-server program

The post How to Install and Configure VNC Server in CentOS and RHEL first appeared on Tecmint: Linux Howtos, Tutorials & Guides.

RedHat vs Debian: Administrative Point of View

RedHat vs Debian: Administrative Point of View

The post RedHat vs Debian: Administrative Point of View in 2023 first appeared on Tecmint: Linux Howtos, Tutorials & Guides .

There are countless Linux distributions available, a vast majority are free to download and use. Some are more appropriate for performing particular tasks than others.

The post RedHat vs Debian: Administrative Point of View in 2023 first appeared on Tecmint: Linux Howtos, Tutorials & Guides.

How to Permanently Disable Swap in Linux

How to Permanently Disable Swap in Linux

The post How to Permanently Disable Swap Partition in Linux first appeared on Tecmint: Linux Howtos, Tutorials & Guides .

Swapping or swap space represents a physical memory page that lives on top of a disk partition or a special disk file used for extending

The post How to Permanently Disable Swap Partition in Linux first appeared on Tecmint: Linux Howtos, Tutorials & Guides.

How to Test Network Speed Using iPerf3 Tool in Linux

How to Test Network Speed Using iPerf3 Tool in Linux

The post iPerf3 – Test Network Speed/Throughput in Linux first appeared on Tecmint: Linux Howtos, Tutorials & Guides .

iperf3 is a free open-source, cross-platform command-line-based program for performing real-time network throughput measurements. It is one of the most powerful tools for testing the

The post iPerf3 – Test Network Speed/Throughput in Linux first appeared on Tecmint: Linux Howtos, Tutorials & Guides.

How to Delete a Large Directory with Files in Linux

How to Delete a Large Directory with Files in Linux

The post How to Delete Large Directory with Thousands of Files in Linux first appeared on Tecmint: Linux Howtos, Tutorials & Guides .

File management is one of the common tasks that a user undertakes on a Linux system, which includes creating, copying, moving, modifying, and deleting files

The post How to Delete Large Directory with Thousands of Files in Linux first appeared on Tecmint: Linux Howtos, Tutorials & Guides.