Maud  Rosenbaum

Maud Rosenbaum

1597394820

Fdisk Command in Linux (Create Disk Partitions)

The first thing you need to do after installing a new SSD or hard disk is to partition it. A drive needs to have at least one partition before you can format it and store files on it.

In Linux, there are several tools that you can use to create partitions, with fdisk being the most commonly used one.

In this article, we will talk about the fdisk command.

fdisk is a menu-driven command-line utility that allows you to create and manipulate partition tables on a hard disk.

Be aware that fdisk is a dangerous tool and should be used with extreme caution. Only root or users with [sudo](https://linuxize.com/post/sudo-command-in-linux/) privileges can manipulate the partition tables.

List Partitions

To list the partition table of a device, invoke the fdisk command with the -l option, followed by the device name. For example to list the /dev/sda partition table and partitions you would run:

fdisk -l /dev/sda

When no device is given as an argument, fdisk will print partition tables of all devices listed in the /proc/partitions file:

fdisk -l
Disk /dev/nvme0n1: 232.91 GiB, 250059350016 bytes, 488397168 sectors
Disk model: Samsung SSD 960 EVO 250GB               
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: gpt
Disk identifier: 6907D1B3-B3AB-7E43-AD20-0707A656A1B5

Device            Start       End   Sectors   Size Type
/dev/nvme0n1p1     2048   1050623   1048576   512M EFI System
/dev/nvme0n1p2  1050624  34605055  33554432    16G Linux swap
/dev/nvme0n1p3 34605056 488397134 453792079 216.4G Linux filesystem

Disk /dev/sda: 465.78 GiB, 500107862016 bytes, 976773168 sectors
Disk model: WDC WD5000AAKS-0
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0x0001cca3

Device     Boot Start       End   Sectors   Size Id Type
/dev/sda1        2048 976771071 976769024 465.8G 83 Linux

The output above shows the current partition tables of all devices that are attached to your system. Generally, SATA device names follow the pattern /dev/sd[a-z], while NVMe device names have the following pattern /dev/nvme[1-9]n[1-9].

Creating Partition Table

To start partitioning the drive, run fdisk with the device name. In this example we’ll work on /dev/sdb:

fdisk /dev/sdb

The command prompt will change, and the fdisk dialogue where you can type in commands will open:

Welcome to fdisk (util-linux 2.34).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.

Command (m for help):

Changes you make to the partition table won’t take effect until you write them with the w command. You can exit the fdisk dialogue without saving the changes using the q command.

#linux

What is GEEK

Buddha Community

Fdisk Command in Linux (Create Disk Partitions)

Examples of the dig command in Linux

Dig Command Line Options and Examples
Here is the frequently used command line options and example’s of dig command.
1. Basic Dig Command
A basic dig command accept domain name as command line parameter and prints Address record.
2. Query With Specific DNS Server
The default dig command queries to dns server configured on your system. For example, the Linux systems keep default DNS entry in /etc/resolv.conf.
3. Print Short Answer
Use +short command line option to print result in short form. This is basically useful with the shell scripting and other automation tasks.
4. Print Detailed but Specific Result
Use +noall with +answer to print detailed information but specific. This will print only answer section including few more details as a result.

#linux commands #command #dig #dig command #useful examples #linux

Useful Example for the mv command in Linux

mv Command Examples
Below is the basic mv command examples on Linux terminal.

  • Rename file in current directory – For example rename file source.txt to dest.txt in current directory.
  • Move file to destination directory – Move a source.txt file available in current directory to /tmp directory. In above command the file name is unchanged at target directory. You can also rename file name at destination directory just by providing filename at destination.
  • Move file from source directory to destination directory – We can also move files or directory from some other directory to destination directory.
  • Move multiple files to destination at once – The mv accepts multiple source files and move them to the destination directory at once. The following command will move file1.txt, file2.txt in current directory and /opt/file3.txt to the /tmp directory. Here the last command line parameter is used as destination by the mv command.

#linux commands #command #mv #useful example #mv command #linux

date command in Linux with Examples

date Command Examples
Show date time in UTC/GMT
View past dates on specific days
View future dates
View date in other timezone
Print date in specific format
View file modification time

#linux commands #command #date #linux

20 Funny Commands of Linux or Linux is Fun in Terminal

1. Command: sl (Steam Locomotive)

2. Command: telnet

3. Command: fortune

4. Command: rev (Reverse)

5. Command: factor

6. Command: script

7. Command: Cowsay

8. Command: yes

9. Command: toilet

10. Command: cmatrix

#linux commands #terminal #funny commands #linux

I am Developer

1620616862

How to Delete Directories and Files in Linux using Command Line

In this remove or delete directories and files linux tutorial guide, you will learn how to remove empty directory and non empty directory linux using command line. And as well as how to remove/file files linux using command line.

If you work with Linux then you will need the following:

  • how to remove empty directory in linux,
  • how to remove non empty directory,
  • how to remove directory without confirmation linux
  • how to remove files with and without confirmation in linux.

So, this tutorial guide will show you you how to use the rmunlink, and rmdir commands to remove or delete files and directories in Linux with and without confirmation.

https://www.tutsmake.com/how-to-remove-directories-and-files-using-linux-command-line/

#how to delete directory in linux #how to remove non empty directory in linux #remove all files in a directory linux #linux delete all files in current directory #linux delete all files in a directory recursively #delete all files in a directory linux