Magento 2 Bootcamp Cheatcheet
Learn, Act, Commit
VI, Linux, Git, Magento Commands
VI Commands
:e filename | Open filename for edition |
:w | Save file |
:q | Exit Vim |
:w! | Write file and quit |
Search
/word | Search word from top to bottom |
?word | Search word from bottom to top |
/jo[ha]n | Search john or joan |
/\< the | Search the, theatre or then |
/the\> | Search the or breathe |
/\< the\> | Search the |
/\< ¦.\> | Search all words of 4 letters |
/\/ | Search fred but not alfred or frederick |
/fred\|joe | Search fred or joe |
/\<\d\d\d\d\> | Search exactly 4 digits |
/^\n\{3} | Find 3 empty lines |
:bufdo /searchstr/ | Search in all open files |
Replace
:%s/old/new/g | Replace all occurences of old by new in file |
:%s/old/new/gw | Replace all occurences with confirmation |
:2,35s/old/new/g | Replace all occurences between lines 2 and 35 |
:5,$s/old/new/g | Replace all occurences from line 5 to EOF |
:%s/^/hello/g | Replace the begining of each line by hello |
:%s/$/Harry/g | Replace the end of each line by Harry |
:%s/onward/forward/gi | Replace onward by forward, case unsensitive |
:%s/ *$//g | Delete all white spaces |
:g/string/d | Delete all lines containing string |
:v/string/d | Delete all lines containing which didn’t contain string |
:s/Bill/Steve/ | Replace the first occurence of Bill by Steve in current line |
:s/Bill/Steve/g | Replace Bill by Steve in current line |
:%s/Bill/Steve/g | Replace Bill by Steve in all the file |
:%s/\r//g | Delete DOS carriage returns (^M) |
:%s/\r/\r/g | Transform DOS carriage returns in returns |
:%s#<[^>]\+>##g | Delete HTML tags but keeps text |
:%s/^\(.*\)\n\1$/\1/ | Delete lines which appears twice |
Ctrl+a | Increment number under the cursor |
Ctrl+x | Decrement number under cursor |
ggVGg? | Change text to Rot13 |
Case
Vu | Lowercase line |
VU | Uppercase line |
g~~ | Invert case |
vEU | Switch word to uppercase |
vE~ | Modify word case |
ggguG | Set all text to lowercase |
:set ignorecase | Ignore case in searches |
:set smartcase | Ignore case in searches excepted if an uppercase letter is used |
:%s/\<./\u&/g | Sets first letter of each word to uppercase |
:%s/\<./\l&/g | Sets first letter of each word to lowercase |
:%s/.*/\u& | Sets first letter of each line to uppercase |
:%s/.*/\l& | Sets first letter of each line to lowercase |
Read/Write files
:1,10 w outfile | Saves lines 1 to 10 in outfile |
:1,10 w >> outfile | Appends lines 1 to 10 to outfile |
:r infile | Insert the content of infile |
:23r infile | Insert the content of infile under line 23 |
File explorer
:e . | Open integrated file explorer |
:Sex | Split window and open integrated file explorer |
:browse e | Graphical file explorer |
:ls | List buffers |
:cd .. | Move to parent directory |
:args | List files |
:args *.php | Open file list |
:grep expression *.php | Returns a list of .php files contening expression |
gf | Open file name under cursor |
Interact with Unix
:!pwd | Execute the pwd unix command, then returns to Vi |
!!pwd | Execute the pwd unix command and insert output in file |
:sh | Temporary returns to Unix |
$exit | Retourns to Vi |
Alignment
:%!fmt | Align all lines |
!}fmt | Align all lines at the current position |
5!!fmt | Align the next 5 lines |
Tabs
:tabnew | Creates a new tab |
gt | Show next tab |
:tabfirst | Show first tab |
:tablast | Show last tab |
:tabm n(position) | Rearrange tabs |
:tabdo %s/foo/bar/g | Execute a command in all tabs |
:tab ball | Puts all open files in tabs |
Window spliting
:e filename | Edit filename in current window |
:split filename | Split the window and open filename |
ctrl-w up arrow | Puts cursor in top window |
ctrl-w ctrl-w | Puts cursor in next window |
ctrl-w_ | Maximise current window |
ctrl-w= | Gives the same size to all windows |
10 ctrl-w+ | Add 10 lines to current window |
:vsplit file | Split window vertically |
:sview file | Same as :split in readonly mode |
:hide | Close current window |
:nly | Close all windows, excepted current |
:b 2 | Open #2 in this window |
Auto-completion
Ctrl+n Ctrl+p (in insert mode) | Complete word |
Ctrl+x Ctrl+l | Complete line |
:set dictionary=dict | Define dict as a dictionnary |
Ctrl+x Ctrl+k | Complete with dictionnary |
Marks
mk | Marks current position as k |
˜k | Moves cursor to mark k |
d™k | Delete all until mark k |
Abbreviations
:ab mail mail@provider.org | Define mail as abbreviation of mail@provider.org |
Text indent
:set autoindent | Turn on auto-indent |
:set smartindent | Turn on intelligent auto-indent |
:set shiftwidth=4 | Defines 4 spaces as indent size |
ctrl-t, ctrl-d | Indent/un-indent in insert mode |
>> | Indent |
<< | Un-indent |
Syntax highlighting
:syntax on | Turn on syntax highlighting |
:syntax off | Turn off syntax highlighting |
:set syntax=perl | Force syntax highlighting |
Linux Commands
System Info
date | Show the current date and time |
cal | Show this month's calendar |
uptime | Show current uptime |
w | Display who is online |
whoami | Who you are logged in as |
finger user | Display information about user |
uname -a | Show kernel information |
File Commands
ls | Directory listing |
ls -l | List files in current directory using long format |
ls -laC | List all files in current directory in long format and display in columns |
ls -F | List files in current directory and indicate the file type |
ls -al | Formatted listing with hidden files |
tree | Directory listing in tree format |
cd dir | Change directory to dir |
cat /proc/cpuinfo | CPU information |
cat /proc/meminfo | Memory information |
df -h | Show disk usage |
du | Show directory space usage |
free | Show memory and swap usage |
Learn the commands
apropos subject | List manual pages for subject |
man -k keyword | Display man pages containing keyword |
man command | Show the manual for command |
man -t command | ps2pdf -> command.pdf | Make a pdf of a manual page |
which command | Show full path name of command |
time command | See how long a command takes |
whereis app | Show possible lcoations of app |
which app | Show which app will be run by default; it shows the full path |
Searching
grep pattern files | Search for pattern in files |
grep -r pattern dir | Search recusrively for pattern in dir |
command | grep pattern | Search for pattern in the output of command |
locate file | Find all instances of file |
find / -name filename | Starting with the root directory, look for the file called filename |
find / -name "*filename* | Starting with the root directory, look for the file containing the string filename |
locate file | Find all instances of file |
updatedb | Create or update the database of files on all file systems attached to the Linux root directory |
which filename | Show the subdirectory containing hte executalbe file called filename |
grep TextStringToFind /dir | Starting with the directory called dir, look for and list all files containing TextStringToFind |
File Permissions
chmod octal file | Change the permissions of file to octal which can be found separately for user, group and world by adding: 4 - read (r), 2 - write (w), 1 - execute (x) |
chmod 777 | read, write, execute for all |
chmod 755 | rwx for owner, rx for group and world. For more options see man chmod.dir |
cd | Change to home |
mkdir dir | Create a directory dir |
pwd | Show current directory |
rm name | Remove a file or directory called name |
rm -r dir | Delete directory dir |
rm -f file | Force remove file |
rm -rf dir | Force remove an entire directory dir and all it's included files and subdirectories (use with extreme caution) |
cp file1 file2 | Copy file1 to file2 |
cp -r dir1 dir2 | Copy dir1 to dir2; create dir2 if it doesn't exist |
cp file /home/dirname | Copy file to the /home/dirname directory |
mv file /home/dirname | Move the file to the /home/dirname directory |
mv file1 file2 | Rename or move file1 to file2; if file2 |
ln -s file link | Create symbolic link link to file |
touch file | Create or update file |
cat > file | Places standard input into file |
cat file | Display the file called file |
more file | Display the file called file one page at a time, proceed to next page using the spacebar |
head file | Output the first 10 lines of the file called file |
head - 20 file | Output the first 20 lines of the file called file |
tail file | Output the last 10 lines of the file called file |
tail -20 file | Output the last 20 lines of the file called file |
tail -f file | Output the contents of file as it grows, starting with the last 10 lines |
Compression
tar cf file.tar files | Create a tar named file.tar containing files |
tar xf file.tar | Extract the files from file.tar |
tar czf file.tar.gz files | Create a tar with Gzip compression |
tar xzf file.tar.gz | Extract a tar using Gzip |
tar cjf file.tar.bz2 | Create a tar with Bzip2 compression |
tar xjf file.tar.bz2 | Extract a tar using Bzip2 |
gzip file | Compresses file and renames it to file.gz |
gzip -d file.gz | Decompresses file.gz back to file |
Network
ifconfig | List IP addresses for all devices on the local machine |
iwconfig | Used to set the parameters of the network interface which are specific to the wireless operation (for exmple: the frequency) |
iwlist | Used to display some additional information from a wireless network interface that is not displayed by iwconfig |
ping host | Ping host and output results |
whois domain | Get whois information for domain |
dig domain | Get DNS information for domain |
dig -x host | Reverse lookup host |
wget file | Download file |
wget -c file | Continue a stopped download |
SSH
ssh user@host | Connect to host as user |
ssh -p port user@host | Connect to host on port port as user |
ssh-copy-id user@host | Add your key to host for user to enable a keyed or passwordless login |
User Administration
adduser accountname | Create a new user called accountname |
passwd accountname | Give accountname a new password |
su | Login as superuser from current login |
exit | Stop being superuser and revert to normal user |
Process Management
ps | Display your currently active processes |
top | Display all running processes |
htop | Display all running processes |
kill pid | Kill process id pid |
killall proc | Kill all processes named proc (use with extreme caution) |
bg | Lists stopped or background jobs; resume a stopped job in the background |
fg | Brings the most recent job to foreground |
fg n | Bring job n to the foreground |
Installation from package manager
apt-get install apache2 | Install Apache2 (Debian / Ubuntu /Linux Mint) |
apt-get install -y apache2 | Install Apache2 without confirm (Debian / Ubuntu /Linux Mint) |
apt-get install -y apache2 && apt-get install -y php-fpm | Install Apache2 and PHP-FPM without confirm |
Installation from source
./configure | |
make | |
make install | |
dpkg -i pkg.deb | Install a DEB package (Debian / Ubuntu / Linux Mint) |
rpm - Uvh pkg.rpm | Install an RPM package (Red Hat / Fedora) |
Stopping & Starting
shutdown -h now | Shutdown the system now and do not reboot |
halt | Stop all processes - same as above |
shutdown -r 5 | Shutdown the system in 5 minutes and reboot |
shutdown -r now | Shutdown the system now and reboot |
reboot | Stop all processes and then reboot - same as above |
service apache2 start|stop|restart | Start the Apache2 system |
service varnish start|stop|restart | Star the Varnish system |
GIT Commands
git init
git remote add origin [eigen link]
git fetch
git checkout [branch]
git add --all
git commit -m "comment"
git push origin [branch]
Or create a new respository from the command line
echo "# [repo name]" >> README.md
git init
git add README.md
git commit -m "first commit"
git remote add origin git@github.com:[alias]/[branch].git
git push -u origin master
Or push an existing repository from the command line
git remote add origin git@github.com:[alias]/[branch].git
git push -u origin master
Setup
Configuring user information used across all local repositories
git config --global user.name "firstname lastname" | Set a aname that is identifiable for credit when reviewing version history |
git config --global user.email "email" | Set an email address that will be associated with each history marker |
git config --global color.ui auto | Set automatic command line coloring for Git for easy reviewing |
Init
Initializing and cloning repositories
git init | Initialize an existing direcotry |
git clone url | Retrieve an entire repository from a hosted location via url |
Stage & Snapshot
Working with snapshots and the Git staging area
git status | Show modified files in working directory, staged for your next commit |
git add [file] | Add file as it looks now to your next commit (stage) |
git reset [file] | Unstage file while retaining the changes in working directory |
git diff | Show a diff of what is changed but not staged |
git diff --staged | Show a diff of what is staged but not yet committed |
git commit -m "descriptive message" | Commit your staged content as a new commit |
Branch & Merge
Isolating work in branches, changing context and integrating changes
git branch | List your branches. A * will appear next to the currently active branch |
git branch [branch-name] | Create a new branch with name branch-name at the current commit |
git checkout | Switch to another branch and check it out into your working directory |
git merge [branch] | Merge the history of branch with name branch into the current one |
git log | Show all commits in the current branch's history |
Inspect & Compare
Examining logs, diffs and object information
git log | Show the commit history for the currently active branch |
git log branchB..branchA | Show the commits on branchA that are not on branchB |
git log --follow [file] | Show the commits that changed file, even across renames |
git diff branchB...branchA | Show the diff of what is in branchA that is not in branchB |
git show [SHA] | Show any object in Git in human-readable format |
Tracking path changes
Versioning file removes and path changes
git rm [file] | Deletes file from project and stage the removal for commit |
git mv existing-path new-path | Change an existing file path and stage the move |
git log --stat -M | Show all commit logs with indication of any paths that moved |
Ignoring Patterns
Preventing unintentional staging or committing files
logs/
*.notes
pattern*/
Save a file with desired patterns as .gitignore with either direct string matches or wildcard globs.
git config --global core.excludesefile [file] | Systemwide ignore pattern for all local repositories |
Share & Update
Retrieving updates from another repository and updating local repos
git remote add [alias] [url] | Add a git url as an alias |
git fetch [alias] | Fetch down all the branches from that Git remote |
git merge [alias]/[branch] | Merge a remote branch into your current branch to bring it up to date |
git push [alias] [branch] | Transmit local branch commits to the remote repository branch |
git pull | Fetch and merge any commits from the tracking remote branch |
Rewrite history
Rewriting branches, updating commits and clearing history
git rebase [branch] | Apply any commits of current branch ahead of specified one |
git reset --hard [commit] | Clear staging area, rewrite working tree from specified commit |
Temporary commits
Temporarily store modified, tracked files in order to change branches
git stash | Save modified and staged changes |
git stash list | List stack-order of stashed file changes |
git stash pop | Write working from top of stash stack |
git stash drop | Discard the changes from top of stash stack |
Magento 2 Commands
Usage:
command [options] [arguments]
Options
--help (-h) | Displays help message |
--quiet (-q) | Do not output any message |
--verbose (-v|vv|vvv) | Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug |
--version (-V) | Display this application version |
--ansi | Force ANSI output |
--no-ansi | Disable ANSI output |
--no-interaction (-n) | Do not ask any interactive question |
Available commands
help | Displays help for a command |
list | Lists commands |
Admin
admin:user:create | Creates an administrator |
admin:user:unlock | Unlock admin account |
Cache
cache:clean | Cleans cache type(s) |
cache:disable | Disables cache type(s) |
cache:enable | Enables cache type(s) |
cache:flush | Flushes cache storage used by cache type(s) |
cache:status | Checks cache status |
Catalog
catalog:images:resize | Creates resized product images |
Cron
cron:run | Runs jobs by schedule |
Customer
customer:hash:upgrade | Upgrade customer's hash according to the latest algorithm |
Deploy
deploy:mode:set | Set application mode |
deploy:mode:show | Displays current application mode |
Dev
dev:source-theme:deploy | Collects and publishes source files for theme |
dev:tests:run | Runs tests |
dev:urn-catalog:generate | Generates the catalog of URNS to *.xsd |
dev:xml:convert | Converts XML file using XSL style sheets |
i18n
i18n:collect-phrases | Discovers phrases in the codebase |
i8n:pack | Saves language package |
i18n:uninstall | Uninstalls language packages |
Indexer
indexer:info | Shows allowed indexers |
indexer:reindex | Reindexes data |
indexer:set-mode | Sets index mode type |
indexer:show-mode | Shows index mode |
indexer:status | Shows status of indexer |
Maintenance
maintenance:allow-ips | Sets maintenance mode exempt IPs |
maintenance:disable | Disables maintenance mode |
maintenance:enable | Enables maintenance mode |
maintenance:status | Displays maintenance mode status |
Module
module:disable | Disables specified modules |
module:enable | Enables specified modules |
module:status | Displays status of modules |
module:uninstall | Uninstalls modules installed by composer |
Sampledata
sampledata:deploy | Deploy sample data modules |
sampledata:remove | Remove all sample data from composer.json |
sampledata:reset | Reset sample data modules for re-installation |
Theme
theme:uninstall | Uninstalls theme |
Info
info:adminuri | Displays the Magento Admin URI |
info:backups:list | Prints list of available backup files |
info:currency:list | Displays the list of available currencies |
info:dependencies:show-framework | Shows number of dependencies on Magento framework |
info:dependencies:show-modules | Shows number of dependencies between modules |
info:dependencies:show-modules-circular | Shows number of circular dependencies between modules |
info:language:list | Displays the list of available language locales |
info:timezone:list | Displays the list of available timezones |
Setup
setup:backup | Takes backup of Magento Application code base, media and database |
setup:config:set | Creates or modifies the deployment configuration |
setup:cron:run | Runs cron job scheduled for setup application |
setup:db-data:upgrade | Installs and upgrades data in the DB |
setup:db-schema:upgrade | Installs and upgrades the DB schema |
setup:db:status | Checks if the DB schema or data requires upgrade |
setup:di:compile | Generates DI configuration and all non-existing interceptors and factories |
setup:di:compile-multi-tenant | Generates all non-existing proxies and factories, and pre-compile class definitions, inheritance information and plugin definitions |
setup:install | Installs the Magento application |
setup:performance:generate-fixtures | Generates fixtures |
setup:rollback | Rolls back Magento Application codebase, media and database |
setup:static-content:deploy | Deploys static view files |
setup:store-config:set | Installs the store configuration |
setup:uninstall | Uninstalls the Magento application |
setup:upgrade | Upgrades the Magento application, DB data, and schema |