2. About Me Lorna Mitchell Developer at Ibuildings European Rep for http://phpwomen.org Personal blog http://lornajane.net Compulsive keyboard user (for accessibility reasons)
7. pwd Print Working Directory - shows you where you are lorna@taygete:~/Documents$ pwd /home/lorna/Documents
8. ls list files -a for all including hidden files lorna@taygete:~/Documents$ ls - a . jam_labels.pdf netball .. libmemcache_install_notes.txt tek_instructions.txt advent_web_services.rtf linux - fu_geekup.txt using_the_community.txt girlgeek_post2.txt memcache.odt jam_labels.odt memcache.rtf
9. ls -l for long list ls -la lorna@taygete:~/Documents$ ls - la total 136 drwxr - xr - x 3 lorna lorna 4096 2009 - 04 - 24 09 : 37 . drwxr - xr - x 66 lorna lorna 4096 2009 - 04 - 23 17 : 33 .. - rw - r -- r -- 1 lorna lorna 16790 2008 - 12 - 04 22 : 54 advent_web_services.rtf - rw - r -- r -- 1 lorna lorna 1263 2008 - 12 - 10 12 : 16 girlgeek_post2.txt - rw - r -- r -- 1 lorna lorna 10700 2008 - 12 - 20 16 : 08 jam_labels.odt - rw - rw - rw - 1 lorna lorna 6747 2008 - 12 - 25 21 : 35 jam_labels.pdf - rw - r -- r -- 1 lorna lorna 316 2009 - 03 - 19 19 : 28 libmemcache_install_notes.txt - rw - r -- r -- 1 lorna lorna 189 2009 - 02 - 08 16 : 02 linux - fu_geekup.txt - rw - r -- r -- 1 lorna lorna 33275 2008 - 12 - 04 11 : 37 memcache.odt - rw - r - xr -- 1 lorna users 28205 2008 - 12 - 04 11 : 37 memcache.rtf drwxr - xr - x 2 lorna lorna 4096 2009 - 04 - 24 09 : 37 netball - rw - r -- r -- 1 lorna lorna 940 2008 - 12 - 09 09 : 43 tek_instructions.txt - rw - r -- r -- 1 lorna lorna 461 2008 - 11 - 28 22 : 49 using_the_community.txt
10. ls -t for list by time -r for sort in reverse order lorna@taygete:~/Documents$ ls - lrt total 128 - rw - r -- r -- 1 lorna lorna 461 2008 - 11 - 28 22 : 49 using_the_community.txt - rw - r -- r -- 1 lorna lorna 33275 2008 - 12 - 04 11 : 37 memcache.odt - rw - r - xr -- 1 lorna users 28205 2008 - 12 - 04 11 : 37 memcache.rtf - rw - r -- r -- 1 lorna lorna 16790 2008 - 12 - 04 22 : 54 advent_web_services.rtf - rw - r -- r -- 1 lorna lorna 940 2008 - 12 - 09 09 : 43 tek_instructions.txt - rw - r -- r -- 1 lorna lorna 1263 2008 - 12 - 10 12 : 16 girlgeek_post2.txt - rw - r -- r -- 1 lorna lorna 10700 2008 - 12 - 20 16 : 08 jam_labels.odt - rw - rw - rw - 1 lorna lorna 6747 2008 - 12 - 25 21 : 35 jam_labels.pdf - rw - r -- r -- 1 lorna lorna 189 2009 - 02 - 08 16 : 02 linux - fu_geekup.txt - rw - r -- r -- 1 lorna lorna 316 2009 - 03 - 19 19 : 28 libmemcache_install_notes.txt drwxr - xr - x 2 lorna lorna 4096 2009 - 04 - 24 09 : 37 netball
11. ls ls <path> to list contents of a different directory
12. cd Change Directory cd <dir> to enter a subdir cd .. to go up a level lorna@taygete:~$ cd /etc lorna@taygete:/etc$ cd cron.d lorna@taygete:/etc/cron.d$ lorna@taygete:/etc/cron.d$ cd .. lorna@taygete:/etc$
13. cd cd ~ to go home cd - to go back to where you came from lorna@taygete:/etc$ cd ~ lorna@taygete:~$ pwd /home/lorna lorna@taygete:~$ lorna@taygete:~$ cd - lorna@taygete:/etc$ pwd /etc
15. touch creates an empty file with current timestamp no feedback (this is *nix) lorna@taygete:~/talks/temp$ touch unicorns.txt lorna@taygete:~/talks/temp$ ls - lA total 0 - rw - r -- r -- 1 lorna lorna 0 2009 - 04 - 24 09 : 50 unicorns.txt
16. cat outputs a file to your terminal cat <file> lorna@taygete:~/talks$ cat orange.txt Oranges are not the only fruit ( name of a book ) lorna@taygete:~/talks$
17. less/more pager for viewing longer content more <file> less <file> use less – it really is more in this case
18. stdin/stdout stdin "standard in" – input to a program, usually command line arguments stdout "standard out" – output, usually to your screen
21. pipe cat orange.txt index.php | more lorna@taygete:~/talks$ cat orange.txt index.php | more Oranges are not the only fruit ( name of a book ) < ?php class Response { public function output () { header ( 'Content-type: text/xml' ); echo '<?xml version="1.0"?>' ; echo " " ; } } -- More --
22. file redirection operators a.k.a. "pointy brackets" < and > > directs stdout to the named file >> appends to the file rather than truncating it before outputting
23. file redirection operators lorna@taygete:~/talks$ mysqldump -- compact - u root - p test Enter password : SET @saved_cs_client = @@character_set_client ; SET character_set_client = utf8 ; CREATE TABLE `users` ( `user_id` int ( 11 ) NOT NULL auto_increment , `name` varchar ( 20 ) default NULL , PRIMARY KEY ( `user_id` ) ) ENGINE = MyISAM AUTO_INCREMENT = 2 DEFAULT CHARSET = latin1 ; SET character_set_client = @saved_cs_client ; INSERT INTO `users` VALUES ( 1 , 'lornajane' );
24. file redirection operators lorna@taygete:~/talks$ mysqldump -- compact - u root - p test > test .sql Enter password : [email_address] :~/talks$ lorna@taygete:~/talks$ mysqldump -- compact - u root - p test | gzip > test .sql.gz Enter password : [email_address] :~/talks$
25. file redirection operators < directs the contents of the file to stdin lorna@taygete:~/talks$ mysql - u root - p test < test .sql Enter password : lorna@taygete:~/talks$
27. telnet not now used much for server access useful for direct port access telnet <host> <port>
28. ssh Secure SHell prompts for password, you arrive at command prompt
29. scp secure copy copies files over a one-off ssh connection if you have ssh access, this is available scp <source> <target> source and/or target can be remote paths
50. wget to mirror a site wget -m http://lornajane.net to resume large downloads wget -c http://localhost
51. grep finding things (Global/Regular Expression/Print) grep [options] [pattern] [target]
52. grep discover functions lorna@rivendell:~/svndir/snapshot/lib$ grep function Service.class.php * This class holds the functionality of the out - ward facing part of * This function is called to add a new request to the queue. public function requestShot ( $accountID , $requestURL , $returnURL = NULL , $height = 75 , $width = 100 ) { function getShotStatus ( $accountID , $transactionID ) { function getAccountStatus ( $accountID ) { function getShotList ( $accountID , $status = NULL ) { function getShot ( $accountID , $transactionID ) {
53. grep look for class names in source tree lorna@rivendell:~/svndir/phergie$ grep - R '^class ' * | grep - v .svn | more Phergie / Event / Response.php : class Phergie_Event_Response Phergie / Event / Request.php : class Phergie_Event_Request Phergie / Driver / Streams.php : class Phergie_Driver_Streams extends Phergie_Driver_A bstract Phergie / Plugin / Drink.php : class Phergie_Plugin_Drink extends Phergie_Plugin_Abstr act_Command Phergie / Plugin / ModuleList.php : class Phergie_Plugin_ModuleList extends Phergie_Pl ugin_Abstract_Command Phergie / Plugin / Debug.php : class Phergie_Plugin_Debug extends Phergie_Plugin_Abstr act_Command Phergie / Plugin / Twitter / twitter.class.php : class Twitter { Phergie / Plugin / Twitter / laconica.class.php : class Twitter_Laconica extends Twitter {
54. grep Recursive and case insensitive lorna@rivendell:~/svndir/snapshot$ grep - Ri 'select from' * lib / Model / Miscinfo.class.php : $row = $dbh -> read ( 'select * from misc_info where info_key = ' . $dbh -> quote ( $key ) . ' limit 1' ); lib / Model / Transaction.class.php : $row = $dbh -> read ( 'select * from transactions where transaction_id = ' . $dbh -> quote ( $transaction_id ) . ' limit 1' ); lib / Model / Transaction.class.php : $row = $dbh -> read ( 'select * from transactions where transaction_id = ' . $dbh -> quote ( $transaction_id ) . ' and account_id = ' . $dbh -> quote ( $account_id ) . ' limit 1' ); lib / Model / Transaction.class.php : $sql = 'select * from transactions where account_id = ' . $dbh -> quote ( $account_id ); lib / Model / Transaction.class.php : $sql = 'select * from transactions where status = ' . $dbh -> quote ( $status ); lib / Model / File.class.php : $row = $dbh -> read ( 'select * from files where id = ' . $dbh -> quote ( $id ) . ' limit 1' ); lib / Model / Account.class.php : $row = $dbh -> read ( 'select * from accounts where account_id = ' . $dbh -> quote ( $account_id ) . ' limit 1' ); lib / DBL / Database.class.php : * $rows = $db -> read ( 'select * from aTable' );
55. find powerful "grep" using file metadata rather than content can search by name find . -name .htaccess also by modified time, by size, etc ...
56. diff shows differences between files, doesn't show you what is the same lorna@taygete:~/talks$ diff misc.php.old misc.php 3 c3 < $link = mysql_connect ( 'localhost' , 'app_user' , 'yorkshirepud' ); --- > $link = mysql_connect ( 'localhost' , 'lorna' , 'candyfloss' );
61. tar Tape ARchive for gluing together files, for transfer lorna@taygete:~/talks$ ls cherries.jpg example.php long_file.txt orange.txt temp test .sql.gz what.jpg credits.txt index.php misc.php patch .txt test .sql thing.jpg lorna@taygete:~/talks$ tar - zcf talks.tgz * lorna@taygete:~/talks$ ls cherries.jpg example.php long_file.txt orange.txt talks.tgz test .sql thing.jpg credits.txt index.php misc.php patch .txt temp test .sql.gz what.jpg lorna@taygete:~/talks$
62. nano widely available lightweight editor designed as a non-pine equivalent to pico (PIne COmposer) instructions are on-screen
69. man man pages are the manual man <command> name synopsis (example arguments) description (all the switches) examples, if you are lucky some tools use "info" instead
70. man lorna@taygete:~$ man pwd PWD(1) User Commands PWD(1) NAME pwd - print name of current/working directory SYNOPSIS pwd [OPTION] DESCRIPTION Print the full filename of the current working directory. --help display this help and exit --version output version information and exit NOTE: your shell may have its own version of pwd, which usually supersedes the version described here. Please refer to your shellâÀÙs documentation for details about the options it supports.
78. ps ps ax ps aux use with grep 6761 ? Ss 0 : 00 / usr / sbin / apache2 - k start 8009 ? S 0 : 00 / usr / sbin / apache2 - k start 8010 ? S 0 : 00 / usr / sbin / apache2 - k start 8011 ? S 0 : 00 / usr / sbin / apache2 - k start 8012 ? S 0 : 00 / usr / sbin / apache2 - k start 8013 ? S 0 : 00 / usr / sbin / apache2 - k start 24209 pts / 4 S + 0 : 00 grep apache
79. top show current top processes sort by zxc z for colour x for column highlight c to show full command < > to change which column we're sorting by ** q to quit
80. check apache is running use grep - look for "apache" or "httpd" if not: apache2ctl restart service httpd restart
81. check mysql is running use grep if not: /etc/init.d/mysql start
83. mkdir mkdir make directory lorna@taygete:~/temp$ ls lorna@taygete:~/temp$ mkdir examples lorna@taygete:~/temp$ ls examples
84. mv and cp move and copy files lorna@taygete:~/temp$ ls cherries.jpg lorna@taygete:~/temp$ mv cherries.jpg oranges.jpg lorna@taygete:~/temp$ ls oranges.jpg lorna@taygete:~/temp$ cp oranges.jpg cherries.jpg lorna@taygete:~/temp$ ls cherries.jpg oranges.jpg lorna@taygete:~/temp$ cp /etc/php5/cli/php.ini php-cli.ini lorna@taygete:~/temp$ ls cherries.jpg oranges.jpg php-cli.ini
85. rm remove files/directories cherries.jpg examples oranges.jpg lorna@taygete:~/temp$ rm oranges.jpg lorna@taygete:~/temp$ touch examples/dewdrops.txt lorna@taygete:~/temp$ rm examples/ rm: cannot remove `examples/': Is a directory lorna@taygete:~/temp$ rmdir examples rmdir: failed to remove `examples': Directory not empty lorna@taygete:~/temp$ rm -rf examples lorna@taygete:~/temp$ ls cherries.jpg
86. ln link - creates a symlink or alias between directories lorna@taygete:~/Documents$ ln - s / home / lorna / downloads temp lorna@taygete:~/Documents$ cd temp lorna@taygete:~/Documents/temp$ pwd / home / lorna / Documents / temp lorna@taygete:~/Documents/temp$ ls FlickrDownload - 0.4 highlight - 2.7 . tar .gz libmemcached - 0.26 . tar .gz ZendFramework - 1.7.6 - minimal FlickrDownload - 0.4 . tar .gz key.txt lorna_andean_explorer_large.jpg ZendFramework - 1.7.6 - minimal. tar .gz highlight - 2.7 libmemcached - 0.26 sun - presenter - screen - linuxintel.oxt lorna@taygete:~/Documents/temp$
87. cURL great for services flickr example curl -X POST http://api.flickr.com/services/rest/ -d method=flickr.photos.getRecent -d api_key=853b05c9... -d per_page=5