Prelude to FLOW3

Michael Cannon
TYPO3 Vagabond
US, South Korea, Taiwan, India, Germany

Command Line for Newbies

It might be old school, but it's not outdated!
me

Let's Review the Command Line…

Terminology

michael@tlf:~ $
http://www.tuxfiles.org/linuxhelp/shell.html

Command Line Interface (CLI)

Michael's bash environment at https://github.com/typo3-vagabond/skel.git

Which Shell to Use?

http://linuxfinances.info/info/unixshells.html

Shell Recommendations

http://stackoverflow.com/questions/4317247/bash-vs-csh-vs-others-which-is-better-for-application-maintenance

Get the Command Line - Applications to Use

Command Line Basics

Looking Around the CLI

michael@tlf:~ $ pwd
/Users/michael

michael@tlf:~ $ ls
Desktop/	Library/	Sites/

michael@tlf:~ $ ls -l
total 4.0K
drwx------+  6 michael staff  204 Aug 13 10:19 Desktop/
drwx------+ 38 michael staff 1.3K Mar 29 18:31 Library/
drwsrws--x+ 33 michael _www  1.1K Aug 12 11:39 Sites/
http://www.tuxfiles.org/linuxhelp/linuxfiles.html

Looking at Files

michael@tlf:~/tmp $ cat hello.txt 
Hello Phnom Penh

michael@tlf:~/tmp $ less lipsum.txt
http://www.tuxfiles.org/linuxhelp/examinefiles.html

Moving Around the CLI

michael@tlf:~ $ pwd
/Users/michael
michael@tlf:~ $ cd ../; pwd
/Users
michael@tlf:~ $ cd /Users/michael/Sites/; pwd
/Users/michael/Sites
michael@tlf:~/Sites $ cd; pwd
/Users/michael
http://www.tuxfiles.org/linuxhelp/linuxfiles.html
http://myy.helia.fi/~karte/command_line.html

Manipulate Files

michael@tlf:~/hmm $ ls
date.txt
michael@tlf:~/hmm $ cp date.txt today.txt; ls
date.txt  today.txt
michael@tlf:~/hmm $ mv today.txt tomorrow.txt; ls
date.txt  tomorrow.txt
michael@tlf:~/hmm $ rm tomorrow.txt; ls
date.txt
http://www.tuxfiles.org/linuxhelp/fileman.html

Manipulate Directories

michael@tlf:~/hmm $ mkdir dir1; ls
dir1/
michael@tlf:~/hmm $ rmdir dir1; ls

michael@tlf:~/hmm $ rm -r dir1; ls

michael@tlf:~/hmm $ cp -r dir1/ dir2; ls
dir1/  dir2/
michael@tlf:~/hmm $ rmdir dir2; ls
dir1/
michael@tlf:~/hmm $ mv dir1/ dir2; ls
dir2/
http://www.tuxfiles.org/linuxhelp/dirman.html

tab Completion

michael@tlf:~ $ cat /etc/c[tab]
com.apple.named.conf.proxy             csh.login
com.apple.screensharing.agent.launchd  csh.logout
csh.cshrc                              cups/
michael@tlf:~ $ cat /etc/cs[tab]
csh.cshrc   csh.login   csh.logout  
michael@tlf:~ $ cat /etc/csh.l[tab]
csh.login   csh.logout  
michael@tlf:~ $ cat /etc/csh.logout 
http://www.tuxfiles.org/linuxhelp/tabtrick.html

Getting Help

michael@tlf:~ $ man ls

http://www.tuxfiles.org/linuxhelp/manpages.html

Getting Help

michael@tlf:~ $ gzip --help
Usage: gzip [OPTION]... [FILE]...
Compress or uncompress FILEs (by default, compress FILES in-place).

	-c, --stdout      write on standard output, keep original files unchanged
	-d, --decompress  decompress
…
michael@tlf:~ $ man gzip
michael@tlf:~ $ apropos gzip
to-gzip(1)               - converts .Z and .lzo files to gzip format
gzip(1), gunzip(1), zcat(1) - compress or expand files
zforce(1)                - force a '.gz' extension on all gzip files
http://www.tuxfiles.org/linuxhelp/manpages.html

Type Less with Alias Helpers

michael@tlf:~ $ alias la="ls -a" 
michael@tlf:~ $ la
.CFUserTextEncoding    .crash_report_preview  .macports       Library
.DS_Store	       .crash_reportrc	      .matplotlib     Movies

michael@tlf:~ $ alias ll="ls -lh"
michael@tlf:~ $ ll
total 4.0K
drwx------+  8 michael staff  272 Aug 13 13:59 Desktop/
drwsrws--x+ 33 michael _www  1.1K Aug 12 11:39 Sites/

michael@tlf:~ $ alias hisg='history | \grep'
michael@tlf:~ $ hisg cp
2  2012-06-21 17:39:02 vi gitadd gitcp gitrm 
43  2012-06-21 17:58:28 cp cvs2cl.pl cvs2cl.pl.o

michael@tlf:~ $ alias ..="cd .."
http://www.thegeekstuff.com/2009/07/linux-ls-command-examples/

Type Less with Alias Helpers

Command Line Editors – nano & pico

Command Line Editors – vi & vim

Regular Expression Basics - Shell Wildcards

# Move all "linux" named HTML files into directory dir1
michael@tlf:~ $ mv *linux*.html dir1

# List files and directories beginning with mk or git
michael@tlf:~ $ ls {mk,git}*

# List files and directories not starting with letters a to r
michael@tlf:~/bin $ ls [!a-r]*
Wildcard Matches
* zero or more characters
? exactly one character
[abcde] exactly one character listed
[a-e] exactly one character in the given range
[!abcde] any character that is not listed
[!a-e] any character that is not in the given range
{debian,linux} exactly one entire word in the options given
http://www.tuxfiles.org/linuxhelp/wildcards.html

Website Permissions - For Development

http://flow3.typo3.org/documentation/guide/partii/installation.html#file-permissions

Website Permissions - For TYPO3 Development, The Code

cd /Users/michael/Sites/aihrus/

# Recursively change owner to michael and group to www
chown -R michael:www *

# Recursively changing file permissions to remove all access, then grant 
# read/write to files & directories, and execute to directories
chmod -R a=,a-s,u+rwX,g+rwX *

# Correct .htaccess permissions to be readable
chmod a=,a-s,u+rw,g+rw .htaccess

# Enable cron file execution
find . -type f \( -name "*.sh" -o -name "*.phpsh" \) -exec chmod ug+x {} \;

# Enabling SETUID and SETGID on directories - clean ownership
find * -type d ! -type l -exec chmod ug+s {} \;
chmod ug+s /Users/michael/Sites/aihrus/

# Enabling exec on /Users/michael/Sites/aihrus/
chmod a+X /Users/michael/Sites/aihrus/
https://github.com/typo3-vagabond/skel/blob/master/bin/websitepermissions

More Useful Tips

FLOW3 starts and ends on the command line, the IDE is for in between
me

Comments? Questions?

Ask, speak up, mumble aloud

Thank you!

Michael Cannon
TYPO3 Vagabond
michael.cannon@in2code.de