How Do? Here’s how.
Need to mount a USB drive on Linux?
First, plug the drive in. Use sudo fdisk -l to view disks attached to the
system. Look for an entry corresponding to the disk you’ve just inserted:
Disk /dev/sda: 119.5 GiB, 128320801792 bytes, 250626566 sectors
Disk model: Flash Drive FIT
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: 4FD2D271-36AF-B847-916F-03EABE1BF0CF
Device Start End Sectors Size Type
/dev/sda1 2048 250626532 250624485 119.5G Linux filesystem
We want the Device here, which is /dev/sda1.
Next, we must prepare a mount point for the disk. Let’s assume this disk will
be known as /mnt/usb-drive:
sudo mkdir /mnt/usb-drive
Now we are ready to mount the drive:
sudo mount /dev/sda1 /mnt/usb-drive
Try accessing the drive:
cd /mnt/usb-drive
ls
Yay! Can we write?
cd /mnt/usb-drive
touch asdf
touch: cannot touch '/mnt/usb-drive/asdf': Permission denied
Oh no! This is happening because the mount directory is owned by root. Change it to your current user with:
sudo chown $USER:$USER /mnt/usb-drive
Let’s try again:
cd /mnt/usb-drive
touch asdf
ls asdf
Yay!
Need to generate a simple calendar for a specific month or year? The cal
command does just that.
Show this month:
% cal
October 2021
Su Mo Tu We Th Fr Sa
1 2
3 4 5 6 7 8 9
10 11 12 13 14 15 16
17 18 19 20 21 22 23
24 25 26 27 28 29 30
31
Show a specific year/month:
% cal 1 2021
January 2021
Su Mo Tu We Th Fr Sa
1 2
3 4 5 6 7 8 9
10 11 12 13 14 15 16
17 18 19 20 21 22 23
24 25 26 27 28 29 30
31
Show a full year:
% cal 2021
2021
January February March
Su Mo Tu We Th Fr Sa Su Mo Tu We Th Fr Sa Su Mo Tu We Th Fr Sa
1 2 1 2 3 4 5 6 1 2 3 4 5 6
3 4 5 6 7 8 9 7 8 9 10 11 12 13 7 8 9 10 11 12 13
10 11 12 13 14 15 16 14 15 16 17 18 19 20 14 15 16 17 18 19 20
17 18 19 20 21 22 23 21 22 23 24 25 26 27 21 22 23 24 25 26 27
24 25 26 27 28 29 30 28 28 29 30 31
31
April May June
Su Mo Tu We Th Fr Sa Su Mo Tu We Th Fr Sa Su Mo Tu We Th Fr Sa
1 2 3 1 1 2 3 4 5
4 5 6 7 8 9 10 2 3 4 5 6 7 8 6 7 8 9 10 11 12
11 12 13 14 15 16 17 9 10 11 12 13 14 15 13 14 15 16 17 18 19
18 19 20 21 22 23 24 16 17 18 19 20 21 22 20 21 22 23 24 25 26
25 26 27 28 29 30 23 24 25 26 27 28 29 27 28 29 30
30 31
July August September
Su Mo Tu We Th Fr Sa Su Mo Tu We Th Fr Sa Su Mo Tu We Th Fr Sa
1 2 3 1 2 3 4 5 6 7 1 2 3 4
4 5 6 7 8 9 10 8 9 10 11 12 13 14 5 6 7 8 9 10 11
11 12 13 14 15 16 17 15 16 17 18 19 20 21 12 13 14 15 16 17 18
18 19 20 21 22 23 24 22 23 24 25 26 27 28 19 20 21 22 23 24 25
25 26 27 28 29 30 31 29 30 31 26 27 28 29 30
October November December
Su Mo Tu We Th Fr Sa Su Mo Tu We Th Fr Sa Su Mo Tu We Th Fr Sa
1 2 1 2 3 4 5 6 1 2 3 4
3 4 5 6 7 8 9 7 8 9 10 11 12 13 5 6 7 8 9 10 11
10 11 12 13 14 15 16 14 15 16 17 18 19 20 12 13 14 15 16 17 18
17 18 19 20 21 22 23 21 22 23 24 25 26 27 19 20 21 22 23 24 25
24 25 26 27 28 29 30 28 29 30 26 27 28 29 30 31
31
MySQL running slow and want to see which queries are running? If you can get a
mysql> prompt, try SHOW PROCESSLIST or SHOW FULL PROCESSLIST.
Need to kill one of those queries? Note its Id value, and run
KILL(803952).
If you ran a git pull and need to revert, you can use git reflog to find
the last revision you were on before you pulled:
~/work/some-project (master) % git reflog
f7da659 HEAD@{0}: pull: Fast-forward
...
~/work/some-project (master) % git reflog
87582cf HEAD@{0}: pull: Fast-forward
f7da659 HEAD@{1}: pull: Fast-forward
...
HEAD@{0} is the commit you just pulled, and HEAD@{1} is the commit that
was checked out before the pull. To revert to it:
git checkout HEAD@{1}
See man git-reflog for more info.
This is my scrappy little microsite for sharing dev and tech knowledge.