Commands That Admistrators Need To Know

Commands That Admistrators Need To Know

List the Disk and Partitions On Your Computers

The command lsblk lists information about all available or the specified block devices.

#lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda 8:0 0 477G 0 disk
├─sda1 8:1 0 1G 0 part /boot
├─sda2 8:2 0 460.3G 0 part /
└─sda3 8:3 0 15.7G 0 part [SWAP]
sdb 8:16 0 1.8T 0 disk
├─sdb1 8:17 0 32G 0 part
└─sdb2 8:18 0 1.8T 0 part
sdc 8:32 0 10.9T 0 disk
└─sdc1 8:33 0 10.9T 0 part /raid
sr0 11:0 1 1024M 0 rom

The command fdisk -l gives you more detail than lsblk

[root@fileserver usb]# fdisk -l
Disk /dev/sda: 476.96 GiB, 512110190592 bytes, 1000215216 sectors
Disk model: Samsung SSD 850
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: 0x9489b2d3

Device     Boot     Start        End   Sectors   Size Id Type
/dev/sda1  *         2048    2099199   2097152     1G 83 Linux
/dev/sda2         2099200  967331839 965232640 460.3G 83 Linux
/dev/sda3       967331840 1000214527  32882688  15.7G 82 Linux swap / Solaris




Disk /dev/sdc: 10.94 TiB, 12001212366848 bytes, 23439867904 sectors
Disk model: MR9271-8i
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disklabel type: gpt
Disk identifier: 56B9D1B4-9E8F-4EE2-9416-92B9D1B4

Device     Start         End     Sectors  Size Type
/dev/sdc1   2048 23439861759 23439859712 10.9T Linux filesystem


Disk /dev/sdb: 1.84 TiB, 2000398934016 bytes, 3907029168 sectors
Disk model: PSSD T7
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 33553920 bytes
Disklabel type: dos
Disk identifier: 0xf6a8c918

Device     Boot    Start        End    Sectors  Size Id Type
/dev/sdb1  *        2048   67110911   67108864   32G  c W95 FAT32 (LBA)
/dev/sdb2       67110912 3907024895 3839913984  1.8T  7 HPFS/NTFS/exFAT

Mount and Unmount USB External Disk

Your computer may not auto-mount your USB extern disk. You can use the following command to mount your USB extern drive.

If you don’t have a mount point already, you can create a mount point using

#cd /media
#mk usb

Of course, you can name your point anything you like. So,s instead of calling your mount point usb, you can call it external. So, the command will be

#mk external

Use the following command to mount your USB extern disk:

#mount /dev/sdb2 /medi/usb

Assuming that you want to mount the partition /dev/sdb2.

Before you unmount, ensure you are not currently accessing the drive from any program, including your terminal shells.

Once confirmed, you can use the following command

#umount /media/usb

If you still have a program accessing the USB drive, then you will get the following error message:

umount: /media/usb: target is busy.

Finding Files Using Find Command

The find command is quite useful when you cannot remember a specific file is located on your disk.

#find . -name thisfile.txt

This command will search in the current directory and subdirectories for the filename.

Find Files Containing Texts

#grep -ri "text" --include=*.cpp

This command find all the files with the extension cpp that containing the “text” in the current directory and subdirectories.

Leave a Reply

Your email address will not be published. Required fields are marked *


The reCAPTCHA verification period has expired. Please reload the page.