Wget is a Linux command line utility that is used to retrieve files from World Wide Web(WWW) and makes use of protocols like HTTPS and FTP. It is a freely available package and can be downloaded and installed on any Linux supporting architecture.One of the key features of wget is its ability to automatically start downloading where it was left off in case there is a network issue. It should also be noted that it deletes files recursively and it will keep trying to download all the files until it has been retrieved completely.Installing wgetFor Ubuntu/Fedorasudo apt-get install wgetFor Mac ... Read More
Linux provides the famous top command utility that provides us with all the information about the processes, their time, their respective IDs, how much CPU chunk they are consuming and much more. The only issue with that is the processes are not sorted in any order and the order changes frequently.There are certain cases where we would like the output to be in a sorted manner somehow, like sorted in the sense that the process which is using the most memory will be at the top.The most basic approach is to make use of the ps command that Linux provides ... Read More
The pdfgrep command in Linux is used to filter searches for a particular pattern of characters in a PDF or multiple PDFs. It is one of the most used Linux utility commands to display the lines that contain the pattern that we are trying to search.Normally, the pattern that we are trying to search in the file is referred to as the regular expression.Installing Pdf grepFor Ubuntu/Fedorasudo apt-get update -ysudo apt-get install -y pdfgrepFor CentOSyum install pdfgrepSyntaxpdfgrep [options...] pattern [files] While there are plenty of different options available to us, some of the most used are −-c : counts the ... Read More
In order to create a crontab job to run every Sunday, we first need to explore and understand what a crontab job is.A crontab is nothing but a list of commands that we can run during a cron job. A cron job is a utility that schedules automatic execution of commands at specific times.We can start a cron job with the help of bash script by following the commands shown below −crontab -eThis will open a file which you can edit, insert the cron job shell script in the above file and then close that file.Just insert the code shown ... Read More
There is always a scenario where we sometimes encounter the transfer of files to be broken because of some reason. The reasons could be different, unless it is not that you explicitly closed the particular connection or process, it can be recovered.It should also be noted that the scp command doesn’t have a resume option, and the only option is to simply start copying the files from the beginning and overwrite the existing files. The process of doing this again and again because of the ssh disconnection can be very annoying and time consuming.Linux does provide us with a command ... Read More
Consider a case in which one directory on my local machine looks something like this −immukul@192 dir1 % ls -ltr total 0 -rw-r--r-- 1 immukul staff 0 Jul 3 20:44 sample code.txt -rw-r--r-- 1 immukul staff 0 Jul 3 20:44 sample code with love.txtIn the above directory named dir1, there are two .txt files present and both these files have spaces in between the words in their name, and we need to replace these spaces using a bash script on Linux.In order to achieve what we want, we must first be aware of the fact that we can traverse the ... Read More
Consider that we have a file named bar that contains different numbers inside it. The bar file looks something like thisimmukul@192 linux-questions-code % cat bar 11 12 13We need to get the sum of all the numbers present in the above file.There are plenty of approaches and solutions that we can consider that involve different commands and keywords. Let’s consider some of these possible solutions one by one.The most basic approach is to open the file and read the contents and then calculate the sum of all the numbers by making use of the do while loop.Bash Scriptsum=0 while read ... Read More
A background process in Linux is a process that is running independently of the shell. It provides us the privilege to leave the terminal window, and it will still be executing in the background without any interaction from the users.Nginx and Apache web servers are the most common examples of the background processes that are used to serve images and dynamic content.In Linux, we can start a process in the background by just appending the symbol & after it.Consider the example shown below −sleep 10000 &In the above command, we make use of the sleep statement that will run for ... Read More
In order to be able to preserve colouring after using the pipe in between the grep togrep command, we must first be aware of what the grep command is and how to use it on Linux.The grep command in Linux is used to filter searches in a file for a particular pattern of characters. It is one of the most used Linux utility commands to display the lines that contain the pattern that we are trying to search.Normally, the pattern that we are trying to search in the file is referred to as the regular expression.Syntaxgrep [options] pattern [files]While there ... Read More
The grep command in Linux is used to filter searches in a file for a particular pattern of characters. It is one of the most used Linux utility commands to display the lines that contain the pattern that we are trying to search.Normally, the pattern that we are trying to search in the file is referred to as the regular expression.Syntaxgrep [options] pattern [files]While there are plenty of different options available to us, some of the most used are −-c : It lists only a count of the lines that match a pattern -h : displays the matched lines only. ... Read More
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP