Backtracking is a technique to solve dynamic programming problems. It works by going step by step and rejects those paths that do not lead to a solution and trackback (moves back ) to the previous position.In the subset sum problem, we have to find the subset of a set is such a way that the element of this subset-sum up to a given number K. All the elements of the set are positive and unique (no duplicate elements are present).For this, we will create subsets and check if their sum is equal to the given number k. Let's see a ... Read More
Removing directories is a regular process for anyone working on Unix systems.But sometimes we also need to find the directories first and then decide to delete it. One hurdle in deleting the files is to do a recursive deleting because by default Unix systems do not allow deleting of a directory if it is not empty. So in this article we will see how to find and remove directories recursively.Using find and execThe below command first searches for the required directory using the find command then executes the ‘rm’ command to recursively remove the directory using the recursive option as ... Read More
Random variables are those variables that are an outcome of the outcomes of a process that has the probability of giving rise to multiple outcomes. For example, The variable denoting head or tail as an outcome on tossing a coin is a random variable.A binomial random variable is a special type of random variable whose value is related to an event that has a fixed probability of an outcome in an event.There are certain properties that are possessed by a binomial random variable that makes it special. These are a must for a variable to become a binomial random variable ... Read More
Re-running commands in the command line is a regular task which all of us go through when working on the Unix systems. In the below article we will see various ways how we can rerun the commands we have already executed this helps save time and it helps reasoning longer commands easily without retyping them.Before we get into how to re-execute previous command let's see how we can look at the list of all the commands. There is a command call history which lists down all the executed command for a specific time period configured by the system. Below is ... Read More
Because of security concerns, the users in a system are required to update their passwords regularly. In this article we will see how we can force an user to change their password when they login to the system next time.List the usersFirst lets have a look at the users available in the system.$ cut -d: -f1 /etc/passwdRunning the above code gives us the following result −mail news uucp proxy www-data backup list … Ubuntu uname1Check user DetailsNext we check the settings for users current password system configuration.$ sudo chage -l uname1 [sudo] password for ubuntu:Running the above code gives us ... Read More
For the sysadmins, it is routine to monitor user details like who are active and who are not, who logged in in last 2 days, which users belong to a given group etc etc. To help these requirements, Linux provides below list of commands which can be used to gather various types of information about the users.id CommandIt gives the id details of users including the group id along with the secondary group IDs and names of a user choosen by the system. But you also ask for a specific user’sdeatils by giving the userid value in the command.ubuntu@ubuntu:~$ id ... Read More
For purpose of security, cyber-crime investigation, government compliance or just for curiosity we might ned to track the geographical location of a Linux server in the internet or at least the location of the server which diverts the internet traffic to the server we are interested in. It involves getting the I.P address of the server and using some third party services offered in the web, to map that I.P address to get the location. In this article we will see the steps to achieve that.Step 1 − Install curl jqThe curl package will make the http requests to the ... Read More
Usually a continuously growing files, needs to be emptied from time to time to accept the latest data from the next operation. There are various mechanisms to empty the file. We will see them one by one below. The common approach is the overwrite the target file by using > sign which should come from a source which is empty./dev/nullThis is a common method where we output empty result and then redirect that result to the target file.# Original file size $ls-lt -rw-rw-r-- 1 ubuntu ubuntu 2925 Jan 1 08:39 ref_file.txt # Redirect the output from /dev/null $ cat /dev/null ... Read More
We can download any required file form the web using the linux terminal. But many times it is found that the downloaded file is a zipped file which is in tar format. In this article we will see how to download and extract the file in a single command.Using wget and tarThe wget command downloads the data form the given URL while the tar command does the extraction of the tar.gz files.$ wget -c https://www.metoffice.gov.uk/hadobs/hadisd/v300_2018f/data/WMO_200000-249999.tar.gz -O - | sudo tar -xzRunning the above code gives us the following result:--2020-01-01 07:25:18-- https://www.metoffice.gov.uk/hadobs/hadisd/v300_2018f/data/WMO_200000-249999.tar.gz Resolving www.metoffice.gov.uk (www.metoffice.gov.uk)... 104.80.55.230 Connecting to www.metoffice.gov.uk (www.metoffice.gov.uk)|104.80.55.230|:443... connected. ... Read More
While some GUI based Linux desktops give a calculator to be used in a similar way to what is available in Windows, the terminal has lot of features to do both simple and advanced level arithmetic calculations. In this article we will see how we can invoke various calculations from the Linux terminal itselfUsing bcThe command bc stands for basic calculator. Using it we can do various operations like arithmetic calculations, assigning values to variables, using comparison or relational operators and using many math functions available through bc itself. Also it has features for conditional statements and iterative statements. Below ... Read More
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP