Computer
-
Get Mac hardware model:
1$ sudo dmidecode -s system-product-name 2MacBookAir5,2
Disk
-
Show all S.M.A.R.T. info of a disk:
1$ smartctl -a /dev/ada4
-
Low-level format of the
hdadevice:1$ dd if=/dev/zero of=/dev/hda
-
Same as above but for paranoïd, as random bits will be written 3 times before performing the “low-level format” (i.e. writing zeros):
1$ shred --verbose --force --iterations=3 --zero /dev/hda
Partitions
-
Remove the MBR:
1$ dd if=/dev/null of=/dev/hda bs=446 count=1
-
Restore the original Windows MBR:
1$ apt-get install mbr 2$ install-mbr -i n -p D -t 0 /dev/hda
-
Guess the partition table of a device, including damaged ones:
1$ gpart -v /dev/md0
-
Search for a Linux partition:
1$ sudo fdisk -d /dev/disk0 | cut -d ',' -f 3 | grep --quiet "0x83" 2$ if [[ $? -ne 0 ]]; then 3> echo "No Linux partition found." 4> else 5> echo "Linux partition found." 6> fi
-
Mount an NTFS partition:
1$ sudo ntfs-3g /dev/disk4s2 ./usb-hdd -o local -o allow_other -o auto_xattr -o auto_cache
-
Extract the content of an Apple Disk Image
.dmgfile and access its content:1$ dmg2img ./my-package.dmg 2$ mount -t hfsplus -o loop ./my-package.img /media/my-mount-point
Keyboard
-
Change the keyboard layout in Debian (don’t forget to logoff and logon to activate the new setting):
1$ dpkg-reconfigure keyboard-configuration
-
X.orgs’ configuration (
~/.Xmodmap) to remap function and command keys of a Mac keyboard ( source ):! --- Remove Cmd keys ! Remaps the keys (reading left-to-right): ! -FROM- ! Fn Control_L Alt_L Super_L Space Super_R Alt_R ! -TO- ! Fn Control_L Alt_L Alt_L Space Alt_R Alt_R ! keycode 133 = Alt_L Meta_L Alt_L Meta_L keycode 134 = ISO_Level3_Shift clear Mod1 clear Mod4 clear Mod5 add Mod1 = Alt_L Alt_R Meta_L add Mod4 = Super_L Super_R Super_L Hyper_L add Mod5 = ISO_Level3_Shift Mode_switch
Trackpad
-
X.orgs’ configuration (
~/.Xmodmap) to either set natural or reverse scrolling for Mac trackpads ( source ):! --- Reverse Scrolling !pointer = 1 2 3 5 4 6 7 8 9 10 11 12 13 14 15 ! --- Natural Scrolling pointer = 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
-
To add touchpad kernel support, add the following option to kernel at boot time:
1$ psmouse.proto=imps
-
Sometimes, depending of the laptop I use, the mouse pointer disappear from the screen when I plug a VGA cable to a projector. In this case, I resort to a ++ctrl+alt+f1++, then I login as a normal user and finally I start a new X session:
1$ startx -- :1
Camera
-
Get the number of shutter count of a DSLR (Canon EOS 7D in my case):
1$ gphoto2 --get-config /main/status/shuttercounter 2Label: Shutter Counter 3Type: TEXT 4Current: 49238
Printer
-
List printers:
1$ lpstat -p -d 2printer HP_Color_LaserJet_M254dw_0 is idle. enabled since Fri Nov 6 17:47:06 2020 3system default destination: HP_Color_LaserJet_M254dw_0
1$ lpq 2HP_Color_LaserJet_M254dw_0 is ready and printing 3Rank Owner Job File(s) Total Size 41st kde 209 (stdin) 0 bytes 5active kde 211 HP_Color_LaserJet_Pro_M254_dw_P 33557504 bytes 62nd kde 212 HP_Color_LaserJet_Pro_M254_dw_P 33557504 bytes 73rd kde 213 HP_Color_LaserJet_Pro_M254_dw_P 33557504 bytes