Tag: bash

How to Run Bash Script as Root During Startup on Linux

Have you ever wanted to run bash script as a root user during startup? Here’s how you can harness the power of cron and set your scripts to run at startup.

Source: How to Run Bash Script as Root During Startup on Linux – Make Tech Easier

Change shell properties with Linux shopt command

Bash shopt command explained  with examples

Shopt(SHell OPTions) is a built-in command to change the properties of a shell such as..

Its history behavior

Spell check

Enable special characters for echo command by default

and many more.

This is an excellent command which give more control on Shell for you when you are working on bash and sh shells. …..

Source: Change shell properties with Linux shopt command

Link: Bash One-Liners Explained, Part I: Working with files

I love being super fast in the shell so I decided to do a new article series called Bash One-Liners Explained. It’s going to be similar to my other article series – Awk One-Liners Explained, Sed One-Liners Explained, and Perl One-Liners Explained. After I’m done with this bash series, I’ll release an e-book by the same title, just as I did with awk, sed, and perl series. The e-book will be available as a pdf and in mobile formats (mobi and epub). I’ll also be releasing bash1line.txt, similar to perl1line.txt that I made for the perl series.

In this series I’ll use the best bash practices, various bash idioms and tricks. I want to illustrate how to get various tasks done with just bash built-in commands and bash programming language constructs.

Also see my other articles about working fast in bash:

Full article here:
Bash One-Liners Explained, Part I: Working with files (Browserling)

Links: Bash by Example, Parts 1-3

You might wonder why you ought to learn Bash programming. Well, here are a couple of compelling reasons:

You’re already running it 
If you check, you’ll probably find that you are running bash right now. Even if you changed your default shell, bash is probably still running somewhere on your system, because it’s the standard Linux shell and is used for a variety of purposes. Because bash is already running, any additional bash scripts that you run are inherently memory-efficient because they share memory with any already-running bash processes. Why load a 500K interpreter if you already are running something that will do the job, and do it well?
You’re already using it
Not only are you already running bash, but you’re actually interacting with bash on a daily basis. It’s always there, so it makes sense to learn how to use it to its fullest potential. Doing so will make your bash experience more fun and productive. But why should you learn bash programming? Easy, because you already think in terms of running commands, CPing files, and piping and redirecting output. Shouldn’t you learn a language that allows you to use and build upon these powerful time-saving constructs you already know how to use? Command shells unlock the potential of a UNIX system, and bash is the Linux shell. It’s the high-level glue between you and the machine. Grow in your knowledge of bash, and you’ll automatically increase your productivity under Linux and UNIX — it’s that simple.

Full articles here (source: funtoo linux):
Bash by Example, Part 1 – Fundamental programming in the Bourne-again shell
Bash by Example, Part 2 – More bash programming fundamentals
Bash by Example, Part 3 – Exploring the ebuild system

Link: How to set the PATH variable in Bash

So, how do you set the PATH variable in Bash?

That’s a very simple task, which should take less than a minute to complete. However, for the benefit of those not familiar with the Bash shell or the PATH variable, let’s start with a very brief introduction.

Full article here:
How to set the PATH variable in Bash (LinuxBSDos.com)

Link: Alien’s Bash Tutorial

First you probably need to read a UNIX command bible to really understand this tutorial, but I will try to make it as clear as possible, there is about 100-150 UNIX commands explained later in this tutorial.

You are to have some UNIX experience before starting on this tutorial, so if you feel that you have UNIX/Linux experience feel free to start to learn here.

What I included here is general shell scripting, most common other things and some UNIX commands.

Full article here:
Alien’s Bash Tutorial (subsignal.org)

Link: 15 Useful Bash Shell Built-in Commands (With Examples)

Bash has several commands that comes with the shell (i.e built inside the bash shell).

When you execute a built-in command, bash shell executes it immediately, without invoking any other program.

Bash shell built-in commands are faster than external commands, because external commands usually fork a process to execute it.

In this article let us review some useful bash shell builtins with examples.

Full article here:
15 Useful Bash Shell Built-in Commands (With Examples) (The Geek Stuff)

Link: Tutorial: Customizing Your Bash Prompt

In this tutorial I will show you how you can change the look and behavior of the prompt to show more details or use a different coloring style. I will explain how to try all these examples and how to make changes permanently by adding them inside the Bash configuration file. Please note that this stuff is Bash-specific and it won’t work in other shells.

Full article here:
TuxArena | Tutorial: Customizing Your Bash Prompt (TuxArena)

RELATED: Some of you might prefer to run a program that customizes the bash prompt for you. For you there’s bash-prompt-customizer-cli at GitHub.

Link: Basic Linux Shell Scripting Language : ‘While’ Loops

In the previous article entitled “Basic Linux Shell Scripting Language : Introduction to ‘For’ Loops“, we have observed how a loop works. Loop is nothing but a control flow statement which executes a block of commands repeatedly till certain condition stays true, once the condition becomes false, the loop is terminated.

In this article, I will explain Basic syntax of ‘While’ loop along with some examples of ‘While’ loop usage. If you are new to Shell Scripting, I recommend that, you should read my article – Getting Started – Linux Shell Scripting Language.

One of the things we found interesting in this article is that it shows how to use an infinite ‘while’ loop that can only be broken out of by some specific event or condition. Very basic stuff, but something that can come in quite handy in certain situations.

Full article here:
Basic Linux Shell Scripting Language : ‘While’ Loops (Your Own Linux..!)

Recent Posts

Recent Comments

Archives

Categories

Meta

GiottoPress by Enrique Chavez