D. Nixon: CS 12 > Tutorials > Miscellaneous typics

Home (CS 12) | Assignments | Tutorials | Examples | Quizzes & Exam | Other Info | Chat

Computer Science 12


Tutorials on computer basics, operating systems, and non-Web Internet




Week 2: Filename extensions in Windows

Filename extensions in Windows:  This week's tutorials about graphics files mention some graphics filename extensions. However, Windows hides filename extensions by default. So that you can see filename extensions in Windows, see:


To all information for Week 2  |  To all tutorials about computer basics, operating systems, and non-Web Internet



Week 3: Computer basics: Binary numbers

On computer basics, including binary numbers, hexadecimal numbers, and number base conversions, see Some basics of how computers work, by Marcas Neal and D. Nixon. See especially the section on Binary numbers.


To all information for Week 3  |  To all tutorials about computer basics, operating systems, and non-Web Internet



Week 4: Use of binary codes to store data

On the use of binary codes for data storage, see the following sections of Some basics of how computers work:


To all information for Week 4  |  To all tutorials about computer basics, operating systems, and non-Web Internet



Week 7: Non-Web Internet file transfer

  1. Non-Web Internat protocols for transfering files:
  2. Installation of an SFTP/SCP program
  3. Logging in to the CS 12 Unix (Linux) machine
  4. General tutorials on WinSCP and FileZilla
  1. Non-Web Internat protocols for transfering files:

    The Internet is not the same thing as the World Wide Web. The World Wide Web (the Internet protocol that enables you to view pages in a web browser) is only the most popular way of using the Internet. There are also other, older ways of using the Internet, such as File Transfer Protocol (FTP).

    You will now be taught how to use a variant of FTP to upload your HTML files to the CS 12 Unix (Linux) machine, so you can view them as a website there.

    The original FTP protocol was not secure. Usernames, passwords, and the files themselves were all sent unencrypted. It is now standard for all access to passworded accounts over the Internet to be encrypted. To that end, the original FTP protocol has been largely superceded by SFTP, which stands for "Secure File Transfer Protocol." Another, very similar protocol is "SCP," which stands for "Secure Copy." WinSCP can do both SFTP and SCP.

  2. Installation of an SFTP/SCP program:

    Before you can upload your website to the CS 12 Unix (Linux) machine, you will first need an SFTP file transfer client program. In the lab at school, WinSCP is is already installed. If you are doing this at home, you must download and install one of the programs below:

  3. Logging in to the CS 12 Unix (Linux) machine:

    Make sure you can log in to tue Unix machine for this class. Use the following as the "Host name":

        cs12.cs.qc.cuny.edu
    

    Use the same username and password that we use on the machines in the lab. Make sure you type the letters of your username in all lower case. Unix is case-sensitive.

    If you have difficulty figuring out how to log in, refer to the tutorials below.

  4. General tutorials on WinSCP and FileZilla:

    Below are some tutorials on WinSCP:

    Below are some tutorials on using SFTP with FileZilla (but see note below):

    Note: Both of the above FileZilla tutorials are tailored for specific sites that we are not using. Ad noted above, the host name you should use is  cs12.cs.qc.cuny.edu  rather than whatever host name is indicated in the tutorial.


To all information for Week 7  |  To all tutorials about computer basics, operating systems, and non-Web Internet



Week 10: Non-Web Internet file transfer, and Unix file permissions

  1. Logging in to the CS 12 Unix (Linux) machine
  2. Uploading your HTML files to a remote Unix machine
  3. A brief intro to file permissions
  4. Adjusting file permissions
  5. Checking your HTML filenames and links
  1. Logging in to the CS 12 Unix (Linux) machine:

    Via WinSCP or whatever similar program you are able to use, log in to the Unix machine for this class. Use the following as the "Host name":

        cs12.cs.qc.cuny.edu
    

    Use the same username and password that we use on the machines in the lab. Make sure you type the letters of your username in all lower case. Unix is case-sensitive.

    If you have difficulty figuring out how to log in, refer to the tutorials listed here.

  2. Uploading your HTML files to a remote Unix machine:

    Once you have successfully logged in to the remote Unix machine, the left half of the WinSCP or FileZilla window will show files and folders (a.k.a. directories) on your local machine, whereas the right half of the window will show files and folders/directories on the remote machine.

    Prepare to upload your HTML files to the remote Unix machine, as follows: Before you upload them, copy and paste them out of your ZIP file into a new ordinary (NOT compressed) folder with the exact name of:

    	public_html
    

    Then, to upload your HTML files via WinSCP, once you are logged in: (1) On the left side of your WinSCP window, navigate to the folder which contains your  public_html  folder, on your local machine. (2) On the right side, above the file listing, click the house icon to make sure that the right side of your WinSCP window is looking at your home directory on the Unix machine. (3) On the left side of your WinSCP window, click on  public_html  to highlight it. (4) In WinSCP, select "Upload" from the "Files" menu, then click the "Copy" or "Upload" button on the dialog box that pops up. (For FileZilla, see tutorials here.)

    You should now see a copy of your  public_html  folder on the right side of your WinSCP window. If so, you have successfully uploaded it.

  3. A brief intro to file permissions:

    Once you've uploaded your HTML files and set the permissions, try to view your new website at a URL like the following:

    http://cs12.cs.qc.cuny.edu/~yourusername/

    replacing " yourusername " with your actual username. Be sure to include the tilde (" ~ ") just before your username.

    Even if you've uploaded your files correctly, you WON'T be able to see your new website yet. If you follow the above instructions correctly, you will see "Permission denied". (If you DIDN'T follow the above instructions correctly, you will see "Not Found".)

    To make your HTML files visible as a website, you will need to adjust the file permissions. Before we tell you how to do that, here is a very brief explanation of what file permissions are.

    All users who could potentially access your files are divided into 3 categories: (1) the owner (you), (2) the group (all users whom the system adminstrator has decided to group together with you for whatever reason), and (3) others (all other logged-in users with accounts on the machine). A person viewing your files via a web browser is NOT in ANY of these categories, since you don't need to be logged in to CS 12 Unix machine itself to do that. However, on a Unix machine, programs such as the Apache Web Server (which enables your website to be seen) are treated as if they were users in either the "group" or "other" category. Therefore, you need to ensure that both "group" and "other" can read your files.

    Each of the three types of "user" can be given three kinds of permissions: (1) read, (2) write, and (3) eexcute. In WinSCP these are abbreviated R,  W,  and X,  respectively. On the Unix machine itself they are abbreviated r,  w,  and x. 

    Permissions are given on a per-file basis. In the right hand side of your WinSCP window, double-click the  public_html  folder to see a listing of your files. Next to each filename, you will see

    • In WinSCP, in the "Rights" column, you'll see a sequence of nine characters like the following:

      rw-r--r--
      
    • In FileZilla, in the "Permissions" column, you'll see a sequence of ten characters like the following:

      -rw-r--r--
      

      In FileZilla, the first of these ten characters not really one of the "persissions" but indicates whether the listed file is a regular file or a folder. (If it's a regular file, that character is a dash. If it's a folder, that character is a 'd' -- which stands for "directory," and older word for a folder.) The remaining nine characters are the permissions.

    In both WinSCP and FileZilla, among the nine characters that constitute the rights/permissions:

    • The first three characters are the permissions for the owner.
    • The next three characters are the permissions for the group.
    • The last three characters are the permissions for other.

    Within each of these three sets of three characters:

    • The first of the three characters is either  r  or  -  depending on whether the user does (r) or does not (-) have read permission.
    • The second of the three characters is either  w  or  -  depending on whether the user does (w) or does not (-) have write permission.
    • The third of the three characters is either  x  or  -  depending on whether the user does (x) or does not (-) have execute permission.

    To read a file means to read its contents. To write to a file means to modify it. To execute a file means to run it, if the file happens to be an executable program or script. (It is meaningless to execute an HTML file, but you should note that, on HTML files, it is best to deny execute permission to everyone, including even the owner, just to make sure the file doesn't do anything weird.) On an HTML file, it is standard to give both read and write permission to the owner, and to give only read permission to both group and other.

    Now double-click the double dot at the top of the right hand panel of your WinSCP or FileZilla window to go back to your home directory (the folder you were in when you originally logged in). Next to the name of the  public_html  folder, you will see something like the following in the "Rights"/"Permissions" column:

    • In WinSCP, in the "Rights" column:

      rwxr-xr-x
      
    • In FileZilla, in the "Permissions" column:

      drwxr-xr-x
      

    Permissions can be set not only for individual files, but also for folders, also known as directories. In the example above, you, the owner, have all 3 permissions (read, write, and execute) for the  public_html  folder, whereas the group and other have both read and execute permissions but not write permission.

    To read a folder means to view a listing of the files (and other folders) within the folder. To write to a folder means to add or delete a file within the folder. To execute a folder means to access any file (or other folder) within the folder. Thus, to be able to read a file on a Unix system, you not only need read permission for the file itself, you also need execute permission for the folder containing that file -- and you also need execute permisson for the folder containt that folder, and so on, all the way up to the root directory (the one big folder containing all the others).

    Now click the double dot at the top to go outside your home directory into a director which contains all the home directories of all the students in this class. You will see a list of folders, each with a student username (4 letters, followed by 4 digits), including yours. Note the following in the "Rights"/"Permissions" column:

    • In WinSCP, in the "Rights" column:

      rwxr------
      
    • In FileZilla, in the "Permissions" column:

      drwxr------
      

    Thus each student, each of whom is the owner of a directory with one's own username, has full permissions for that directory, but no one else has permission to do anything. That's why the web server can't read your files, which is why you got "Forbidden" when trying to access them via a web browser. Remember, the web server (treated as a user in either the "group" or "other" category) needs execute permission for your home directory in order to access your  public_html  directory, which the web server needs to access to get to your HTML files.

    Now go back to your home directory (the one with your username), either by double-clicking its icon or by clicking on the house icon at the top. Look again at the permissions for your  public_html  directory:

    • In WinSCP, in the "Rights" column:

      rwxr-xr-x
      
    • In FileZilla, in the "Permissions" column:

      drwxr-xr-x
      

    These permissions are actually more generous than they need to be. The web server needs execute permission but NOT read permission on directories/folders. The web server needs to be able to access all files and folders within a folder, but does NOT need a listing of the contents of a folder. The web server already knows what file to go to, based on the URL you entered in your web browser, so it doesn't need a file listing; it just needs execute permission on all folders that contain the file either directly or indirectly.

    For security reasons, it is generally best to give no more permissions than are necessary. Hence, for a website, the following permissions are most appropriate for your  public_html  folder as well as for your home directory:

    • In WinSCP, in the "Rights" column:

      rwx--x--x
      
    • In FileZilla, in the "Permissions" column:

      drwx--x--x
      
  4. Adjusting file permissions:

    To make your HTML files visible as a website, you will need to adjust the permissions. Here's how to do this in WinSCP:

    1. In the right side of the WinSCP window, right-click on the  public_html  folder and select "Properties." In the dialog box that pops up, make sure that the R, W, and X boxes are checked for "Owner," and make sure that only the X box, but NOT the R or W box, is checked for both "Group" and "Others." Then, if you had to make any changes, click "OK"; otherwise click "Cancel."

    2. In the right side of the WinSCP window, double-click on the  public_html  folder to enter. Then right-click on each HTML file, one at a time and select "Properties." In the dialog box that pops up, make sure that the R and W boxes, but NOT the X box, are checked for "Owner," and make sure that only the R box, but NOT the W or X box, is checked for both "Group" and "Others."

    3. You can go back to your home directory by double-clicking the double-dot at the top of the file listing on the right hand side. Once you are in your home directory double-click the double dot again to go outside your home directory, into the directory with a list of folders including the one with your username. Right-click on the folder with your user name, and give execute permission to the "Group" and "Others." In the dialog box that pops up when you select "Properties", make sure that the R, W, and X boxes are checked for "Owner," and make sure that only the X box, but NOT the R or W box, is checked for both "Group" and "Others."

    For FileZilla, see the tutorial Changing File Permissions using Filezilla, then do the nearest equivalent of the above.

    For CyberDuck, see the tutorials Changing File Permissions Using Cyberduck (text-based) and File & Folder Permissions using Cyberduck (video), then do the nearest equivalent of the above.

  5. Checking your HTML filenames and links:

    Once you've uploaded your HTML files and set the permissions, view your files at a URL like the following, to make sure you've done this correctly:

    http://cs12.cs.qc.cuny.edu/~yourusername/

    replacing " yourusername " with your actual username. Be sure to include the tilde (" ~ ") just before your username.

    If you still can't see your website and you are sure you typed the URL correctly, make sure that the main page has the following EXACT filename, spelled in all-lower-case letters:

    index.html
    

    Once you are able to view your website, click on the links to make sure they still work. Note that Unix is a big fussier than Windows in the following ways: (1) Unix is case-sensitive. If the filename contains one or more letters that are upper case in the filename of the file itself, but lower case in the link, or vice versa, the link won't work. (2) If your filename contains spaces (and so did your links), the links won't work on a Unix system.

    Additionally, regardless of the operating system of the web host, there's another possible issue that may cause your links not to work: If you used complete absolute pathnames, rather than just filenames, in your local links, then the links won't work anywhere except in the same folder, on your local machine, where you created the files.

    Once you've gotten all the links to work correctly, submit your homework as per the instructons on the homework assignments page.


To all information for Week 10  |  To all tutorials about computer basics, operating systems, and non-Web Internet



Week 12: Computer basics (general)

Some basics of how computers work, by Marcas Neal and D. Nixon.


To all information for Week 12  |  To all tutorials about computer basics, operating systems, and non-Web Internet

D. Nixon: CS 12 > Tutorials > Miscellaneous topics