Linux commands #2 – some environment variables


$BASH_VERSION                    # bash version
$EDITOR                          # default editor
$GROUPS                          # membership in groups
$HISTFILE                        # user shell`s history file
$HISTSIZE                        # how many commands can be stored in bash $HISTFILE
$HOME                            # home directory
$HOSTNAME                        # hostname
$LANG                            # locale for the shell
$LC_*                            # locale settings that override $LANG
$LC_ALL                          # 
$LD_LIBRARY_PATH                 # paths to search for libraries
$PATH                            # paths to search for commands, priority order
$PS1                             # 
$PS2                             # 
$PWD                             # users working directory
$SHLLVL                          # current shell level
$TZ                              # current time zone if different from system time zone
$UID                             # user id
$VISUAL                          # 

Linux commands #1


readlink /bin/sh           # to which shell points /bin/sh 
echo $SHELL                # current shell 
echo $BASH_VERSION         # bash version
uname                      # distribution
uname -r                   # kernel version
uname -a                   # detailed kernel information
echo hello you             # output some text 
echo \[some \'content\'\]  # escape special characters: *?[]'"\$;&()|^<>
 
pwd                        # current directory
cd ~                       # cd to home 
cd $HOME                   # cd to home 
cd -                       # cd to home and print home dir location
type echo                  # shell built in or external command

 

How I setup my basic Laravel 5.8 project

Make authentication

php artisan make:auth

Create the database (UTF8), modify .ENV file accordingly

CREATE SCHEMA `readxlsx4` DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci;

In the config/database.php edit the mysql section (charset, collation, credentials)

'mysql' => [
            'database' => env('DB_DATABASE', 'forge'),
            'username' => env('DB_USERNAME', 'forge'),
            'password' => env('DB_PASSWORD', ''),
            'charset' => 'utf8',
            'collation' => 'utf8_general_ci',
]

Create default database tables to make authentication work

php artisan migrate

Disable user registration by adding in routes/web.php

Auth::routes(['verify' => true, 'register' => false]);

Create a new controller with model from the console

php artisan make:controller UploadXlsxController --model=UploadXlsx

Make certain routes available for logged in users and for guests

//routes/web.php
Route::group(['middleware' => ['auth']], function () {
    //only authorized users can access these routes
});

Route::group(['middleware' => ['guest']], function () {
    //only guests can access these routes
});

Git console / gitbash – basic console commands

#show commit history
git log

#list files modified on a certain commit
git diff-tree --no-commit-id --name-only -r commit-hash

#list files modified within last 30 days
git diff --name-only "@{30 days ago}"

#list remote branches 
git fetch 
git branch -r 
git ls-remote --heads 
git remote show origin

git branch -vv # list local branches

git checkout -b BRANCHNAME # create a new branch and switch to it
git push --set-upstream origin BRANCHNAME # push your new branch to remote repo

git checkout BRANCHNAME    # switch to a branch BRANCHNAME
git push origin BRANCHNAME # push your branch to github

#merge master branch into feature branch
git checkout F1 # switch to branch F1
git merge master # merge from master branch

# completely remove all staged and unstaged changes to tracked files
git reset --hard

#config
git config --list
git config --global user.name "John Doe"
git config --global user.email johndoe@example.com

#if git is tracking files that should be ignored by .gitignore
git rm -r --cached .
git add .
git commit -m "fixed untracked files"

git branch -d branch_name    #delete local branch
git push origin --delete dev #delete remote branch