Showing posts with label Command Line. Show all posts
Showing posts with label Command Line. Show all posts

Sunday, 10 November 2013

How to run .sh file in Ubuntu command prompt

Give execute permission to your script

Example:

chmod +x /path/to/yourscript.sh


And to run your script

Example:

bash /path/to/yourscript.sh

Wednesday, 18 September 2013

Useful Git Commands

Clone Command:

git clone "Your_remote_source_name"

Check Status:

git status

Create branch:

git branch "Name_of_your_new_branch"

Change branch:

git checkout "Your_branch_name"

View all branch:

git branch

Add project:

git add .

Commit Project:

git commit -m "Your_comments"

Push Project:

git push origin "Your branch Name"

Pull Project:

git pull origin "Your branch Name"

Clone specific branch in git:

git clone -b "Your_branch_name" "Your_remote_source_name"

Rename local branch in git:

git branch -m "old_branch_name" "new_branch_name"

If you want to rename the current branch, you can simply do:

git branch -m "new_branch_name"

Delete specific branch in git:

git branch -D "Your_branch_name"

To Remove deleted files from Git Repository use following command:

git add .
git commit -a -m "Message_in_quote"

Initialize directory and push to remote repository:

git init
git add .
git commit -m "first commit"
git remote add origin your-remote-repo-url
git push -u origin master OR git clone origin master
Reference: https://www.kernel.org/pub/software/scm/git/docs/

Learn Git branching:

https://learngitbranching.js.org/

GitSheet

https://gitsheet.wtf/

Thursday, 28 February 2013

Command Line import-export database in Windows 7

Import .csv file

⇛ Step 1: Copy your desired importing file into the mysql using following steps:

Open the wamp installed folder (lets consider it as a D:\ drive)

D:\wamp\bin\mysql\mysql5.5.20\bin

Paste your database file there (in bin folder)

Right click on (Start->All Programs->Accessories->Command Prompt) Command Prompt and click on ''Run as administrator''

Execute the following command:

D:\wamp\bin\mysql\mysql5.5.20\bin
mysql -p -uusername
Example: mysql -p -uroot

Press ''ENTER'', then it will prompt you to enter the password.  Provide the appropriate password to it, then it will go in mysql mode like this:

mysql>

⇛ Step 2: Select your database name using command

use [database name]
Example: use mydatabase

⇛ Step 3: Here is the following command for importing .csv file (''Make sure that you copied your desired files into bin folder'')

load data local infile 'filename.csv' into table tablename fields terminated by 'terminate character' enclosed by 'enclosed character' lines terminated by 'terminate character'(col1,col2,@ignore, col4);

Example:
load data local infile 'user.csv' into table user fields terminated by '|' enclosed by ' ” ' lines terminated by '\n' (id,username,@ignore, password);

''@ignore'' specifies the extra column in the csv which you don't want to import into the table.

Import .sql file

⇛ Step 1: Use ''same'' step 1 as Import.csv file section

⇛ Step 2: After that for importing .sql from command line you need to use following command

mysql -uusername -p databasename < filename.sql
Example'': mysql -uroot -p mydatabase < user.sql

Export database to the .sql file

⇛ Step 1: Open the command prompt ('''Run as administrator''') and execute following command:

D:\wamp\bin\mysql\mysql5.5.20\bin>

⇛ Step 2: For exporting database from command line you need to use following command

mysqldump -uusername -p databasename > filename.sql
Example: mysqldump -uroot -p mydatabase > mynewdb.sql

Export table to the .sql file

⇛ Step 1: Open the command prompt (''Run as administrator'') and execute following command:

D:\wamp\bin\mysql\mysql5.5.20\bin>

⇛ Step 2: For exporting table from command line you need to use following command

mysqldump -uusername -p databasename tablename > filename.sql
Example: mysqldump -uroot -p mydatabase mytable > newtable.sql

Export Multiple tables to the .sql file

mysqldump -u username -p databasename table1 [table2 ...]> path/to/dump.sql
Example: mysqldump -uroot -p mydatabase tb1 tb2 tb3 > tbsdetails.sql