Sign up to create your own snipts, or login.

Public snipts » Fotinakis's snipts » bash The latest bash snipts from Fotinakis.

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
    

    copy | embed

    0 comments - tagged in  posted by Fotinakis on Jul 28, 2009 at 6:15 p.m. EDT
  • Bash—please save my history for ever and eternity (or, at least a really long time)
    # In .bashrc or .bash_profile
    export HISTSIZE=2048
    export HISTFILESIZE=1048576
    

    copy | embed

    0 comments - tagged in  posted by Fotinakis on Jul 02, 2009 at 6:33 p.m. EDT
  • Change Linux hostname without reboot
    vim /etc/hostname
    vim /etc/hosts
    hostname new-hostname
    

    copy | embed

    0 comments - tagged in  posted by Fotinakis on Jun 15, 2009 at 1:18 p.m. EDT
  • 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
    

    copy | embed

    0 comments - tagged in  posted by Fotinakis on Apr 28, 2009 at 12:09 p.m. EDT
  • 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
    

    copy | embed

    0 comments - tagged in  posted by Fotinakis on Apr 23, 2009 at 12:22 p.m. EDT
Sign up to create your own snipts, or login.