User Tools

Site Tools


chapter_2_-_the_linux_operating_system:basic_linux_shell_commands

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

chapter_2_-_the_linux_operating_system:basic_linux_shell_commands [2013/01/25 13:38]
cellbiol [Chapter Sections]
chapter_2_-_the_linux_operating_system:basic_linux_shell_commands [2013/01/30 19:21] (current)
cellbiol [Hello, World!: creating and executing a script]
Line 1: Line 1:
-===== Basic Linux Shell Commands =====+===== 2-3: Basic Linux Shell Commands =====
  
 The best way to follow this discussion is to sit in front of a Linux Terminal and try the examples while you read. Turn on your machine, fire up a shell and put your hands on the keyboard, NOW ;-). The best way to follow this discussion is to sit in front of a Linux Terminal and try the examples while you read. Turn on your machine, fire up a shell and put your hands on the keyboard, NOW ;-).
Line 9: Line 9:
 An in-depth, nice and clean guide of the main linux commands is available online thanks to the [[http://​www.linfo.org/​command_index.html|Linux Information Project Linux Commands pages]]. An in-depth, nice and clean guide of the main linux commands is available online thanks to the [[http://​www.linfo.org/​command_index.html|Linux Information Project Linux Commands pages]].
  
-We will now list the main Linux commands in what we consider a logical order, rather than an alphabetically.+We will now list the main Linux commands in what we consider a logical order, rather than alphabetically.
 ==== man ==== ==== man ====
  
Line 283: Line 283:
 Let's create the script file and open it for editing with nano, all in one command: Let's create the script file and open it for editing with nano, all in one command:
  
-''​andrea@ubuntu:​~$ nano -w myscript.py''​+''​andrea@ubuntu:​~$ nano -w helloworld.py''​
  
-We will then put a first line in the script, called shebang line, to point Linux to the correct interpreter for the code that follows. Since we will write in python, we must include the python path returned previously by the "which python"​ command:+We will then put a first line in the script, called ​[[http://​en.wikipedia.org/​wiki/​Shebang_(Unix)|shebang line]], to point Linux to the correct interpreter for the code that follows. Since we will write in python, we must include the python path returned previously by the "which python"​ command:
  
 ''#​!/​usr/​bin/​python''​ ''#​!/​usr/​bin/​python''​
Line 292: Line 292:
  
 print "​Hello,​ World!"​ print "​Hello,​ World!"​
 +
 +//The helloworld.py python script//
 +<​code>​
 +#​!/​usr/​bin/​python
 +print "​Hello,​ World!"​
 +</​code>​
  
 That's it, we are done. We can save with Ctrl + o, press return to confirm the file name and then exit nano with Ctrl + x. That's it, we are done. We can save with Ctrl + o, press return to confirm the file name and then exit nano with Ctrl + x.
Line 297: Line 303:
 If we try to then run the script like this: If we try to then run the script like this:
  
-''​andrea@ubuntu:​~$ ./myscript.py''​+''​andrea@ubuntu:​~$ ./helloworld.py''​
  
 This will not work, because the file does not have execute permissions. Let's grant execute permission: This will not work, because the file does not have execute permissions. Let's grant execute permission:
  
-''​andrea@ubuntu:​~$ chmod +x myscript.py''​+''​andrea@ubuntu:​~$ chmod +x helloworld.py''​
  
 Then we can execute it: Then we can execute it:
  
-''​andrea@ubuntu:​~$ ./myscript.py''​+''​andrea@ubuntu:​~$ ./helloworld.py''​
  
 will print "​Hello,​ World!"​ to the screen. Please note that in order for Linux to understand that we want to run the script file, rather than executing a command with the same name as the script, we have to use the ./ notation for the relative path, or use an absolute path. So we have to type: will print "​Hello,​ World!"​ to the screen. Please note that in order for Linux to understand that we want to run the script file, rather than executing a command with the same name as the script, we have to use the ./ notation for the relative path, or use an absolute path. So we have to type:
  
-''​andrea@ubuntu:​~$ ./myscript.py''​+''​andrea@ubuntu:​~$ ./helloworld.py''​
  
 or  or 
  
-''​andrea@ubuntu:​~$ /​home/​andrea/​myscript.py''​+''​andrea@ubuntu:​~$ /​home/​andrea/​helloworld.py''​
  
 rather then: rather then:
  
-''​andrea@ubuntu:​~$ ​myscript.py''​+''​andrea@ubuntu:​~$ ​helloworld.py''​
  
 that will raise an error about the command not existing. that will raise an error about the command not existing.
Line 324: Line 330:
  
 It's now time to move ahead and turn our newly installed Linux distro in a full fledged web server. We will start by installing an SSH Server and learning to connect remotely to our machine. [[chapter_2_-_the_linux_operating_system:​installing and using openssh server for remote connections |Read on]]  It's now time to move ahead and turn our newly installed Linux distro in a full fledged web server. We will start by installing an SSH Server and learning to connect remotely to our machine. [[chapter_2_-_the_linux_operating_system:​installing and using openssh server for remote connections |Read on]] 
- 
 ==== Chapter Sections ==== ==== Chapter Sections ====
-  ​* [[chapter_2_-_the_linux_operating_system:​start|Chapter 2: Introduction]]+<box 100% left round blue | **Chapter 2**> 
 +<​html>&​nbsp;</​html>​ 
 +  ​* [[chapter_2_-_the_linux_operating_system:​start|Introduction]]
   * **2-1:** [[chapter_2_-_the_linux_operating_system:​installing ubuntu linux|Installing Ubuntu Linux]]   * **2-1:** [[chapter_2_-_the_linux_operating_system:​installing ubuntu linux|Installing Ubuntu Linux]]
   * **2-2:** [[chapter_2_-_the_linux_operating_system:​the linux filesystem |The Linux Filesystem]]   * **2-2:** [[chapter_2_-_the_linux_operating_system:​the linux filesystem |The Linux Filesystem]]
-  * **2-3:** Basic Linux Shell Commands+  * **2-3:​** ​[[chapter_2_-_the_linux_operating_system:​basic linux shell commands |Basic Linux Shell Commands]]
   * **2-4:** [[chapter_2_-_the_linux_operating_system:​installing and using openssh server for remote connections |Installing and using Open SSH Server for remote connections]] ​   * **2-4:** [[chapter_2_-_the_linux_operating_system:​installing and using openssh server for remote connections |Installing and using Open SSH Server for remote connections]] ​
-  * **2-5:​** ​ [[chapter_2_-_the_linux_operating_system:​installing linux apache php mysql lamp server |Installing a LAMP (Linux, Apache, PHP, MySQL) Server]] ​+  * **2-5:​** ​ [[chapter_2_-_the_linux_operating_system:​installing linux apache php mysql lamp server |Installing a LAMP (Linux, Apache, PHP, MySQL) Server]] 
 +  * **2-6:** [[chapter_2_-_the_linux_operating_system:​apache web server configuration |Apache Web Server Configuration]] 
 +  * **2-7:** [[chapter_2_-_the_linux_operating_system:​setting up a linux web server|Setting up a Linux Web Server - Reference Summary]] 
 + 
 + 
 +[[..:​start|Back to index]] 
 +</​box>​
chapter_2_-_the_linux_operating_system/basic_linux_shell_commands.txt · Last modified: 2013/01/30 19:21 by cellbiol