menu
  + 
    #### 
    Reliable web hosting for your business or personal sites. cPanel + Litespeed included on fast NVMe storage.
    Loaded features and overselling enabled plans to help grow your business. cPanel/WHM + LiteSpeed + NVMe.
    Fine-tuned and optimized for all WordPress sizes. No i/io limits, AccelerateWP + cPanel + LiteSpeed + NVMe.
    KVM VPS servers with NVMe standard. Fast setup. **Free VPS control panel included.**
    Enterprise grade bare-metal servers with **1G / 10G unmetered** options. Fast provisioning.
 / Knowledge Base
# How to Delete Lines in Vim Editor
## Knowledge Base
290
June 8, 2024
## Table of Contents
1. 
2. 
   1. 
   2. 
3. 
4. 
How to delete lines in vim editor via Linux SSH or its precursor Vi is quite simple. VIM editor comes preinstalled on most Linux distributions and macOS. Knowing the basics of Vim is important if you are a system administrator or just a regular Linux user.
Quite often, when working with text files, you’ll need to delete one or more lines.
This article shows how to delete lines in Vim editor in Linux.
## Deleting a Line
The command to delete a line in Vim is `dd`.
Below are step-by-step instructions to delete a line:
1. Press the `Esc` key to go to normal mode.
2. Place the cursor on the line you want to delete.
3. Type `dd` and hit Enter to remove the line.
Pressing `dd` multiple times will delete multiple lines.
## Deleting Multiple Lines
To delete multiple lines at once, prepend the `dd` command with the number of lines to be deleted. For example, to delete five lines you would do the following:
2. Place the cursor on the first line you want to delete.
3. Type `5dd` and hit Enter to delete the next five lines.
### Delete a range of lines
The syntax for deleting a range of lines is as follows:
```
:[start],[end]d
Copy
For example, to delete lines starting from 3 to 5 you would do the following:
2. Type `:3,5d` and hit Enter to delete the lines.
You can also use the following characters to specify the range:
* `.` (dot) – The current line.
* `$` – The last line.
* `%` – All lines.
Here are a few examples:
* `:.,$d` – From the current line to the end of the file.
* `:.,1d` – From the current line to the beginning of the file.
* `10,$d` – From the 10th line to the end of the file.
### Delete All Lines
To delete all line you can use either the `%` symbol that represents all lines or the `1,$` range:
2. Type `%d` and hit Enter to delete all the lines.
## Deleting Lines Containing a Pattern
The syntax for deleting multiple lines based on a specific pattern is as follows:
:g/<pattern>/d
The global command (`g`) tells the delete command (`d`) to delete all lines containing the `<pattern>`.
To match the lines not matching the pattern, add an exclamation mark (`!`) before the pattern:
:g!/<pattern>/d
The pattern can be a literal match or  . Below are some examples:
* `:g/foo/d` – Delete all lines containing the string “foo”. It also removes line where “foo” is embedded in larger words, such as “football”.
* `:g!/foo/d` – Delete all lines not containing the string “foo”.
* `:g/^#/d` – Remove all comments from a Bash script. The pattern `^#` means each line beginning with `#`.
* `:g/^$/d` – Remove all blank lines. The pattern `^$` matches all empty lines.
* `:g/^\s*$/d` – Remove all blank lines. Unlike the previous command, this also removes the blank lines that have zero or more whitespace characters (`\s*`).
## Conclusion: How to Delete Lines in Vim Editor
We have shown you how to delete lines in Vim.
If you are new to Vim, visit the  site where you can practice Vim with an interactive tutorial.
Feel free to leave a comment if you have any questions.
source: <
Tags: , 
0
Share Feedback
email
 Submit
previous article
#### 
next article
### Leave a Reply 
You must be  to post a comment.
* cPanel
* Control Panels
* Linux Tips
* Monitoring
* Operating Systems
* Random Stuff
!
The **LOGICWEB** logo is a registered trademark of LogicWeb Inc. All rights reserved. © 2024
**Company**
**Policies**
**Support**
# 3 Best Ways to Securely Wipe Disk in Linux Using Command Line
13300
December 6, 2024
5. 
**This article shows you the three best ways to completely erase data from your disk using the dd, shred and wipe command.**
Sometimes we have to erase all the information from our disk in a way that ensures it is impossible to recover. The most typical reason for completely and irreversibly deleting a device is when, for example, it is to be given away or sold.
Many users probably believe that deleting their data using the file manager or the `rm` command ensures security. The truth, however, is slightly different.
 just removes the pointer to the filesystem. So the original data is still available. As a result, with a high probability, a considerable portion of this data can be recovered using specific techniques.
However, wiping the disk with one of the following commands, `shred`, `dd`, or `wipe`, assures that the information you erased is unrecoverable. So, let us show you how to do it.
## Erasing Disk Using shred Command
We start with the `shred` command because it is one of the best ways to protect your private data on a Linux system.
The command helps in overwriting the data several times, such that it can only be recovered with extreme difficulty, if at all, using specialized hardware. That is why it is frequently used to erase data securely.
Because `shred` is part of the `coreutils` package in Linux, you most likely have the command available by default on your system. It uses three passes by default, writing pseudo-random data to the device during each run.
For example, if you want to erase a device that is present as `/dev/sdb` on your Linux system, the command would be as follows:
sudo shred -v /dev/sdb
We’ve included the `-v` (`--verbose`) option to see the disk wipe operation in detail.
However, the time required to complete these three subsequent cycles will be lengthy. Fortunately, we can specify shred to perform only one loop using the `-n` (`--iterations=`) option.
sudo shred -v -n 1 /dev/sdb
Of course, we can improve the reliability of wiping data from disk by adding a few more options to the shred command.
First, we’ll specify that the disk is overwritten with randomly generated data by using the `--random-source=/dev/urandom` option. Linux’s special file `/dev/urandom` provides an interface to the kernel’s random number generator.
Finally, we’ll use the `-z` (`--zero`) option to overwrite everything thus far with 0.
sudo shred -v -n 1 --random-source=/dev/urandom -z /dev/sdb
Running this command gives us high confidence that restoring the data previously saved on it is virtually impossible once the disk has been erased in this manner.
## Erasing Disk Using wipe Command
You can completely erase data from your disk with the `wipe` command. As the name suggests, the command is used to wipe data from a disk.
The `wipe` command rewrites the sector and flushes the cache, making data recovery impossible or extremely difficult.
However, on most Linux systems, the `wipe` command is not installed by default, so you will need first to install it using your package manager, such as , , , etc. Then, please search for a package named `wipe` and install it.
After that, using the wipe command is relatively straightforward. Just run it, followed by the path to the disk.
sudo wipe /dev/sdb
## Erasing Disk Using dd Command
The `dd` command is another frequently used method for erasing a disk in Linux. Although the command is not explicitly meant to erase data from disk, like `shred` and `wipe` are, it is a widely used approach among Linux users.
For example, run the following command to securely and reliably erase all available information from a disk presented as a `/dev/sdb` device on your Linux system:
sudo dd if=/dev/urandom of=/dev/sdb bs=512 status=progress
The wiping process is successfully finished when `dd` reports “*No space left on device*” and returns control.
Let’s break down the syntax:
* `if` – The input file, we’ve used `/dev/urandom` to produce random data.
* `of` – The output file, in that case – our disk.
* `bs` – This is the block size (in bytes).
It should be noted that the size of the given block size significantly impacts the speed with which the operation will be completed. For example, the process may take days to complete if you choose the default block size value of 512 bytes and erase a multi-terabyte disk.
Therefore, we recommend using a bigger number for the block size when erasing the disk with the dd command, such as `bs=4096` (4 KiB). As a result, this will significantly accelerate the process.
sudo dd if=/dev/urandom of=/dev/sdb bs=4096 status=progress
As can be seen, the operation here takes only 29 seconds, which is seven times faster than the 210 seconds required for an equivalent execution with a block size of 512.
In addition, similar to the above approach, the command below will overwrite the entire disk with strings of zeros rather than producing random data.
sudo dd if=/dev/zero of=/dev/sdb bs=4096 status=progress
However, if security is your top priority, using `/dev/urandom` as more reliable is the way to go.
## Conclusion
This guide shows you how to securely and reliably delete data from your  using three basic Linux tools: shred, wipe, and dd. Whichever method you choose, you can be sure that the information you remove will be nearly impossible to recover.
However, we recommend using the `shred` command as your first choice for safe disk wiping under Linux.
## High Performance VPS Hosting
Check out our NVMe powered KVM VPS plans today for superior performance and network speeds. Multiple global locations available. Free full admin management control panel included.
Tags: , , 