git clone https://github.com/mzandrew/bin.git
git diff --cached
find -type f -exec chmod 644 {} +
find -type d -exec chmod 755 {} +
find -type f -exec chmod --changes 644 {} + -o -type d -exec chmod --changes 755 {} +
cat /etc/issue.net
cat /etc/lsb-release
cat /etc/redhat-release # good for scientific linux
uname -a
# idlab server reports: # Linux idlab 2.6.18-371.9.1.el5 #1 SMP Tue Jun 10 17:49:56 EDT 2014 x86_64 x86_64 x86_64 GNU/Linux # cygwin under win7 reports: # CYGWIN_NT-6.1-WOW64 mzatop 1.7.32(0.274/5/3) 2014-08-13 23:03 i686 Cygwin
file /sbin/init
/sbin/init: ELF 64-bit LSB executable, AMD x86-64, version 1 (SYSV), for GNU/Linux 2.6.9, dynamically linked (uses shared libs), stripped
grub rescue > ls (hd0) (hd0, msdos9) grub rescue > ls (hd0,msdos9) grub rescue > ls (hd0,msdos8) grub rescue > ls (hd0,msdos5) # suppose this is linux grub rescue > ls (hd0,msdos5) grub rescue > set root=(hd0,msdos5) grub rescue > set prefix=(hd0,msdos5)/boot/grub grub rescue > insmod normal grub rescue > normalthen, from linux:
sudo update-grub sudo grub-install /dev/sda # If the drive is hd0 the equivalent is sda, if it's hd1 then use sdb
lvm (http://www.linuxuser.co.uk/features/resize-your-disks-on-the-fly-with-lvm)
lvs
pvdisplay
vgdisplay
lvdisplay
fdisk /dev/sdb, mark partition /dev/sdb1 as type 8e
pvcreate vg_data /dev/sdb1
vgcreate -L 1G lv_data vg_data
mkfs.ext4 /dev/mapper/vg_data-lvdata
mount /dev/mapper/vg_data-lvdata
umount /dev/mapper/vg_data-lvdata
lvextend -L +1G /dev/mapper/vg_data-lvdata /dev/sdb1
resize2fs /dev/mapper/vg_data-lvdata
lvextend -r -L +1G /dev/mapper/vg_data-lvdata /dev/sdb1
vgextend vg_data /dev/sdc1
lvextend -L +1G /dev/mapper/vg_data-lvdata /dev/sdc1
resize2fs /dev/mapper/vg_data-lvdata
system-config-lvm
gs -dBATCH -dNOPAUSE -q -sDEVICE=pdfwrite -sOutputFile=out.pdf in1.pdf in2.pdf in3.pdf
sudo chkconfig dhcpd on --level 35 # redhat
sudo update-rc.d ntpd enable 3 # debian
server 0.debian.pool.ntp.org iburstor
server 0.rhel.pool.ntp.org iburstetc
server 127.127.1.0line so your server can get time from itself in case there are network problems connecting to the upstream ntp server
restrict 192.168.1.0 mask 255.255.255.0 nomodify notrap nopeerto allow machines on the local subnet to get the time from your server
chkconfig ntpd on --level 35on redhat, or
sudo update-rc.d ntp enable 3; sudo update-rc.d ntp enable 5on debian to enable it as a runlevel 3/5 service
sudo iptables -I INPUT 1 -p udp --sport 123 -s 192.168.153.0/255.255.255.0 -j ACCEPT
server 192.168.1.1
/usr/sbin/ntpq -pshows whether your machine is connected to an upstream ntp server and how far off your clock is
/usr/sbin/ntpd -gqhas it set the time (even if it was way off), and then quit. Similar to how ntpdate worked.
sudo su
echo 1 > /proc/sys/net/ipv4/ip_forward
/sbin/iptables -t nat -A POSTROUTING -o wlan0 -j MASQUERADE
ifconfig eth0 192.168.10.4 netmask 255.255.255.0
ifconfig eth0 0.0.0.0make sure dhclient is running; if networking came up before the dhcp server was up, you might have to issue
sudo service network restart
ddns-update-style none; ignore client-updates; subnet 192.168.1.0 netmask 255.255.255.0 { option routers 192.168.1.1; option subnet-mask 255.255.255.0; option domain-name-servers 1.2.3.4; # make this some real dns server instead of 1.2.3.4 range dynamic-bootp 192.168.1.200 192.168.1.209; default-lease-time infinite; max-lease-time infinite; next-server 192.168.1.1; filename "/linux-install/pxelinux.0"; host CPR3006 { hardware ethernet 00:00:dd:f0:1d:2d; fixed-address 192.168.1.106; } }
grep DHCPACK /var/log/syslog# or /var/log/messages
yum install system-config-netboot-cmd
pxeos -a -i "centos5.7" -p NFS -D 1 -s 192.168.1.254 -L /srv/diskless/i386/RHEL4S/ centos5.7
pxeboot -a -O centos5.7 192.168.1.196
sudo chkconfig nfs on --level 35and
sudo service nfs (re)start
/usr/sbin/showmount 192.168.1.1 --all
/usr/sbin/showmount 192.168.1.1 --exports
showmount -e serverIP
mkdir mountpoint
sudo mount serverIP:/c/sharename mountpoint
chsh -s /bin/bashchanges your shell to bash
export HISTFILESIZE= export HISTSIZE=
history -w
Host internal HostName 192.168.1.12 ProxyCommand ssh external -W %h:%p ForwardX11 yes
tar cf - dir/ | ssh idlab "cat > backups/backup-of-that-dir.tar"tar up a bunch of files and use ssh to tunnel the data into a file on another machine
kern.=warning /var/log/iptables.logand then do:
sudo service rsyslog restart
/var/log/iptables.log { daily create rotate 7 mailfirst mail me@my.email notifempty dateext }and the system will email you each day that someone tries to ssh in more than 4 times in any 2 minute period (SSHATTACK chain) or any of the other things that end up in the DROPLOG chain. (and see note below about postfix so you don't get emails from root@localhost.localdomain)
AMD/ATI RADEON HD 3450 RV620 LE drivers in 64bit linux:
sudo apt-get install kernel-headersor
sudo yum install kernel-headersmake sure your kernel headers are installed and correspond to the kernel that's running (ie reboot if that's not the case)
sudo apt-get install build-essentialor
sudo yum groupinstall "Development Tools"
sudo ./amd-blah.runin an X session
startxas a regular user and it should work
mkdir ~/.cups echo "remote-server.blah.org" >> ~/.cups/client.conf
lpstat -p # lists all printers lpstat -d # shows default printer lpq # show print queue
cat filename | lpr # print a text file grep -i stasi operatives.txt | lpr # print some text lpr this-file.pdf # print a pdf
crontab -llist crontab
crontab -eedit crontab
# m h dom mon dow command 0 2 * * * (nightlies; nightlies exp; ) >> /home/me/nightlies.cron.log 0 3 * * * (cd /usr/src/uh-svn-repo; svn update; ) >/dev/null
chmod 1777 /tmp
unbind C-b set-option -g prefix F1 bind-key F1 send-prefix
find -not -empty -type f -printf "%s\n" | sort -rn | uniq -d | xargs -I{} -n1 find -type f -size {}c -print0 | xargs -0 md5sum | sort | uniq -w32 --all-repeated=separate(from this command-line fu article)
GID=$(getent group asic | sed -e "s,[^:]*:[^:]:\([0-9]*\):.*,\1,")
myhostname = charlotte.blah.nuto /etc/postfix/main.cf and run
sudo service postfix restartto get mails from your system to appear to come from root@ that email domain
apt-cache search libreadlinepackage search for debian/ubuntu
yum list qt*package search for redhat/fedora/centos
yum grouplistshows a bunch of groups of packages that can be installed
yum groupinstall "Development Tools"is akin to
sudo apt-get build-essential
yum groupinstall "X Window System"
yum groupinstall "GNOME Desktop Environment"
yum install vim-X11
sudo yum install vim-enhanced --installroot=/tftpboot/copper/root/install to a path as if you chroot'ed there first
sudo fixfiles restorefix xauth/.Xauthority problem
wget --spider -o ~/wget.log -e robots=off -w 1 -r -p -np http://www.phys.hawaii.edu/~mza/find broken links
/usr/sbin/useradd -d /home/mza -s /bin/bash mzamake new user and use custom shell
unalias virtuoso
find /blah -maxdepth 1 -mindepth 1 -type d -exec ln -s {} \; -o -type f -exec cp -a {} . \;copy all files, symlink all dirs
alias prepend 'if (-d \!:2) if ("$\!:1" \!~ *"\!:2"*) setenv \!:1 "\!:2":${\!:1}'csh alias to prepend things to the PATH, from utah.edu cadence setup file
alias extend 'if (-d \!:2) if ("$\!:1" \!~ *"\!:2"*) setenv \!:1 ${\!:1}:\!:2'csh alias to append things to the PATH, from utah.edu cadence setup file
%admin ALL= NOPASSWD: ALLand then do
groupadd adminand
/usr/sbin/usermod --append --groups admin steve- steve needs to logout/login if he's currently logged in when you do this
for each; do date=$(stat "${each}" --format="%y" | colrm 11); echo "${each} -> ${date}"; mv "${each}" "${date}.${each}"; donerename files based on the last modification date
lsof /path/to/mountpoint
find -follow -type f -iname "*edif*" -exec tar cf - {} + 2>/dev/null | ssh othermachine "cat > edif-files-from-server.tar"- note that this will likely clobber the tar file if you match more files than will fit on a single line (the + in the find -exec command)
while read line ; do echo "${line}"; done < list-of-files
ForwardX11Trusted yesin ~/.ssh/config
sudo -kin case of "sudo: timestamp too far in the future"
tar cvzf - dir/ | split --bytes=200MB - sda1.backup.tar.gz.split what will otherwise be a large tar file into smaller files (from stackexchange)
split --bytes=2650000000 Xilinx_Vivado_SDK_Lin_2014.4_1119_1.tar.gz Xilinx_Vivado_SDK_Lin_2014.4_1119_1.tar.gz.split a big file into some smaller files; recombine with:
cat Xilinx_Vivado_SDK_Lin_2014.4_1119_1.tar.gz.{aa,ab} > Xilinx_Vivado_SDK_Lin_2014.4_1119_1.tar.gz
find . -type d -exec sh -c "echo -n {}; echo -n ' x '; echo {}" \;execute multiple commands with one find command (from here)
find -type f \( -iname "*scrod*.bit" -o -iname "*carrier*.bit" \) -prune -o -iname "*.bit" -printnote that the -print (or -printf) at the end is crucial!
find -type f -printf "%f\n" | sed -e "s,.*\.\([-a-zA-Z0-9]\+\)$,\1," | sort -ushows a list of file extensions that are present
find -type f -printf "%f\n" | sed -e "s,.*\.\([-a-zA-Z0-9]\+\)$,\1," | sort -u | sed -e "s,^\(.*\)$,*.\1," | xargs -L1 add-up-files | sort -n
less -N blahshow line numbers from less
lf | sort -k 1,1 -k 2,2nlist files; then sort them by date first, and break ties by file size (note date stamp sorting doesn't work if you use the "n" specifier on field 1)
zip -mor0 blah.zip blah# m=delete originals after successful run; o=make modification time of zipfile the same as the last modified file in the archive; r=recurse directories; 0=do not attempt to compress anything