contador web Skip to content

It's not magic, it's Shell Script! Linux command line tricks

Mastering Shell Script, in other words, automating Linux in its purest form. Today we will start a series that will help you make peace with the terminal and still give you some useful tips.

The Shell Script was created by Ken thompson (Thompson Shell, was later replaced by the Bourne Shell developed by Stephen Bourne, Bourne Shell), the creator of Unix and C language, along with Dennis Ritchie. The main goal was to create a fast, easy way that could automate communication with the kernel. The main feature of Shell Script is the same as it differs from several programming languages, which can play output from one command to another command, the pipe, which currently can be "invoked"by character: | .

O Shell script is present on all Unix and Unix-like systems (Linux, FreeBSD, OpenBSD, HP-UX, Solaris, AIX, NetBSD, Irix, etc.), not to mention that Microsoft Windows, in its latest version, has Shell Script, besides macOS is a system that has the custom FreeBSD kernel. There are several types of shell, this variety came into existence because of software licenses. In the distributions Linux, the standard shell Bash (Bourne Again Shell, as it is an improvement of the Bourne Shell and with a more permissive license), than what we will use here.

Customizing the Appearance of Your Command Prompt (PS1 Variable)

Just as there are several types of shell, there are also several terminal emulators for Shell and different ways of presenting their characteristics. The first thing you see when opening the terminal is the command prompt, to better understand it, we can say that it is a "pointer bar" of its position in the shell. Its appearance depends directly on the PS1 variable, which can be set in the files: ~ / .bashrc, .profile or any file that is part of the recursive tree. See the image below for an example of my command prompt:

Terminal That is, the content of my variable $ PS1 . If you assign another value to variable PS1 using the Shell itself, you will see that the prompt will be changed. For example, copy and paste the content below and paste it into your terminal and then hit enter:PS1 ="blog @ diolinux:"

You will notice that the prompt will be modified, but don't worry, if you want it to return to the previous prompt, just close and reopen your terminal or run the command below:source / etc / profile

If you want to permanently modify your prompt setting just assign the value you want in your .bashrc . You can add: specific syntaxes, Colors, characters, … For example, for your prompt to display: the username, the name of your computer, and the directory you are in, use this setting for your prompt: