Because Linux has its conceptual roots in the older Unix operating system, many applications are designed to be executed from a command line. Linux has two user interfaces: the Graphical User Interface (GUI) and The command Line, the Shell.
In UNIX, the parent operating system of Linux, a command interpreter is a Shell. A shell is an environment where we can run commands, programs, and others shell scripts. The UNIX operating system popularised many of the ideas about shell scripting.
Linux offers many different shells; however, Bash has become the default standard on Linux. Bash understands a whole of standard Linux commands or can run any command stored in an executable file. In addition, it can also execute shell scripts (text files that contain Linux commands).
You build a small and simple utility and we use it as one link in a string of others to form a command. The shell acts as the interface between you and the Linux System, allowing you to enter commands for the operating system to execute.
The purpose of the shell is to start processes running your commands. The shell stays between the user (you) and the system. The command is not directly executed; rather, the shell reads the input, interprets the command and then creates the process that executes the command.
Linux provides thousands of shell utilities that range from simple programs for creating, examining, and modifying files and hardware configurations to complex utilities that enable low-level capabilities such as file systems, security and networking.
The basic concept of a shell script is a list of commands, which are listed in the order of execution. Shell scripts are interpreted. They are ASCII text that is read and executed by the shell interpreter. When we execute a shell script, the shell interpreter goes through the ASCII text line by line, and executes each statement, as each line is reached from the top to the bottom.
All shell commands have this general format:
command option1 option2... optionN
Linux is a multiprocessing operating system. This means that several processes can be executed simultaneously. By definition, a process as an instance of an executing program. If the same program is being executed twice, it requires two processes. Everything done on a Linux system is done by a process. It is important to emphasize that a process is not a program. A process is an environment within which a program executes. By default, every process, when created, is connected to three default streams: standard input, standard output, and standard error. We can see it in the following image.
All three standard streams are connected to the process’s controlling terminal, by default the input stream is the keyboard and the screen is the output and error streams respectively.
Because process is independent of the program it executes and the data it processes. The process does not care how the data it is using is generated or consumed. This mechanism allows the output of one process to be connected to the input of another.
Anything done by a pipeline can also be done by storing the output of process A into a file or using a file as input for another process.
You can get the following scripts in the src folder:
- countFolders.sh: Counts the total number of folder in a given path.
- countFiles.sh: Counts the total of files in a given path (same logic that countFolder).
- convertLower2Upper.sh: convert the files names of a given path to Uppercase.
- covertUpper2lower.sh: convert the files names of a given path to Lowercase.
- burnfolder2iso.sh: makes the iso image of a given folder.
- PgAgent.sh: starts or stops a PostgreSQL database.
- killmyprocess.sh: kills a process running by the user.
- showFrequencyWords.sh: Displays the word frequency in a text file.
- showFileSize.sh: Displays the size of the files of a given path.
- backupDir.sh: Backups and compress all directories of a given path, and adds the datetime to the name of each backup file.
- imageConverter.sh: Uses some options in ImageMagick convert command to convert images from one format to another.
- Swart,R.[1990],UNIX Applications Programming: Mastering the Shell,USA,SAMS
- Waingrow, K.[1999],UNIX Hints & Hacks,USA,QUE
- Rosen K,Rosinki R, farber J,Host D[1997], UNIX SYSTEM V an introduction 2 edition,Spain,McGrawHill