Wednesday, 23 November 2011

Some useful command (Mysql Vi etc) Memo

My SQL

Grant a user to a database
mysql>grant all on db_name.* to 'db_username'@'localhost' identified by 'db_userpasswd'
dump a database to a sql file
mysqldump -u root -p --opt leo_db>dump.sql

vi

Auto replace string in vi
:%s/pattern_search_for/new_string_to_be_used/gc

Open and create compressed files

Open files
tar zxvf filename.tar.gz
unzip filename.zip
tar -xvf my.tar
bunzip2 studybuzz.bz2
bzip2 -d studybuzz.bz2
tar jxvf studybuzz.tar.bz2
unrar e test.rar

Create a zip file without parent directory

/test/test.txt
/test/test2.txt
cd test
zip -r -j my.zip *
Create files
zip -r filename.zip filedir
tar -cvf my.tar filedir
Print Env Variables
printenv
curl
curl -H "x-api-key:1234" http://myapi.com/user/1

#The -v option activates verbose mode, revealing detailed communication logs between the client and server
curl -v -H "x-api-key:1234" http://myapi.com/user/1

#curl does not follow HTTP redirects by default. Use the -L, --location option to tell it to do that
curl -L -H "x-api-key:1234" http://myapi.com/user/1

No comments:

Post a Comment