how to get current date and time inside a shell script

date and time in shell

When writing shell scripts, many times you would want to get the current time and date, that is the date and time when the script is getting executed. This value can be saved to a variable and used through out the script for various different purposes. You can use them to generate informative file names or even other variables. You can…

how to prompt for input from user in a linux shell script

shell script select command menu

When writing shell scripts, you will have scenarios you want to get input from the command line. And you would want to perform some specific action based on the user input. Programming a shell script to accept user input from the console is quite simple. We will see some examples of how you can do this in a bash script….

how to chain commands in linux command line (with examples)

sort command with redirection

Sometimes you would want to run multiple commands in succession or simultaneously. This is usually useful when running processes or commands that is expected to run for a long period of time. This allows you to automate a process that include several commands that may or may not depend on the result of the previous command. Linux command chaining is the…

12 useful bash aliases that you can make you more productive in linux

bash aliases in linux

Aliases is one of the most useful features of Linux command shells. You probably end up using the same commands over and over on a daily basis. This is true if you use the command line for almost everything. You can use bash aliases (if you use bash) or shell aliases to make these every day tasks easier to execute. Most of…

how to call shell script (.sh) file from another shell script

Reload shell profile environment in linux

When writing or developing shell scripts in Linux, you might want to call or execute another script file from with in the current script. There are three different ways you can do this, and which method you want to use will depend on what your requirements are. Firstly, you need to know how exactly you want the other script to…

how to make shell script executable from anywhere in linux

Example of Shell Script File

In Linux, shell scripts are the standard staple of everyday life. Most programs or software in Linux and Unix use some script file to start or run. It is roughly equivalent to executable files in Windows. You will also be able to create custom shell scripts to automate many of the everyday tasks as well. It is not uncommon to end…

what are shell scripts in linux and why you need them

Example of Shell Script File

A Shell Script is nothing but a text file which contains a series of commands that can be executed by the shell or the underlying operating system. Some of the commands that you enter in the command line might actually be shell scripts that execute a set of other lower level commands. Also many software in Linux use shell scripts…

what is a command shell in linux

Reload shell profile environment in linux

Many posts on this site deals exclusively with how to get things done in Linux using just a command shell. We use the terms shell, command shell, command prompt, command line, console and terminal interchangeably most of the times. In most cases, it does not matter and it all means the same but there is some subtle differences between shell…

7 simple keyboard shortcuts you should know in linux command shell

Reload shell profile environment in linux

When using the command shell or terminal in Linux, there are several keyboard shortcuts available to you that perform common functions. Many of these shortcuts are common across many of the different shells, such as bash, csh, ksh or fish. That means you do not have to remember different commands for different shells. We will see some common keyboard shortcuts…

how to create an XML sitemap using wget and shell script

Snippet from an XML Sitemap

A SiteMap or Site Map is a file that lists the pages of a webpage that are accessible to users and search engines. This can be in any format as long as whoever is reading it can understand the format. There are mainly two types of format that are used when creating a site map: XML and HTML. All websites…

How to Change the Default Shell for an User in Linux?

finding default shell in linux

There are several different command shells available to you in Linux. bash, csh, tcsh, ksh, zsh, sh and fish are just a few of the popular ones that can be used by an user from the command line. As a system administrator, you can specify a default shell for the user. The user can however choose the run another shell…

how to reboot, logout or shutdown linux machines from command line

Options to Shutdown Linux

All desktop environments has menu options to shut down and reboot machines. Most times there are also keyboard shortcuts that the X or the desktop support that allow you to shut down machines. The most commonly used keyboard shortcut is Ctrl+Alt+Del. Although these menu options and keyboard shortcuts makes it easier, it is beneficial to know the command line options…