Linuxopsys Profile picture
Oct 8 56 tweets 17 min read Twitter logo Read on Twitter
If you want to learn Linux bash scripting for FREE, open this: Image
1. What is Shell in Linux

In this guide, let's learn about the shell which is an important part of the Linux operating system which interprets and passes the commands you provide on your keyboard to the operating system to perform some specific tasks

linuxopsys.com/topics/what-is…
Image
2. Bash variable assignment

A variable is a named storage location in a program's memory where a value can be stored, retrieved, and manipulated. Like any programming language, Variables are an essential component in the Bash scripts.

linuxopsys.com/topics/assign-…
Image
2. Bash let with Examples

In bash, all variables are treated as strings. You cannot perform arithmetic operations on variables as you would normally do in other programming languages since bash interprets them as strings. To overcome this, bash has a built-in tool named let.
Using the let command, you can declare a variable and perform arithmetic operations during the assignment.

linuxopsys.com/topics/bash-le…
Image
3. Bash expr with Examples

As we know bash variables are of string data type, performing arithmetic operations aren’t straightforward. However, bash provides us with several utilities to carry out arithmetic evaluations. One such command line tool is expr.
Using the expr command, you can evaluate any given expression and display the result on the standard output.

linuxopsys.com/topics/bash-ex…
Image
4. Bash Division Explained

We cannot divide numbers directly in Bash as they would be treated as strings. However, Bash provides a lot of tools and commands to perform arithmetic division.
In this guide, we are going to learn about different ways to divide with variables. We will also focus on the advantages and limitations of some of the commonly used methods. Furthermore, we will learn how to round the result of division

linuxopsys.com/topics/bash-di…
Image
5. Bash readarray with Examples

In every programming language, the term array means a collection of items that holds some data. The data would be in an indexed manner.
The unique property bash array is that it can save different types of elements. In this tutorial, we are going to learn about readarray.

linuxopsys.com/topics/bash-re…
Image
6. Loop through lines in a file using bash loops

The most efficient way to process any file, one line at a time, is to develop a bash script and give the file as input to the script. This can be done by reading a file line by line by iterating the lines over a loop.
Bash treats each line as an element in a list. Understanding how to process the contents of a large data file one line at a time saves us from constantly opening them. There are many ways of reading each line using Bash.

linuxopsys.com/topics/bash-lo…
Image
7. Bash Modulo (Division Remainder)

Many times we are only interested in what the remainder is. The mod operator finds use in generating random numbers within a specific range and formatting program output.
It can even be used to generate prime numbers, check if a number is odd or even. Modulo turns up often in the majority of the numerical computations.

In this article, we will learn about the modulus operations in bash.

linuxopsys.com/topics/bash-mo…
Image
8. Bash While Read Line by Line

When it comes to text processing or filtering logs, it becomes important to read the contents line by line. Using the bash while loop you can read the contents one line at a time and use it as per our needs.
We can read from a file, a command and from a variable. We can even read lines into multiple variables.

linuxopsys.com/topics/bash-wh…
Image
9. Bash shift Command

Does your script accept a variable number of arguments? To easily process each argument, bash has shift command.
The command allows you to shift the positional parameters passed to a script.

In this tutorial, we learn about bash shift command with examples.

linuxopsys.com/topics/bash-sh…
Image
10. 4 Ways to Check Which Shell You are Using on Linux

Out of the box, Linux provides a wide variety of shells. There is bash (Bourne Again shell) shell which ships by default in many Linux distributions.
We also have sh (Bourne Shell), tcsh (TC shell), csh (C shell), Zsh (Z shell) and ksh (Korn Shell).
Curious to know which shell you are using on your Linux system? In this guide, we explore different ways that you can use to check which shell you are currently using in Linux.

linuxopsys.com/topics/check-w…
Image
11. Understanding Different Types of Shells in Linux

n the Linux realm, there are multiple shells available, each with its own unique features and capabilities to cater to the varying needs and also preferences of the user.
For instance, the Bourne shell (sh) offers a minimalist set of features for shell scripting, while the Z shell (zsh) offers some advanced ones such as extended globbing and spelling correction.
Therefore, choosing the shell can be subjective based on the task at hand and the specific requirements.

Although it's not necessary to learn all shells, acquiring knowledge on multiple ones can be necessary to improve efficiency....
(one shell for scripting and the other for interactive use) and to increase functionality (taking advantage of the best feature in each shell).

linuxopsys.com/topics/differe…
Image
12. Shell Script to Check Linux Server Health

In this tutorial, we will show how to write a shell script to perform a Linux server health check. This script collects system information and status like hostname, kernel version, uptime, CPU, memory, and disk usage.
13. Bash Command Line Chain Operators in Linux with Examples

Linux command chaining is a technique of combining several commands so that each of them can execute after the other based on the operator between them.
The operator that separates these commands is the most important aspect of command line chaining. These operators control how these commands get executed.
To reword, they control the flow of execution. Linux command chaining is very useful if you want to execute multiple commands at one goal.

linuxopsys.com/topics/bash-ch…
Image
14. Bash Function Return Value

In Bash, functions do not support returning values like in other programming languages. Instead, the return value of a function is its exit status, a numeric value indicating success or failure. A zero exit status indicates success,
while a non-zero exit status indicates failure.

linuxopsys.com/topics/bash-fu…
Image
15. How to Pass all Arguments in Bash Scripting

Bash arguments are one of the ways users provide inputs to the executing scripts. Using bash arguments, we create reusable scripts avoiding redundant code.
In this guide, we learn various approaches to passing all arguments in bash scripting.

linuxopsys.com/topics/pass-al…
Image
16. Bash Parameter Expansion with Cheat Sheet

Any number or string value or list of values (numeric or associative array) can be stored using a variable in bash.
You can define variables in bash without using the `declare` command or by using the `declare` command where the data type is declared at the time of declaration. Bash parameter expansion or parameter expansion is defined by the ‘$’ symbol and the optional curly brackets ({ }).
The parameter expansion is used with the curly brackets when it is required to read or modify the original parameter value. You have to use double quotes (“) when expanding values by using parameter expansion.
This guide explains how you can make use of bash parameter expansion

linuxopsys.com/topics/bash-pa…
Image
17. How to Do Bash Variable Substitution (Parameter Substitution)

When the original value of any expression is substituted by another value then it is called substitution. Bash variable substitution or parameter substitution is a very useful feature of bash.
Generally, it is done in the bash by using the '$' character and the optional curly brackets ({}). The content of the bash variable can be checked or modified based on the programming requirements by using variable or parameter substitution.
In this tutorial, we will learn different ways of substituting bash variables.

linuxopsys.com/topics/bash-va…
Image
18. How to Concatenate String Variables in Bash [Join Strings]

Two or more string variables of characters or numbers or a mix of characters and numbers can be concatenated easily in bash. The string variables are required to concatenate for different types of programming tasks.
Many ways exist in bash to concatenate string variables.

In this tutorial, we learn different ways of concatenating string variables in bash.

linuxopsys.com/topics/concate…
Image
19. source Command in Bash: A Practical Guide

Bash is a Unix shell and command language that provides users with an interface to the operating system. It is widely used on Linux and other Unix-like operating systems, as well as on Windows using the Windows Subsystem for Linux.
This tutorial will discuss about one of the most useful Bash command, source, which is used to execute commands from a file or script in the current shell environment.

linuxopsys.com/topics/source-…
Image
20. Customizing Your Bash Prompt in Linux: Changing Colors

One of the commonly used shell in Linux is bash. Even if there are many modern shells available, it's still the default shell in many Linux distributions.
In this tutorial, we learn how to change the color of specific parts of the bash prompt in Linux. Here we use ANSI escape codes within the PS1 variable.

linuxopsys.com/topics/customi…
Image
21. How to Make Bash Script Executable Using Chmod

In this tutorial, I am going through the steps to create a bash script and make the script executable using the chmod command.
After that, you will be able to run it without using the sh or bash commands.

linuxopsys.com/topics/make-ba…
Image
22. How to Rename Multiple Directories in Linux at Once

To rename a single directory in Linux is simple and straightforward. Whereas to do with multiple directories, we need to use special commands, scripts, or a combination of different commands.
In this tutorial, we learn how to rename multiple directories in Linux at once.

linuxopsys.com/topics/rename-…
Image
23. All the Ways to Rename Multiple Files in Linux

Linux users may have to rename file frequently and it is very easy to rename a single file. You can just use the mv command to rename one file.
There might also be situations where a user or a Linux system administrator may have to rename multiple files at once. This is a completely different case and Linux supports multiple tools and commands to rename multiple files in one go.
In this tutorial, we learn different utilities to rename multiple files in Linux with examples.

linuxopsys.com/topics/rename-…
Image
That's it for today's thread.

Thank you taking your time to read it.

If you enjoyed this thread, follow us @linuxopsys for future Linux posts, which we will be posting on a daily basis.

• • •

Missing some Tweet in this thread? You can try to force a refresh
 

Keep Current with Linuxopsys

Linuxopsys Profile picture

Stay in touch and get notified when new unrolls are available from this author!

Read all threads

This Thread may be Removed Anytime!

PDF

Twitter may remove this content at anytime! Save it as PDF for later use!

Try unrolling a thread yourself!

how to unroll video
  1. Follow @ThreadReaderApp to mention us!

  2. From a Twitter thread mention us with a keyword "unroll"
@threadreaderapp unroll

Practice here first or read more on our help page!

More from @linuxopsys

Oct 9
If you want to learn Linux for FREE, open this (a thread of our Linux threads): Image
1. Permissions

The operating system controls file access in Linux by utilizing file permissions, attributes, and ownership. In Linux, file permissions, attributes, and ownership determine the level of access that system programs and users have to files.

2. paste command in Linux explained

(simple yet powerful way to merge and organize data from multiple text files):

Learn more about the paste command in this master guide:

Read 41 tweets
Sep 27
Linux command line tools for parsing and analyzing logs 🐧↓
Linux logs are a valuable resource for system administrators, network administrators, developers, and security professionals.
They record a timeline of events on a Linux system, such as operating system events, application activity, and user activities and actions (for example log-in attempts).
Read 26 tweets
Jul 22
The ability to link files is a fantastic feature of the Linux filesystem. Consider linking files in Linux to be similar to creating Windows shortcuts.

Links are extremely useful, especially if you need to have two or more versions of the same file on the system.

Learn more↓ Image
Instead of having multiple physical copies of the same file on the system, you can have one physical copy and numerous virtual copies, known as links.
A link is a placeholder in a directory that points to the file's actual location. In Linux, there are two types of file links:

• symbolic link
• hard link
Read 19 tweets
Jul 19
Knowing when and how to stop running processes is an essential skill for sysadmins. When a process becomes stuck, it only takes a gentle nudge to restart or stop it.

At times, a process takes all the system resources. In both cases, you need a cmd that lets you manage a process. Image
The Linux operating system includes a number of commands for terminating errant processes (rogue processes), such as pkill, kill, and killall.

This thread will teach you how to use the kill command in Linux.
𝗚𝗲𝘁𝘁𝗶𝗻𝗴 𝘁𝗼 𝗸𝗻𝗼𝘄 𝗟𝗶𝗻𝘂𝘅 𝘀𝗶𝗴𝗻𝗮𝗹𝘀

Linux processes use signals to communicate with one another. A process signal is a predefined message that processes can either ignore or respond to. Developers define how a process will handle signals.
Read 33 tweets
Jul 15
In Linux, most people use the ls command to check a file's creation, access, and modification times, ownership, and permissions.

What if I told you there is another great way to display detailed information about files and file systems?

Learn more about it in this thread: Image
The Linux ls command typically displays basic or chunk of information about a file; however, what if you want to print more information about the file? This is where the stat command comes in.
stat (short for status) is a command-line utility for displaying detailed information about specific files or file systems. It is commonly used to obtain file timestamps.
Read 25 tweets
Jul 14
What exactly are bash exit codes in Linux?🤔

Learn more in this complete guide 🧵 ↓ Image
When writing Bash scripts, you will frequently need to stop the execution of a script when a certain condition is met or perform some actions based on a command's exit code.
In this thread I will go over the built-in bash exit command as well as the exit statuses of the commands that have been executed.
Read 14 tweets

Did Thread Reader help you today?

Support us! We are indie developers!


This site is made by just two indie developers on a laptop doing marketing, support and development! Read more about the story.

Become a Premium Member ($3/month or $30/year) and get exclusive features!

Become Premium

Don't want to be a Premium member but still want to support us?

Make a small donation by buying us coffee ($5) or help with server cost ($10)

Donate via Paypal

Or Donate anonymously using crypto!

Ethereum

0xfe58350B80634f60Fa6Dc149a72b4DFbc17D341E copy

Bitcoin

3ATGMxNzCUFzxpMCHL5sWSt4DVtS8UqXpi copy

Thank you for your support!

Follow Us on Twitter!

:(