Latest 100 public snipts »
Fotinakis's
snipts » bash
showing 1-5 of 5 snipts for bash
-
∞ Make copy and transfer entire PostgreSQL DB
pg_dump -d prod_db -U prod_db -h localhost > /tmp/transferdump.sql psql -U prod_db_user -h localhost -t -d other_db -c "SELECT 'DROP TABLE ' || n.nspname || '.' || c.relname || ' CASCADE;' FROM pg_catalog.pg_class AS c LEFT JOIN pg_catalog.pg_namespace AS n ON n.oid = c.relnamespace WHERE relkind = 'r' AND n.nspname NOT IN ('pg_catalog', 'pg_toast') AND pg_catalog.pg_table_is_visible(c.oid)" >/tmp/dropothertables.sql; psql -d other_db -h localhost -U other_db_user < /tmp/dropothertables.sql; psql -d other_db -h localhost -U other_db_user < /tmp/transferdump.sql
-
∞ Bash—please save my history for ever and eternity (or, at least a really long time)
# In .bashrc or .bash_profile export HISTCONTROL=ignoredups:ignorespace export HISTSIZE=10000 export HISTFILESIZE=1000000 export HISTTIMEFORMAT="%F %T " export PROMPT_COMMAND='history -a'
-
∞ Change Linux hostname without reboot
vim /etc/hostname vim /etc/hosts hostname new-hostname
-
∞ Drop all tables from PostgreSQL DB without superuser
psql -t -d my_dbname -c "SELECT 'DROP TABLE ' || n.nspname || '.' || c.relname || ' CASCADE;' FROM pg_catalog.pg_class AS c LEFT JOIN pg_catalog.pg_namespace AS n ON n.oid = c.relnamespace WHERE relkind = 'r' AND n.nspname NOT IN ('pg_catalog', 'pg_toast') AND pg_catalog.pg_table_is_visible(c.oid)" >/tmp/droptables psql -d my_dbname -f /tmp/droptables
-
∞ Hack a Mac, get an admin account
# Hold Command-S to boot into single-user mode # Leopard - OOB reset mount -uw / rm /var/db/.AppleSetupDone reboot # Leopard - delete user mount -uw / rm /var/db/dslocal/nodes/Default/users/<shortname>.plist rm -r /Users/<shortname> halt # Tiger - delete user and OOB reset mount -uw / rm -rf /Users/<shortname> rm -rf /var/db/netinfo/local.nidb rm -rf /var/db/.AppleSetupDone


