Empty or Delete Large File Content in Linux

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

920 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

Download and Extract TAR Files with One Command in Linux

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

6K+ 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

Simple Arithmetic on Linux Terminal

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

513 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

Download Website Page on Linux Terminal

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

8K+ 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

Binary Tree with Array Implementation in C++

sudhir sharma
Updated on 03-Jan-2020 06:40:01

5K+ Views

A binary tree is a special type of tree in which each node of the tree can have at most two child nodes. These child nodes are known as right child and left child.A simple binary tree is −For representing trees, there are two ways, dynamic node representation which uses linked listSequential representation which uses array.Here, we will discuss about array representation of binary tree. For this we need to number the nodes of the BT. This numbering can start from 0 to (n-1) or from 1 to n.Lets derive the positions of nodes and their parent and child nodes ... Read More

Redirect If JavaScript is Not Enabled in a Browser

mkotla
Updated on 03-Jan-2020 06:38:41

974 Views

To redirect if JavaScript is not enabled in the web browser, add a script to the tag. Let us say you need to redirect to index.php if JavaScript is not enabled. ExampleHere’s how you can do this:           HTML noscript Tag                                                        html{display:none;}          

Disable Delete Permission of File and Directory in Linux

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

2K+ Views

Many times there can be un-intentional delete of files or directories. That can lead to loss of important data or some misconfiguration of the system so we need a way to stop the accidental deletion of files and directories it may not be applicable to all the files and directories but we can have a design where at least some files and directories are prevented from such scenario.We use the change attribute command to prevent scenario below will see how this command is applied to two files and directories.SyntaxBelow is the syntax of change attribute command.chattr [operator] [flag] [filename] Where ... Read More

Binary Search Tree Delete Operation in C++

sudhir sharma
Updated on 03-Jan-2020 06:37:30

5K+ Views

Binary search tree (BST) is a special type of tree which follows the following rules −left child node’s value is always less than the parent Noteright child node has a greater value than the parent node.all the nodes individually form a binary search tree.Example of a binary search tree (BST) −A binary search tree is created in order to reduce the complexity of operations like search, find minimum and maximum.Delete Operation binary search tree (BST)delete operation is dropping the specified node from the tree. in case deleting the nodes, there are three possibilities −Deleting a leaf node from the tree: ... Read More

Determine File System Type in Linux: ext2, ext3, or ext4

Pradeep Elance
Updated on 03-Jan-2020 06:36:36

27K+ Views

The file systems in Linux can be of different types. They support different file sizes and some mechanism like journaling etc. Also different types of file systems are supported by different Linux Kernel systems. So for the devices which are available as memory in the Linux System, we can determine their file types by using the following commands.Using lsblkThis command dispalys all the attached divices as well as their file types and partitions.$ lsblk -fRunning the above code gives us the following result −NAME FSTYPE LABEL UUID MOUNTPOINT sr0 sda ├─sda2 ├─sda5 swap 02a54ace-c5c2-41cf-a679-acd9b460ee79 [SWAP] └─sda1 ext4 ae7c051f-451b-45ad-80a3-347c70a9de5e /Using fileIt ... Read More

Create Multiple User Accounts in Linux

Pradeep Elance
Updated on 03-Jan-2020 06:32:22

4K+ Views

Adding a single new user to a Linux system can be achieved through the useradd command. But system admins often get request to add many users. So Linux provides a different to do a bulk addition of many users to a system.This is the newusers command.Synatxsudo newusers user_deatils.txt user_details.txt is the file containing the details of all the usernames to be added.User DetailsBelow we see the structure of user_details.txt file.UserName:Password:UID:GID:comments:HomeDirectory:UserShell So we create a file with below details to add many usres.~$ cat MoreUsers.txt uname1:pwd#@1:2112:3421:storefront:/home/uname1:/bin/bash uname3:pwd#!@3:2112:3525:backend:/home/uname3:/bin/bash uname4:pwd#$$9:9002:4721:HR:/home/uname4:/bin/bashGiving Permissions to the User Details FileBefore we sue the user details file to ... Read More

Advertisements