Uly.me

cloud engineer

  • Home
  • About
  • Archives
Home/Archives for terminal

November 29, 2020

Running MySQL commands from the Terminal

You can run MySQL commands from the terminal by using -e switch. Here are a few examples.

mysql -u username -p -e "create database mydb"
mysql -u username -p -e "use mydb"
mysql -u username -p database -e "select * from mytable"

mysql -u username -p -e "create database mydb" mysql -u username -p -e "use mydb" mysql -u username -p database -e "select * from mytable"

If you have .mycnf configured, you can omit the username and password.

mysql -e "create database mydb"
mysql -e "use mydb"
mysql -e "select * from mytable"

mysql -e "create database mydb" mysql -e "use mydb" mysql -e "select * from mytable"

To run multiple commands from a single line, separate the commands using a semicolon.

mysql -e "create database somedb; use mydb; select * from mytable;"

mysql -e "create database somedb; use mydb; select * from mytable;"

July 9, 2020

Linux Format USB Drive

Here’s how to format a USB drive on Linux.

Plug in the USB drive to see mount point.

# scan for all drives
df -Th
Filesystem     Type     Size  Used Avail Use% Mounted on
/dev/sdc1      fuseblk   30G   66M   30G   1% /media/ulysses/451B99AF225B48EC

# scan for all drives df -Th Filesystem Type Size Used Avail Use% Mounted on /dev/sdc1 fuseblk 30G 66M 30G 1% /media/ulysses/451B99AF225B48EC

Unmount USB drive.

umount /dev/sdc1

umount /dev/sdc1

Choose a file system type and run the appropriate format command.

# nfts format
mkfs.ntfs /dev/sdc1
# vfat format
mkfs.vfat /dev/sdc1
# ext4 format
mkfs.ext4 /dev/sdc1

# nfts format mkfs.ntfs /dev/sdc1 # vfat format mkfs.vfat /dev/sdc1 # ext4 format mkfs.ext4 /dev/sdc1

February 5, 2020

Display Sequential Write Throughput

Here’s a dd command to display sequential write throughput from the command line.

time dd if=/dev/zero of=/mounted_backup_volume/zero.raw bs=1M count=512 status=progress

time dd if=/dev/zero of=/mounted_backup_volume/zero.raw bs=1M count=512 status=progress

Output is.

512+0 records in
512+0 records out
536870912 bytes (537 MB) copied, 0.667813 s, 804 MB/s
 
real    0m0.669s
user    0m0.000s
sys     0m0.359s

512+0 records in 512+0 records out 536870912 bytes (537 MB) copied, 0.667813 s, 804 MB/s real 0m0.669s user 0m0.000s sys 0m0.359s

  • 1
  • 2
  • 3
  • Next Page »
  • Cloud
  • Linux
  • Git

Copyright © 2012–2021