script favs
|
Run sc to get the latest list:
-----------------------------------------------
/^\v/^\v/^\v/^\v/^\v/^\v/^\v/^\v/^\v/^\v/^\v/^\
-----------------------------------------------
useful commands and scripts
_______________________________________________
\v/^\v/^\v/^\v/^\v/^\v/^\v/^\v/^\v/^\v/^\v/^\v/
---------------------------------------------
i3[scriptname] run an i3-specific script
equery files pkg show package files, use |less
elogv[iewer] browse recent emerges and comments
edit_fluxbox_menu edit and apply fb menu changes
edit_firewall edit, restart iptables w/screen
mdb-[] access db tools
gtdm;gw;gd;gwa go to tdm|wimpy|dune|wally via ssh
greplogs [term] search logs for term [-C 3]
grepcode [term] search code in curr dir for term
ds [dir] get directory sizes
pk [proc_regex] kill matches - type ALL for -9
lsof -c [proc] show open files for process
which|whereis app show app location|paths
alsamixer adjust sound levels
eq finally an eq in linux, yay!
watch [command] repeatedly run command
rs restore screen (w/detach)
st;gt search/get torrents
post_torrent run from m@wimpy:rrip/flac (or mp3)
srd [#] show most recent downloads
move_and_resymlink symlink destdir
resymlink symlink destdir (if file is already there)
rm_torrent.pl torrent cleanup; run for usage
extract_tordir extract dir from .torrent
ls_broken_symlinks uses curr dir
ls_nonsymlinks uses curr dir
rm_broken_symlinks uses curr dir, WILL rm THEM
td;etd show/edit active todo w/cvs
top top resource-consuming procs
apachetop -f log site-specific apache requests
ex;em emacs with/without X
uc;cm cvs update/commit (no message)
sp;ep search/edit private data
edit_spam_[rules|settings] what it says
edit_sieve_rules edit mailfilter rules
tree -fid -L 1 great tree display of dir & files
edit_torrent_[] shows (common) or rss (rare)
search_xbmc_keys search key file for term
edit_world edit portage master pkg list
xscreensaver-demo then select Disable to turn off
recordmydesktop does what it says
bandwidth monitor current bw usage
edit_rsync_jobs edit bp<->tdm nightly rsync
trac-tda $1 $2 trac admin tool, RUN AS ROOT
erase_trac_ticket_block 17 20 blah (run as root)
update_ampache_tda update music catalog, RUN AS ROOT
edit_gentoo_grub_cfg set up gentoo kernels on 3-boot
htdj/*_scripts/push_release(.bat)
get_ampache_official changes
publish_hangthedj_ampache_module
get_ampache_official changes
cdh;huc;hcm;hpush scripts to manage hangthedj repos
also see scripts/git_* helpers
ec2-ubuntu-ssh ssh to amazon ec2 server
mp3search search (and optionally copy mp3s
|
Disabling xscreensaver
|
emacs ~/.xscreensaver
timeout: 12:00:00 # the max timeout is 12 hours
crontab -e
# So... I have .xscreensaver set to max delay (12 hours)
# and I call this every ten hours to restart the idle timer.
* */10 * * * /usr/bin/xscreensaver-command --deactivate >/dev/null
|
linux software raid [mdraid]
|
mdraid has not received the polish it needs to Just Work. It has serious flaws that after hours of learning, still leave you unsure and hanging and most likely bailing out of the entire process. But it is the best thing we have on the planet, so let’s distill it down to the essentials.
- check S.M.A.R.T. data of drives – run tests and make sure they are completely healthy!
- clean raid drives of superblock and partition data
mdadm --misc --zero-superblock /dev/sdd && dd if=/dev/zero of=/dev/sdd bs=1M count=100 && mdadm --examine /dev/sdd
mdadm: No md superblock detected on /dev/sdd.
- use whole drives (not drive partitions) in a newly created raid
mdadm --create --verbose /dev/md0 --level=mirror --raid-devices=2 /dev/sdd /dev/sde
mdadm: size set to 3906887488K
mdadm: automatically enabling write-intent bitmap on large array
Continue creating array? yes
mdadm: Defaulting to version 1.2 metadata
mdadm: array /dev/md0 started.
watch -n 1 cat /proc/mdstat
# wait 400 FUCKING MINUTES for a GODDAMNED EMPTY 4TB DRIVE to sync with ANOTHER empty 4TB drive, FUCKSAKE
# IF YOU REBOOT BEFORE THAT, IT WILL BE AS IF YOU NEVER SET UP A RAID
- save and reboot and make sure the mdraid service restores the raid
mdadm --detail --scan >>/etc/mdadm.conf
rc-update add mdraid boot
# start then stop then start the /etc/init.d/mdraid service, make sure this works to restore your raid (check /proc/mdstat)
# format /dev/md0 as ext4 and set up an auto mount point in /etc/fstab
# reboot and pray
- hopefully much later, upon failure, to restore a single drive, set it up as a raid:
madadm -A /dev/sdd # I THINK! it's all very iffy. Which SUCKS.
|
Adding a new drive (with testing)
|
To add a new drive:
- ls /dev/sd* # and make note of what you have
- stuff the new drive in the SATA tower or plug it into a SATA socket
- ls /dev/sd* # you should now see something new, like [/dev/sdf]
- or do: cat /var/log/messages|grep sd # to see what it used
- EITHER: parted /dev/sdf
- print # should show nothing or errors
- mklabel gpt # this sets the drive up for "big" >2TGB partition labeling - WARNING: TRASHES EVERYTHING ON THE DRIVE
- mkpart primary ext4 0 -1s # makes an ext4 primary partition that goes from start (0) to end (-1s), yay
- quit # yeah weird but that's how you exit, things are changed as you go (oops should have told you that before)
- OR USE: gpart /dev/sdg # a bit cleaner than parted it seems, either works
- n
- (use defaults, including 8300 for linux file type)
- w
- mkfs.ext4 -m 0 /dev/sdf1 # the [-m 0] is very important; without it, goofy ext4 wastes 5% "saved for root" wtf
- mount /dev/sdf1 /somewhere # make sure it looks good!
# install smartctl tools
smartctl -c /dev/sdf # to peek at available tests and how long they typically take to run
smartctl -t short /dev/sdf
watch -n 3 smartctl -l selftest /dev/sdf # until success, takes about 1 minute
# if you're feeling ambitious, rerun with [-t long]
- umount # we are NOT going to be manually mounting! we need to label the drive and put it in /etc/fstab
- e2label /dev/sdb1 box-type-sizename # what a stupid f'in name for that util
- emacs /etc/fstab - and put in an entry like this:
/dev/disk/by-label/box-type-sizename /my-mount-location ext4 noatime 0 2
- mount /my-mount-location # now it will be there when you reboot! but do this to get it NOW :-)
- Note that if you mount the new drive under /spiceflow, samba will already be serving it up, whoop!
|
thedigitalmachine LAN IP addresses
|
We want all IP address management to happen on the Buffalo DD-WRT router, as much as possible.
Ideally, static IPs will be served up to every known box based on MAC address.
Then no matter what OS is booted, the machine will have the same name and IP address.
The router is slick, it can do it, but be careful to Save AND Apply changes there.
DHCP dynamic assignment IP range is 2...99, keep static IPs out of this range.
every [/etc/hosts] should include this block:
# ========================================================================================
# MDM My LAN names v10
192.168.21.1 tdm
192.168.21.200 buffalo # hardcoded Buffalo DD-WRT router IP
# MDM Buffalo DHCP-provided static IPs assigned by MAC addresses
# It's important to assign static IPs via router
# It will always give the same IP regardless of OS
# And it has the ability to provide the names via local DNS (I think!)
# NOTE THAT 192.168.21.2-99 are RESERVED for dynamic IPs
192.168.21.132 wimpy # F4-6D-04-25-9C-60
192.168.21.133 wallee-wireless # macbook pro 00:26:bb:07:d3:7d
192.168.21.134 wallee # macbook pro 00:26:4a:18:ed:58
192.168.21.140 babe # andrea's ipad2 04:54:53:3A:7B:2A
192.168.21.179 dune # 00:1f:e2:07:2d:0e
# TO BE ADDED UPDATED AND VERIFIED AS NEEDED
# NOTE THAT 192.168.21.2-99 are RESERVED for dynamic IPs
192.168.21.4 darthfun # mike's iphone 00:26:B0:99:7F:7E
192.168.21.5 eetee # ipod touch 8gb 00:26:b0:59:4a:94
192.168.21.6 sweepea # girl's d-link card 00:1e:58:96:3a:2a
192.168.21.7 wiihii # wii 00:21:47:ba:c8:c2
192.168.21.8 iroku # roku wired 00:0d:4b:49:a6:30
192.168.21.9 irokit # roku wireless 00:0d:4b:49:a6:31
192.168.21.10 wynter # bailey's win7 laptop 00:11:F5:89:7B:00
192.168.21.11 hermione # andrea's dell inspiron 00:24:D6:78:42:A8
192.168.21.12 toothless # wren's eee 1C:4B:D6:A3:E1:28
192.168.21.13 dunno # 00:0f:b5:f6:99:d2
192.168.21.16 jackwhite # wren's iphone 54:26:96:BB:A4:CD
192.168.21.193 hermione-wired
192.168.21.194 toothless-wired # MAC address 48:5B:39:2B:8F:E8
192.168.21.195 6c-blade1
# ========================================================================================
|
Adding a user to the server
|
su -
useradd #newuser# -m -G wheel(,etc)
# Other possibilities (likely not needed):
## only needed if you want them to have their own group (otherwise use "users" group)
#groupadd #newuser#
## the additional groups here are optional
#useradd #newuser# -m -g #newuser# -G users,wheel,audio,video,games,dvd,usb -s /bin/bash
## Only needed if you didn't use [-m] option
#mkdir /home/#newuser#
#chown #newuser#:users /home/#newuser#
passwd #newuser#
# grant ssh access by adding to "AllowUsers"
em /etc/ssh/sshd_config
/etc/init.d/sshd restart
# grant samba access to home folder
# it's already set up in /etc/samba/smb.conf
# but the user must be manually added to samba
# use same pwd as before to sync them
smbpasswd -a #newuser#
/etc/init.d/samba restart
# YOU PROBABLY HAVE TO RESTART ANY STUPID WINDOWS BOX before it will see things correctly! crazy
# you can try this in Windows but it didn't work for me:
# net use
# net session \\samba.server.ip.address /delete
|
Check disk speed
|
To check SATA capability:
bitpost ~ # hdparm -I /dev/disk/by-label/reservoir-3g-mel |grep -i speed
* Gen1 signaling speed (1.5Gb/s)
* Gen2 signaling speed (3.0Gb/s)
* Gen3 signaling speed (6.0Gb/s)
To test read speed:
bitpost ~ # hdparm -tT /dev/disk/by-label/reservoir-3g-mel
/dev/disk/by-label/reservoir-3g-mel:
Timing cached reads: 33760 MB in 2.00 seconds = 16900.70 MB/sec
Timing buffered disk reads: 274 MB in 3.00 seconds = 91.28 MB/sec
You can use dd to check speed, too:
dd conv=fdatasync if=/dev/zero of=/spiceflow/newraid-4tb-bp/dd_test_output.dat bs=8k count=256k
=256k
262144+0 records in
262144+0 records out
2147483648 bytes (2.1 GB) copied, 4.57219 s, 470 MB/s
# don't forget to clean up..
rm /spiceflow/newraid-4tb-bp/dd_test_output.dat
|
Updating mediawiki installation
|
cd /var/www/localhost/htdocs/mediawiki
emacs LocalSettings_redirector.php (to hardcode each site)
php maintenance/update.php
(repeat for each site)
emacs LocalSettings_redirector.php (to reset dynamic behavior)
|
Creating a new ssh key pair for no-password access to a remote system
|
Say you've got a new machine with user [m] and you want to connect to it, do this:
- install sshd, make sure it's running
- get on the new machine - ssh to the new machine by typing the password if you don't have direct access
- $ scp m@tdm:.ssh/id_rsa .ssh/
- $ scp m@tdm:.ssh/authorized_keys .ssh/
wow I just had serious issues with basic ssh usage, so i'll put a summary on the wiki
basically most misunderstandings stem from describing these two:
client: machine that is trying to ssh into the server
server: machine that the client user wants to get to
most poor sots are just sitting on the client
and they create a pair and push their public key to the server
but in my case, more often, i want to create a pair on the server
and push the private key to the multiple places i need to connect FROM
when doing that, you have to push the public key into the server's authorized_keys
and configure the client to juggle multiple private keys
create a key pair:
ssh suser@server
ssh-keygen
use defaults
will create:
.ssh/id_rsa (private key)
.ssh/id_rsa.pub (public key)
put the public key in place:
cd .ssh
cat id_rsa.pub >>authorized_keys
put the private key on the client and configure:
scp id_rsa cuser@client:.ssh/id_rsa_server
ssh cuser@client
em .ssh/config
Host tdm thedigitalmachine.com
Hostname thedigitalmachine.com
IdentityFile ~/.ssh/id_rsa
User m
Host server
Hostname server.com
IdentityFile ~/.ssh/id_rsa_server
User suser
all is full of light
|
Back up a linux system to a second bootable drive
|
Steps:
- We want to copy all files from the root drive to a new drive.
- We also want to update the boot menu to boot off the new drive.
- We also want to change /etc/fstab on the second drive to use the new root path.
These are the steps for backup of the dune box to the /spiceflow/2.0tb-newmovies/ drive.
When we're done, we'll boot from that drive to prove we have a working standby system.
rsync does an excellent job of copying just what we need. Test it with this:
# a (archive mode -rlptgoD) v (verbose) x (don't cross filesystems) h (human-readable) n (dry run)
rsync -avxhn --progress / /spiceflow/2.0tb-newmovies/
Do the job with this:
rsync -avxh / /spiceflow/2.0tb-newmovies/
sent 28.10G bytes received 8.64M bytes 15.63M bytes/sec
total size is 39.57G speedup is 1.41
There was def some old stuff in there worth cleaning up:
/home/m/development/svn/mythtv...
/var/tmp
xbmc log files
etc
Next we fix /etc/fstab on the new drive to use the drive as root. Original config:
/dev/disk/by-label/d-g2-root / ext3 noatime 0 1
/dev/disk/by-label/d-sp-20newmovies /spiceflow/2.0tb-newmovies ext4 noatime 0 2
New config (remember tho, we lose the 2gb drive):
/dev/disk/by-label/d-g2-root /root-hot-drive ext3 noatime 0 1
/dev/disk/by-label/d-sp-20newmovies / ext4 noatime 0 2
Note: this never worked out for me due to my system's mix of ext3 and ext4.
I'll retry once I migrate everything to ext4.
Next, grub:
mount /boot
em /boot/grub/menu.lst
Orig entry:
title ----- linux-2.6.34-gentoo-r11_withext4
root (hd0,0)
kernel /boot/linux-2.6.34-gentoo-r11_withext4 root=/dev/sda4
Add a new "standby" entry under it - do a "df" to find the root:
title ----- ==STANDBY== linux-2.6.34-gentoo-r11_withext4
root (hd0,0)
kernel /boot/linux-2.6.34-gentoo-r11_withext4 root=/dev/hda1
Then reboot to standby and see what we have... (no "latest" video library etc., but otherwise the same?)
|
wallee gentoo networking
|
Laptop has both wired and wifi adapters.
We set up custom network interface names to make it more clear.
I had installed several tools when attempting to get this going. DO NOT DO THAT, they interfere with one another. Removing NetworkManager and going with the highly-recommended wpa_supplicant and its graphical tools wpa_gui and wpa_cli.
I'm documenting this since it's so basic yet such a bitch.
/etc/udev/rules.d/76-mdm-net.rules
# This file was automatically generated by the /lib/udev/write_net_rules
# program, run by the persistent-net-generator.rules rules file.
#
# You can modify it, as long as you keep each rule on a single
# line, and change only the value of the NAME= key.
# MDM following this to change nw interface names:
# http://www.gentoo.org/doc/en/handbook/handbook-x86.xml?part=4&chap=2
#
# verified MAC addresses
# changed eth0 line to lan0
# changed eth1 line to wifi0
# PCI device 0x10de:0x0ab0 (forcedeth)
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:26:4a:18:ed:58", ATTR{dev_id}=="0x0", ATTR{type}=="1", KERNEL=="eth*", NAME="lan0"
# PCI device 0x14e4:0x432b (wl)
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:26:bb:07:d3:7d", ATTR{dev_id}=="0x0", ATTR{type}=="1", KERNEL=="eth*", NAME="wifi0"
Next you have to set up these weird symlinks:
cd /etc/init.d
ln -s net.lo net.lan0
ln -s net.lo net.wifi0
Now add them to runlevels:
rc-update add net.lan0 default
rc-update add net.wifi0 default
Now add them to runlevels:
rc-update add net.lan0 default
rc-update add net.wifi0 default
Fix the system so that only one is required for startup to work...
/etc/rc.conf
rc_depend_strict="NO"
No, we're not even close to done yet...
We have to CUT the firmware out of the proprietary driver. Wow.
su -
emerge -av b43-fwcutter # NOT THIS, DAAAMN: bcm43xx-fwcutter
emerge -av sys-firmware/b43-firmware
export FIRMWARE_INSTALL_DIR="/lib/firmware"
mkdir macbook_bcm43xx_wireless_driver
cd macbook_bcm43xx_wireless_driver
wget http://www.lwfinger.com/b43-firmware/broadcom-wl-5.100.138.tar.bz2
tar xjf broadcom-wl-5.100.138.tar.bz2
b43-fwcutter -w "$FIRMWARE_INSTALL_DIR" broadcom-wl-5.100.138/linux/wl_apsta.o
modprobe b43
/etc/init.d/net.wifi0 start
Nope. What a fuckbucket of retardedness.
Look at the notes this guy made - brief but heavy - i think i need to purge b43 and get the "wl" driver working instead.
|
rtorrent keys
|
rtorrent CAN actually work pretty well, IF you pay attention to these basic keys:
- enter - specify a torrent file to load - USE TAB COMPLETION
- ctrl-d - STOP torrent, smack that shit, delete it forever
- ctrl-s - START torrent - WARNING ONLY WORKS IF YOU DISABLE TERMINAL CAPTURE with...
stty stop undef
stty start undef
- ctrl-o - change download dir
- ctrl-k - close files - needed before ctrl-o, usually
- ctrl-r - recheck hash
NOW GET rutorrent going! :-)
|
rtorrent fix torrents that didn't move into place properly
|
* if the torrent is archived properly, use move_and_resymlink to move it:
cd ~/download/torrents/archived/symlinks
move_and_resymlink [symlink] [destdir]
- if things are a mess due to hard drive failure (etc), you should do this:
- use r(u)torrent to see where rtorrent thinks the files are
- copy the files, if available, to the final destination (under a .* dir in symlinks)
- create a symlink: ln -s .music/Fresh/ELO-Secret\ Messages ELO-Secret\ Messages
- close the torrent files (ctrl-k), move the destination (ctrl-o), start again (ctrl-s)
|
|