Created by Jim Birch
jimbir.ch/cmd
@thejimbirch
Xeno Media, Inc.
A command-line interface ... is a means of interacting with a computer program where the user (or client) issues commands to the program in the form of successive lines of text (command lines). - Wikipedia
C - Command
L - Line
I - Interface
$ command -flag argument/operand
Most of the time you find commands written, they will be prefaced with a $
$ cd /path/to/folder
$ cd ../../../
to move up the tree.$ cp wp-config-sample.php wp-config.php
$ grep term filetosearchin.txt
$ ls -la
$ mkdir directoryname
$ mv wp-config.php ../
$ pwd
$ rm -rf whatyouwantremoved
$ sudo anycommand
$ touch newfilename.txt
If you enter a screen that has a page of information, like a help screen:
q
to exit.For most cases I have found, flags that are full words use two dashes, flags that are acronyms use one dash.
If you ever need to cancel a command:
Hold the Control key and C
Archive and compress; extract files and folders quickly and easily right from the command line.
zip -r zip-file-name.zip path/to/folder
zip -r zip-file-name.zip file1 file2 file3
unzip zip-file-name.zip
tar -zcvf tar-file-name.tar.gz path/to/folder
tar -zxvf tar-file-name.tar.gz
nano and vi are text editors available in terminal so you can edit files without needing any other programs.
nano file.txt to open a file
Control + (letter) for commands
Control + G for help
vi file.txt to open a file
:help for commands
:i to insert
:w to save
:q to exit
Connect to other servers, like your staging and production environments and run commands as you would on your local command line.
$ ls -al ~/.ssh
ssh-keygen -t rsa -C "[email protected]"
/Users/Jim/.ssh/clientname
ssh [email protected]
nano ~/.ssh/config
Host hostname
User usernameatserver
HostName (IP Address or domain.name)
Port 22
IdentityFile ~/.ssh/id_rsa
ssh hostname
Type exit
Manage MySQL databases from the command line, including importing and exporting.
mysql -u username -p
You will be prompted for password.
* Note: You want to avoid using the password inline, as it would be available in logs
mysql -u username -p < database.sql
mysqldump -u username -p > database.sql
CREATE TABLE newtablename (id INT NOT NULL PRIMARY KEY AUTO_INCREMENT,
name_of_table VARCHAR(30),
sub_title VARCHAR(20),
yes_or_no CHAR(1),
date_of_thing DATE);
WP-CLI is a set of command-line tools for managing WordPress installations. You can update plugins, set up multisite installs and much more, without using a web browser. - wp-cli.org
wp media regenerate
wp post list
wp user delete 123 --reassign=567
wp plugin install hello-dolly
wp help
wp core update
wp theme list
wp package
Drush is a command line shell and Unix scripting interface for Drupal. - drush.org
In computing, alias is a command in various command line interpreters (shells) ... which enables a replacement of a word by another string. - Wikipedia
name="command"
alias name="command"
nano ~/.bash_profile
alias name="command"
nano ~/.bash_aliases
DOSKEY name="command"
alias htdocs="cd /var/www/public_html"
alias backdropcms="cd /Users/Jim/jim.local/backdropcms.org"
alias restart='sudo apachectl restart'
alias bashprofile='sudo nano /Users/Jim/.bash_profile'
alias sshconfig='nano ~/.ssh/config'
alias github='open -a Firefox https://github.com/thejimbirch?tab=repositories\'
Complex Example
Accepts a url, opens chrome in 5 different sized browsers
ln -s /path/to/file /path/to/symlink
Bash-it is a collection of community Bash commands and scripts. (And a shameless ripoff of oh-my-zsh :smiley:)
Includes autocompletion, themes, aliases, custom functions, a few stolen pieces from Steve Losh, and more.
Secure copy or SCP is a means of securely transferring computer files between a local host and a remote host or between two remote hosts. It is based on the Secure Shell (SSH) protocol. - Wikipedia
scp example.txt username@server:myfile.txt
scp serveralias:/var/www/public_html/wp-uploads/* .
scp serveralias:/var/www/public_html/wp-content/files/file1.zip secondserveralias:/var/www/public_html/wp-content/files/file1.zip
Git is a widely used source code management system for software development. It is a distributed revision control system with an emphasis on speed, data integrity, and support for distributed, non-linear workflows. - Wikipedia
git clone repo.url
git fetch
git merge origin/master
git pull
git checkout -b branchname
git diff filename
git add -A
git commit
git push origin master
git log
I use Node.js® to install NPM to install Grunt which installs...
Once these tasks have been assembled in a Gruntfile.js file, you can run the following command to implement these tasks on any changes:
grunt watch
Composer helps you declare, manage and install dependencies of PHP projects, ensuring you have the right stack everywhere.
- Composer on Github
A composer.json file defines all of the things your website needs. These are called dependencies.
This would include Wordpress itself, plugins, and themes. It could also include outside libraries like jQuery, Bootstrap, Foundation, and more.
A composer.json file defines all of the things your website needs. These are called dependencies.
This would include Wordpress/Drupal core, plugins/modules, and themes. It could also include outside libraries like jQuery, Bootstrap, Foundation, Masonry, and more.
If all dependencies are defined in a composer.json file, composer install
could be run to install the site anywhere.
All you would need to do then is setup the database and move the files.
Created by Jim Birch
jimbir.ch/cmd
@thejimbirch
Xeno Media, Inc.