Shell Signal Values A signal is a message that some abnormal event has taken place or a message requesting another process do something. The signal is sent from one process to another process. Typically, a process sends a signal to one of its own subprocesses. You can obtain more information on signals from the signal […]
DevOps
How to Make a Variable read-only (constant) in Bash and Korn Shell
Creating Bourne Shell Constants A variable can be made read-only with the following syntax: readonly var[=value] The square brackets around =value mean that the assignment of a value is not always necessary. For instance, if the variable had previously been created and assigned a value, and you now want to make it read-only (and not […]
Examples of “shift” Command in Shell Scripts
The shift Statement Sometimes a script does not require a specific number of arguments from users. Users are allowed to give as many arguments to the script as they want. In these situations, the arguments of the script are usually processed in a while loop with the condition being (($#)). This condition is true as […]
Korn Shell select Loop
The select statement in the Korn shell creates a menu. This construct is for the Korn shell only. The syntax for creating a menu is: select var in list do statement1 … statementN done The variables var and list follow the same syntactic rules used in the for loop (although the operation of the select […]
How to use “break” and “continue” statements in shell scripts
The break Statement The break statement allows you to exit the current loop. It is often used in an if statement that is contained within a while loop, with the condition in the while loop always evaluating to true. This is useful if the number of times the loop is executed depends on input from […]
How to use until loop in Shell Scripts
The until Loop The until loop is very similar to the while loop, except that the until loop executes as long as the command fails. After the command succeeds, the loop exits and execution of the script continues with the statement following the done statement. The syntax for the until loop is: until control_command do […]
“while” Loop Examples in Shell Scripts
The while loop allows you to repeatedly execute a group of statements while a command executes successfully. The syntax for the while loop is: while control_command do statement1 … statementN done where, control_command can be any command that exits with a success or failure status. The statements in the body of the while loop can […]
How to Configure Network Namespaces in Docker Containers
This post tells how Docker uses network namespace to isolate resources. The following figure is the lab setup to help you understand the steps visually: 1. Create two network namespaces: ns1 and ns2. – Add two new naetwork namespaces: # ip netns add ns1 # ip netns add ns2 The above commands create network space […]
“su: Authentication failure” – in Docker
The Problem In some situations, a normal user within a Docker container cannot run ‘su’ command to switch user. When ‘su’ command is issued, the following error returns. $ su – Password: [entering correct password] su: Authentication failure The Solution The sticky permission may be missing in /usr/bin/su within the container. With root privilege, you […]
How to Pause and Resume Docker Containers
Question: How to Pause and Resume running containers on docker host? This post will help to know about pausing and resuming any running containers on the Docker host. Let’s first start the docker container “memory_test” on the docker host. # docker start memory_test memory_test To stop the pause the docker container: # docker pause memory_test […]