Found 1437 Articles for Linux

How to Search and Remove Directories Recursively on Linux?

Pradeep Elance
Updated on 03-Jan-2020 07:02:23

275 Views

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

How to Save Command Output to a File in Linux?

Pradeep Elance
Updated on 03-Jan-2020 07:00:58

454 Views

Sometimes the output of Unix command can we learn the important in such case we want to save the result for later reference in this article we will see how to save the output of a command to a file.Creating a New FileOutput of the disk usage command can be saved by using the > symbol and a new file name.$du-h > usagefile.txt $cat usagefile.txtRunning the above code gives us the following result −12K./bin 4.0K./Videos 20K./.compiz/session 24K./.compiz 8.0K./.config/gedit 12K./.config/compiz-1/compizconfig ………… ……….Appending to Existing FileAppend the Output of the disk usage command by using the >> symbol and a new file ... Read More

How to Re-run Last Executed Commands in Linux?

Pradeep Elance
Updated on 03-Jan-2020 06:59:07

219 Views

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

How to Force User to Change Password at Next Login in Linux?

Pradeep Elance
Updated on 03-Jan-2020 06:57:07

542 Views

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

How to Find User Account Info and Login Details in Linux?

Pradeep Elance
Updated on 03-Jan-2020 06:54:25

5K+ Views

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

How to Find Linux Server Geographic Location in Terminal?

Pradeep Elance
Updated on 03-Jan-2020 06:52:37

3K+ Views

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

How to Empty or Delete a Large File Content in Linux?

Pradeep Elance
Updated on 03-Jan-2020 06:47:23

755 Views

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

How to Download and Extract Tar Files with One Command in Linux

Pradeep Elance
Updated on 03-Jan-2020 06:43:54

5K+ Views

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

How to download a website page on Linux terminal?

Pradeep Elance
Updated on 03-Jan-2020 06:40:41

7K+ Views

The Linux command line provides greta features for web crawling in addition to its inherent capabilities to handle web servers and web browsing. In this article we will check for few tools which are wither available or can be installed and used in the Linux environment for offline web browsing. This is achieved by basically downloading the webpage or many webpages.WgetWget is probably the most famous one among all the downloading options. It allows downloading from http, https, as well as FTP servers. It can download the entire website and also allows proxy browsing.Below are the steps to get it ... Read More

How to do simple Arithmetic on Linux Terminal?

Pradeep Elance
Updated on 03-Jan-2020 06:41:18

345 Views

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

Advertisements