Tech/Basics/CLI

From lathama
< Tech‎ | Basics
Jump to navigation Jump to search

Command Line Interface (CLI)

A computer interface where the human interacts via text commands on the 'Command Line'

lathama@lappy:~$ uptime 
16:29:58 up 20 days,  6:00,  1 user,  load average: 0.26, 0.51, 0.53
lathama@lappy:~$ date
Wed 14 Jun 2023 04:30:00 PM MDT
lathama@lappy:~$

Command Line Interfaces most commonly use a Tech/Basics/Shell or interpreter to turn the commands into actions


Handy CLI tips and Tricks

Write random to the first 10mb of a device /dev/sdb

dd if=/dev/urandom of=/dev/sdb bs=1M count=10

Rename files to replace spaces with underscores

rename 's/\ /_/g' *
lathama@lappy:/media/lathama/Elise_Trouw-2017-2019$ ls
'09 - How to Get What You Want.mp3'      '1 - Weird Bed.mp3'      '4 - Burn (Loop Version).mp3'  '7 - Replay.mp3'
'10 - Make Believe (Loop Version).mp3'   '2 - Everlove.mp3'       '5 - Make Believe.mp3'         '8 - Sweetwater.mp3'
'11 - Line of Sight (Loop Version).mp3'  '3 - Line of Sight.mp3'  '6 - Elevate.mp3'
lathama@lappy:/media/lathama/Elise_Trouw-2017-2019$ rename 's/\ /_/g' *
lathama@lappy:/media/lathama/Elise_Trouw-2017-2019$ ls
 09_-_How_to_Get_What_You_Want.mp3        1_-_Weird_Bed.mp3      '4_-_Burn_(Loop_Version).mp3'   7_-_Replay.mp3
'10_-_Make_Believe_(Loop_Version).mp3'    2_-_Everlove.mp3        5_-_Make_Believe.mp3           8_-_Sweetwater.mp3
'11_-_Line_of_Sight_(Loop_Version).mp3'   3_-_Line_of_Sight.mp3   6_-_Elevate.mp3

Use progress output with modern dd

dd status=progress if=example.iso of=/dev/sdb

and or add an alias to your bashrc/profile

alias dd="dd status=progress"

Generate Password

Various methods of generating a random password

tr -dc 'A-Za-z0-9!?%=' < /dev/urandom | head -c 20

or

openssl rand -base64 20