Useful Linux Commands

These are the commands that a Systems Administrator or a DevOps Engineer needs on a daily basis

Basic Configuration Commands

    n

  • Set TimeZone
  • n

dpkg-reconfigure tzdata
    n

  • Set Hostname
  • n

sudo hostnamectl set-hostname exampl.com 

SCP Command

Usage

n

Copy a single file

scp file.txt user@remote_ip:/remote/directory

Copy a folder

scp -r /local/directory user@remote_ip:/remote/directory

Copy file between two remote servers

scp user1@remote_ip1:/files/file.txt user2@remote_ip2:/files

Copy file from a remote server

scp user@remote_ip:/remote/file.txt /local/directory

Deflate .tgz file

Usage

tar -xvzf /path/to/yourfile.tgz

where,

    n

  • x for extract
  • n

  • v for verbose
  • n

  • z for gnuzip
  • n

  • f for file, should come at last just before file name.
  • n

Package Manager Commands

Update APT Silently

sudo apt -qqy update

Docker Commands

nn

Disk Commands

    n

  • Check Read Speeds
  • n

sudo dd if=/dev/zero of=/dev/nvme0n1 bs=1G count=1 oflag=direct
    n

  • Check Write Speeds
  • n

sudo dd if=/dev/nvme0n1 of=/dev/null bs=1G count=1 iflag=direct
    n

  • Run Long SMART Tests on SATA Drives
  • n

sudo smartctl -t long /dev/sdX
    n

  • Check SMART Test Results
  • n

sudo smartctl -a -d ata /dev/sdX
    n

  • Check NVMe Details
  • n

First install nvme-cli

sudo apt install nvme-cli

Run nvme smart log command

sudo nvme smart-log /dev/nvme0

Run long tests on NVMe using nvme-cli

nvme device-self-test --self-test-code 2h /dev/nvme0

More info about the NVMe can be obtained using SMART

sudo smartctl --info /dev/nvme0n1

Leave a Reply

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