Skip to content

Basic Ubuntu commands to install composer, GIT, Gulpjs, files and folder permission, php and mysql etc...

Notifications You must be signed in to change notification settings

thejaydip/ubuntu-command

Repository files navigation

Files and Folder Permission

First of all go to theme directory path, then after apply below commands:

For files permission

sudo find . -type f -exec chmod 644 {} ;

For folders permission

sudo find . -type d -exec chmod 755 {} ;

You can create zip using commands:

zip -r hello-world.zip hello-world

zip -r hello-world-child.zip hello-world-child

zip -r hello-world-addons.zip hello-world-addons

But make sure you neeed to navigate themes folder and plugins folder respectively

File / Folder Permission for specific folder

sudo chmod -R 0777 /var/www/html/demo

sudo chown -R www-data:www-data /var/www/html/demo

Restart Apache 2 web server

/etc/init.d/apache2 restart

OR

sudo /etc/init.d/apache2 restart

OR

sudo service apache2 restart

To stop Apache 2 web server, enter:

/etc/init.d/apache2 stop

OR

sudo /etc/init.d/apache2 stop

OR

sudo service apache2 stop

SSH

CREATE TAR FILE

tar -zcvf public_html_10_july_2018.tar.gz public_html/*

Download Database

mysqldump -u [dbusername] -p [dbpassword] > demo_dev_10_july_2018.sql

Extract TAR

tar -zxvf FILENAME.tar.gz

CREATE DB TAR FILE

tar -zcvf rm_wp_live_22-July-2022.tar.gz rm_wp_live_22-July-2022.sql

Mount File Systems in Linux

For example, to mount the //ServerIP/ServerShare file system to the /mnt/directory directory you would use:

sudo mount //ServerIP/ServerShare /mnt/directory -o username=[username],password=[password],file_mode=0777,dir_mode=0777

Database Import / Export

Export

mysqldump -h localhost -u root -p'mysql123' db-wordpess_demo > dump.sql

Import

mysql -h localhost -u root -p'mysql123' db-wordpess_demo < /home/sys37/Downloads/wordpess-demo.sql

How to Install GIT

git --version

sudo apt update

sudo apt install git

Setting Up Git

Configuration can be achieved by using the git config command.

git config --global user.name "Your Name"

git config --global user.email "youremail@domain.com"

We can display all of the configuration items that have been set by typing:

git config --list

How to Uninstall GIT

To remove just git package itself from Ubuntu 14.04 execute on terminal:

sudo apt-get remove git

Uninstall git and it's dependent packages

sudo apt-get remove --auto-remove git

Purging git

sudo apt-get purge git

sudo apt-get purge --auto-remove git

How to use GIT

Take latest clone from git repo.

git clone https://github.com/[username]/[repository-name].git enter Username and password

Check total branch in existing project:

git branch

Switch new branch for development:

git checkout -b develop

Take latest pull of new created branch:

git pull origin develop

Add New File in your git project

Run git status command to check list of updated files.

Add all updated files in git using

git add -A

Commit all files in git using:

git commit -m "All files uploaded"

Now push all files in git using:

git push origin develop

How to Install composer

Open terminal and type whereis composer, composer should be installed on this path /usr/local/bin/composer
Execute below all command one by one:

composer global require squizlabs/php_codesniffer

composer global require wp-coding-standards/wpcs

composer global require phpcompatibility/php-compatibility

composer global require dealerdirect/phpcodesniffer-composer-installer

Install extension on visual code editor:

(i) PHP Intelephense - Ben Mewburn
(ii) phpcs - Ioannis Kappas
(iii) WordPress Hooks Intellisense - johnbillion

Add below scripts settings.json configuration in visual code ( ctrl + shft + p ):

{
    "php.validate.executablePath": "/usr/bin/php",
    "phpcs.enable": true,
    "phpcs.executablePath" : "/home/[system-name]/.config/composer/vendor/bin/phpcs",
    "phpcs.standard": "WordPress",
    "[php]": {
    	"editor.defaultFormatter": "bmewburn.vscode-intelephense-client"
     },
}

[system-name] - like sys31 or systemdell etc...

Add phpcs.xml and .editorconfig files in the theme directory.

Update PHP

Add the right ppa first, do the following:
  1. sudo add-apt-repository ppa:ondrej/php
  2. sudo apt-get update
  3. sudo apt-get -y install php7.4-common php7.4-mysql libapache2-mod-php7.4 php7.4-mcrypt php7.4-mbstring php7.4-curl php7.4-cli php7.4-mysql php7.4-gd php7.4-intl php7.4-xsl php7.4-zip php7.4-xml
  4. sudo a2dismod php5.6 sudo a2dismod php7.0 sudo a2dismod php7.1 sudo a2dismod php7.2 sudo a2dismod php7.3 sudo a2dismod php8.0 sudo a2dismod php8.1
  5. sudo a2enmod php7.4
  6. sudo update-alternatives --set php /usr/bin/php7.4
  7. sudo systemctl restart apache2
REFERENCE LINKs

https://www.digitalocean.com/community/tutorials/how-to-install-php-7-4-and-set-up-a-local-development-environment-on-ubuntu-18-04

https://www.digitalocean.com/community/tutorials/how-to-install-mysql-on-ubuntu-20-04

Check PHP version

php -v

Check PHP module

php -m

Check Apache version

apache2 -v

How to Install Gulp.js on Ubuntu

Step 1 – Installing Node.js

First of all, you need to install node.js on your system. Use following set of commands to add node.js PPA in your Ubuntu system and install it.

sudo apt-get install python-software-properties

curl -sL https://deb.nodesource.com/setup_12.x | sudo -E bash -

sudo apt-get install nodejs

Make sure you have successfully installed node.js and NPM on your system

node --version

npm --version

Step 2 – Create Sample Application with NPM

Gulp can be easily use in your existing Node.js application. You just need to install Gulp package for Node.js in your project. For this tutorial, I am creating a sample Node.js application with NPM.

mkdir gulp-project && cd gulp-project

npm init

This command will prompt the required information to initialize a new empty project under the current directory.
Input all the required details for your application. At the end, it will show you the details you input and ask you to confirm.
About to write to /root/gulp-project/package.json:
{
  "name": "gulp-project",
  "version": "1.0.0",
  "description": "First gulp application by Tecadmin",
  "main": "index.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "keywords": [
    "gulp",
    "app"
  ],
  "author": "TecAdmin",
  "license": "ISC"
}
Is this OK? (yes)
Just press enter to save all details in package.json file.

Step 3 – Install Gulp.js on Ubuntu

Once you have an node.js application. Use the following commands to install Gulp CLI globally on your system.

npm install -g gulp-cli

Also install the gulp package in your application. Swith to your application directory and execute the following command.

npm install --save-dev gulp

All done, Let’s check the installed version of Gulp CLI on your system and Gulp module in your application with the following command.

gulp --version

Step 4 – Gulp Hello World Example

As you have gulp package added your application and installed gulp-cli on your system.
Next, create a gulpfile.js under the application root directory.
Add a sample code of gulp hello world example program.
var gulp = require('gulp');

gulp.task('hello', function(done) {
  console.log('Hello World!!!');
  done();
})
Save your file and close.
Next run the gulp task with the following command under the application.

gulp hello

Install required gulp modules

npm install gulp-sourcemaps node-sass gulp-clean-css gulp-webserver gulp-sass gulp-ruby-sass gulp-autoprefixer gulp-minify-css gulp-rename gulp-changed gulp-imagemin gulp-concat gulp-uglify main-bower-files gulp-watch gulp-livereload browser-sync --save-dev

About

Basic Ubuntu commands to install composer, GIT, Gulpjs, files and folder permission, php and mysql etc...

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published