In a Linux system, everything is logged in a log file under the directory called /var/log. This directory contains logs related to different services and applications. In this directory we have some files such as utmp, wtmp and btmp. Unlike the system log files and the authentication log files, all of these files are binary […]
Archives for July 2020
How to (Correctly) Change the UID and GID of a user/group in Linux
Changing the UID and GID of a user might seem a trivial task to most of the system admins. But it’s not so trivial and it involves a lot more changes in the backend. In this post, we have outlined the exact steps to change the UID and GID of a user “user01”. Username: user01 […]
PHPMyAdmin :: Existing configuration file (./config.inc.php) is not readable
The Problem I have just installed LAMP on my CentOS machine and while trying to access phpMyadmin thorugh cPanel, get below error: Existing configuration file (./config.inc.php) is not readable. The Solution The above error is due to the misconfiguration of permissions of the phpMyAdmin configuration file – /usr/local/cpanel/base/3rdparty/phpMyAdmin. Follow the steps outlined below in order […]
cp: omitting directory – error while copying a directory in Linux
The Problem When we are trying to copy a directory to other location, we get below error: $ cp /data01 /data02 cp: omitting directory ‘/data01′ $ The Solution The error above is a common mistake done by Linux newbies while copying a directory to other locations without using the recursive copy option in the ‘cp’ […]
How to Use user-defined Functions in awk
User-Defined Functions You can create user-defined functions in a awk script file using the func or function keywords. Placement in the file is not important; the function definition can occur anywhere in the awk script. The function can take arguments (local to the function only) or use any existing variable. The syntax of a function […]
Using Loops (while, for) in awk scripts
The awk programming language contains many of the programming concepts that are used in shell scripting. Conditionals, such as the if statement and loops, such as the following can also be used in awk programming. The while loop The do while loop The for loop The if Statement The if statement can have two branches: […]
Beginners Guide to Using “trap” to Catch Signals and Handle Errors in Shell Script
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 […]
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 […]