Conquering the Command Line

75 %
25 %
Information about Conquering the Command Line
Technology

Published on March 6, 2014

Author: aramonc

Source: slideshare.net

Description

An introduction to the *nix command line environment for those responsible for uploading and maintaining WordPress sites

Conquering the Command Line Making WordPress Work

About Me ● Developer at ServerGrove ● All around nerd ● Systems Administrator for 7 years ● @aramonc in all the places

Why bother? More than 40% of all web servers use Linux Debian Ubuntu CentOS/RHEL SmartOS* Servers do not use graphical interfaces *Not really Linux, still Unix based

What if I mess up?

Navigating the Folder = Directory Tree

Where are you right now? Print Working Directory $>pwd /var/www/wp_site ● /var/www/wp_site = a path ● / not ● Starts with / (root) = absolute

What’s in here? LiSt $>ls index.php license.txt readme.html wp-activate.php wp-admin wp-blog-header.php wp-comments-post.php wp-config-sample.php wp-includes wp-links-opml.php wp-load.php wp-login.php wp-mail.php wp-settings.php wp-signup.php wp-trackback.php

What’s in here? LiSt $>ls -la total 320 drwxr-xr-x drwxr-xr-x -rw-r--r--@ -rw-r--r--@ -rw-r--r--@ -rw-r--r--@ drwxr-xr-x@ drwxr-xr-x@ -rw-r--r--@ 21 3 1 1 1 1 88 5 1 adrian_sg root adrian_sg adrian_sg adrian_sg adrian_sg adrian_sg adrian_sg adrian_sg wheel wheel wheel wheel wheel wheel wheel wheel wheel 714 102 640 418 19929 7185 2992 170 2932 Feb Feb Mar Sep Jan Jan Jan Jan Sep 28 28 05 24 18 13 23 23 24 22:07 21:57 20:14 20:18 2013 13:16 15:17 15:17 20:18 . .. .htaccess index.php license.txt readme.html wp-admin wp-content wp-cron.php

Moving around... Change Directory $>cd wp-admin $>pwd /var/www/wp_site/wp-admin $>cd /var/www/wp_site $>pwd /var/www/wp_site $>cd wp-content/themes/twentyfourteen $>pwd /var/www/wp_site/wpcontent/themes/twentyfourteen

Moving around... Change Directory $>cd .. $>pwd /var/www/wp_site $>cd ~/ $>pwd /Users/adrian_sg $>cd $>pwd /var/www/wp_site

Where is this thing? Find $>find . -iname xml* /var/www/wp_site/xmlrpc.php $>find . -ctime 3 . (dot) means current directory -ctime in 24 hour increments of creation date

Where is this thing? Globally search a Regular Expression and Print $>grep theme ./* ./index.php: * wp-blog-header.php...the theme. grep: ./wp-admin: Is a directory ./wp-settings.php:require(ABSPATH.WPINC.'/theme.php'); ./wp-settings.php:do_action( 'setup_theme' );

Where is this thing? Globally search a Regular Expression and Print $>grep -R theme ./* ./wp-admin/update.php: ./wp-admin/update.php: ./wp-admin/update.php: $parent_file='themes.php'; $submenu_file='themes.php'; $nonce='install-theme_'.$theme;

Can I change things? Owners, Groups, & Permissions $>ls -l total 320 -rw-r--r--@ 1 adrian_sg -rw-r--r--@ 1 adrian_sg -rw-r--r--@ 1 adrian_sg drwxr-xr-x@ 88 adrian_sg drwxr-xr-x@ 5 adrian_sg -rw-r--r--@ 1 adrian_sg drwxr-xr-x@ 122 adrian_sg -rw-r--r--@ 1 adrian_sg wheel wheel wheel wheel wheel wheel wheel wheel 418 19929 7185 2992 170 2932 4148 2359 Sep Jan Jan Jan Jan Sep Jan Oct 24 18 13 23 23 24 23 24 20:18 2013 13:16 15:17 15:17 20:18 15:17 18:58 index.php license.txt readme.html wp-admin wp-content wp-cron.php wp-includes wp-load.php

Can I change things? Permissions r = Read w = Write x = Execute (run a script or open a directory) Three levels of permissions: Owner, Group, Everyone else

Can I change things? Owner = User ● Sometimes your user ● Sometimes root ● Sometimes www-data (Apache user)

Can I change things? Group ● Permissions for a set of users ● Users have own group ● Most users only belong to own group

Can I change things? Permissions $>ls -l drwxr-xr-x@ Is Dir.? 88 adrian_sg wheel 2992 Jan 23 15:17 wp-admin Group adrian_sg d Owner wheel rwx r-x Everyone r-x

How do I change this thing? MaKe DIRectory $>mkdir -p useless/stuff $>ls -l -rw-r--r--@ -rw-r--r--@ -rw-r--r--@ drwxr-xr-x -rw-r--r--@ 1 1 1 2 1 adrian_sg adrian_sg adrian_sg adrian_sg adrian_sg wheel 418 Sep 24 20:18 index.php wheel 19929 Jan 18 2013 license.txt wheel 7185 Jan 13 13:16 readme.html wheel 68 Mar 3 22:04 useless wheel 4892 Oct 4 10:12 wp-activate.php

How do I change this thing? MoVe $>mv readme.html useless/stuff/readme $>ls -l -rw-r--r--@ -rw-r--r--@ drwxr-xr-x -rw-r--r--@ 1 1 2 1 adrian_sg adrian_sg adrian_sg adrian_sg wheel 418 Sep 24 20:18 index.php wheel 19929 Jan 18 2013 license.txt wheel 68 Mar 3 22:04 useless wheel 4892 Oct 4 10:12 wp-activate.php

How do I change this thing? CoPy $>cp wp-config-sample.php wp-config.php $>ls -l -rw-r--r--@ -rw-r--r--@ -rw-r--r--@ drwxr-xr-x@ 1 1 1 5 adrian_sg adrian_sg adrian_sg adrian_sg wheel 4795 Sep 5 wheel 3087 Oct 24 wheel 3087 Mar 3 wheel 170 Jan 23 21:38 18:58 21:59 15:17 ● cp -a keeps same permissions as original wp-comments-post.php wp-config-sample.php wp-config.php wp-content

When everything goes wrong... Read the log file $>less /var/log/apache2/error_log

When everything goes wrong... Read the log file ● ● ● ● ● ● ● (up arrow) to scroll towards the top (down arrow) to scroll towards the bottom (space) next page p previous page q(uit) to exit / <expression> to search for <expression> n to search again

But I only care about the last error... Read the last few lines of the log file $>tail -n 5 /var/log/apache2/error_log [Mon Mar 03 10:28:01 2014] [notice] Digest: generating secret for digest authentication ... [Mon Mar 03 10:28:01 2014] [notice] Digest: done [Mon Mar 03 10:28:01 2014] [notice] Apache/2.2.26 (Unix) DAV/2 PHP/5.5.4 mod_ssl/2.2.26 OpenSSL/0.9.8y configured -- resuming normal operations [Mon Mar 03 13:40:08 2014] [notice] child pid 8870 exit signal Bus error (10) [Mon Mar 03 18:02:20 2014] [notice] caught SIGTERM, shutting down

I only care about the current error... Read the log file as it happens $>tail -f /var/log/apache2/error_log [Mon Mar 03 10:28:01 2014] [notice] Digest: generating secret for digest authentication ... [Mon Mar 03 10:28:01 2014] [notice] Digest: done [Mon Mar 03 10:28:01 2014] [notice] Apache/2.2.26 (Unix) DAV/2 PHP/5.5.4 mod_ssl/2.2.26 OpenSSL/0.9.8y configured -- resuming normal operations [Mon Mar 03 13:40:08 2014] [notice] child pid 8870 exit signal Bus error (10) [Mon Mar 03 18:02:20 2014] [notice] caught SIGTERM, shutting down [Mon Mar 03 20:18:01 2014] [notice] Apache/2.2.26 (Unix) DAV/2 PHP/5.5.4 mod_ssl/2.2.26 OpenSSL/0.9.8y configured -- resuming normal operations ● -f is interactive ● Ctrl+C to exit interactive

Who is currently on my site? Read the access log as it happens $>tail -f /var/log/apache2/*access_log ::1 - - [26/Dec/2013:09:35:23 -0500] "OPTIONS * 127.0.0.1 - - [26/Dec/2013:09:35:34 -0500] "GET 127.0.0.1 - - [26/Dec/2013:09:35:34 -0500] "GET 127.0.0.1 - - [26/Dec/2013:09:36:40 -0500] "GET 127.0.0.1 - - [26/Dec/2013:09:36:42 -0500] "GET HTTP/1.0" 200 / HTTP/1.1" 200 44 /favicon.ico HTTP/1.1" 404 209 / HTTP/1.1" 304 / HTTP/1.1" 304 -

How do I change this thing Nano text editor $>nano wp-config.php

How do I change this thing Nano text editor $>nano wp-config.php ^G ^R ^K ^X ^W ^U Get Help Read File Cut Text Exit Where Is UnCut Text ^O ^Y ^C ^J ^V ^T WriteOut Prev Page Cur Pos Justify Next Page To Spell

Putting it all together Deep filtering with the pipe statement $>tail -n 10000 /var/log/apache2/error_log | grep “Mar 01” | less Look for any log entry that occurred on March 1st within the last ten thousand lines of the error log and display it in a way I can easily navigate

Putting it all together Chaining commands with & $>mkdir -p /var/www/wp_site/news && wget http://wordpress.org/latest.zip && unzip latest.zip -d /var/www/wp_site/news Make news directory under /var/www/wp_site, then download latest version of WordPress, then extract the contents of the archive to /var/www/wp_site/news

Putting it all together Creating files without a text editor $>mkdir -p wp-content/uploads && echo e "RemoveHandler .php .phtml .php3 php4nRemoveType .php .phtml .php3 php4" > wp-content/uploads/.htaccess Make a new uploads directory in wp-content, then create a .htaccess file in uploads with the contents of “RemoveHandler .php .phtml .php3 php4 RemoveType .php .phtml .php3 php4”

Resources ● Usage Share of Server OSes ● http://linuxcommand.org/ ● In The Beginning Was the Command Line ● 5-Minute Essential Shell Tutorial

Questions?

Thank you! http://www.slideshare.net/aramonc/conquering-the-command-line

Add a comment

Comments

buy runescape million | 29/12/14
Omg, It's a good post! Like you, Thanks! Excuse me, Please look at my username! Buying runescape million. buy runescape million http://www.rs4golds.com/
wow stuff | 29/12/14
hi guy cool stuff wow stuff http://www.wow345.com/
rs items | 02/01/15
Omg, That's a nice post! Like you, Thanks! Excuse me, Please click on my username! Buying runescape million. rs items http://www.rs4golds.com/
rs account | 03/01/15
Hi, It's a good post! Excuse me, Please click on my username! Buying runescape million. rs account http://www.rs4golds.com/
Ardmxurtof | 14/06/16
Gtczxvdg http://fxfskrddfbxdf.com here: Gtczxvdg http://fxfskrddfbxdf.com best Gtczxvdg http://fxfskrddfbxdf.com http://fxfskrddfbxdf.com - Maefegvtjy dfsdgbcdsHLBHFDasufksdfjln http://fxfskrddfbxdf.com - Maefegvtjy Ozxcjkl http://fxfskrddfbxdf.com - Maefegvtjy dfdfdfdsdgd FGxczDHXfgvdhjhjhjhsdadddfxgbnbm

Related presentations

Presentación que realice en el Evento Nacional de Gobierno Abierto, realizado los ...

In this presentation we will describe our experience developing with a highly dyna...

Presentation to the LITA Forum 7th November 2014 Albuquerque, NM

Un recorrido por los cambios que nos generará el wearabletech en el futuro

Um paralelo entre as novidades & mercado em Wearable Computing e Tecnologias Assis...

Microsoft finally joins the smartwatch and fitness tracker game by introducing the...

Related pages

Softcover.io - Conquering the Command Line, Unix and Linux ...

Conquering the Command Line Unix and Linux Commands for Developers Mark Bates. Learn to master and conquer the most valuable and useful command line tools ...
Read more

From Bash to Z Shell: Conquering the Command Line: Amazon ...

Englischsprachige Bücher: From Bash to Z Shell: Conquering the Command Line bei Amazon: Schnelle Lieferung Kostenloser Versand für Bücher
Read more

Chapter 3: cURL | Conquering the Command Line | Softcover.io

Conquering the Command Line Unix and Linux Commands for Developers Mark Bates. Learn to master and conquer the most valuable and useful command line tools ...
Read more

Books by Mark Bates

Conquering the Command Line. Learn to master and conquer the most valuable and useful command line tools for Unix and Linux based systems. In this book you ...
Read more

From Bash to Z Shell: Conquering the Command Line

Thanks for visiting this book's website. The site also has links and other information. (Suggestions are always welcome! Our email address is below.)
Read more

From Bash to Z Shell: Conquering the Command Line: Oliver ...

Buy From Bash to Z Shell: Conquering the Command Line on Amazon.com FREE SHIPPING on qualified orders
Read more

From Bash to Z Shell: Conquering the Command Line

From Bash to Z Shell: Conquering the Command Line OLIVER KIDDLE, JERRY PEEK, AND PETER STEPHENSON ... Case Study 3: Locating Command-Line Arguments 359
Read more

Downloads for Conquering the Command Line | Softcover.io

Conquering the Command Line Unix and Linux Commands for Developers Mark Bates. Learn to master and conquer the most valuable and useful command line tools ...
Read more

Conquering the Command Line: Unix and Linux Commands for ...

Title Conquering the Command Line: Unix and Linux Commands for Developers; Author(s) Mark Bates; Publisher: ConqueringTheCommandLine.com (January 2014)
Read more

From Bash to Z Shell: Conquering the Command Line im ...

From Bash to Z Shell 'From Bash to Z Shell: Conquering the Command Line' is a comprehensive, hands-on guide to the subtleties and power of the shell ...
Read more