Server Files

cp /path/to/source/file /path/to/target/file
Copy file
mv old_name new_name
Rename file (move it within the same directory)
rm -R -f /path/to/directory/to/be/removed
Delete directory and all files inside, -f force without prompt, -i prompt deletion of each file
tail -f C:/wamp/logs/apache_error.log
Watch file. Example above is for watching windows WAMP server error logs which is a web developer must use to discover errors not visible in front end.
tar cvfz target-file.tar.gz source-folder/
Back up Folder. Compress source-folder and all its files into target-file.tar.gz. If you want just files inside without folder run following from inside the folder: tar cvfz target-file.tar.gz *
tar xvfz file.tar.gz
Uncompress (eXtrack) compressed file.tar.gz inside current directory. Files and foldes will be
ln -s /path/to/the/real/file/or/folder symlink_name
Create symlink
unlink symlink_name
Remove symlink
chown -R owner:group directory
Change owner and group recursively on directory and all files inside.
chmod 755 filename
Change permissions.
-R recursive, i.e. include objects in subdirectories
-f force, forge ahead with all objects even if errors occur
-v verbose, show objects processed
7 read, write and execute rwx
6 read and write rw-
5 read and execute r-x
4 read only r--
3 write and execute -wx
2 write only -w-
1 execute only --x
0 none ---
scp somefile.sql.gz
Send file from one srver to another over SCP - no need to download and upload :-)



mysqldump -u dbuser -p dbname | gzip > target-file.sql.gz
Export MYSQL database structure and data as SQL and compress afterwards into target gzip file. SQL includes DROP tABLE IF EXISTS.
To skip some of tables in export use option: --ignore-table=tablename1  --ignore-table=tablename2 ...
Gzip needs to be installed on server. If not use just: mysqldump -u dbuser -p dbname > target-file.sql
zcat /path/source-file.sql.gz | mysql
Import MYSQL database from gzipped source file on Linux.
mysql -u dbuser -p dbname < source-file.sql
Import MYSQL database from source file. On Windows WAMP if "error 2006 MySQL server has gone away" appears set max_allowed_packet = 16M in my.ini
gunzip < source-file.sql.gz | mysql -u dbuser -p dbname
Import directly gzipped SQL file into MySql
mysql -u dbuser -p
Open Mysql console - connect as a db user - password is asked afterwards.

MySql Console

mysql> show databases;
List all available databases
mysql> use dbname;
Switch to a particular database
mysql> show tables;
List all tables in connected database
mysql> describe dbtable;
Show table stucture - columns
mysql> show index from dbtable;
Show table indexes


git branch --set-upstream localBranchName origin/remoteBranchName
Set remote branch to local one to follow.
git commit --amend -m "new amended comment"
Changes (wrong) comment on most recent commit. Only one commit stays in Git.
git tag v2.2.0
git push origin v2.2.0
git tag
Create a tag (local), push to origin, list all tags
git tag -d v2.2.0
git push --delete origin v2.2.0
Delete local tag, delete origin tag.
git fetch --prune --tags
Fetch remote tags - create local ones