CMPSC 311, General Instructions

Logging In -- Remotely, to the PSU Linux cluster



Penn State ITS runs a set of Linux labs (without remote access) and a Linux cluster that you can access remotely.  See here for more information.  The cluster access instructions are here (and recommended, no matter which system you will connect to).

There is an incompatibility problem between the CSE Linux systems and the PSU Linux cluster, caused by the PSU PASS system, with regard to execute permission of compiled programs.  Read the explanation of how to enable execute permissions on your files.  This is a largely unsatisfactory solution, since it turns on the execute permission bits for every file and subdirectory, for the owner, the owner's group, and all other users.  Worse, you can't turn easily off the execute permission bits, once they are enabled through the PASS controls.  For this reason, we don't recommend use of the PSU Linux cluster by programmers.  After explaining the problem in more detail (it's more of a rant than an explanation), we'll show how to organize the directories and files to make a workable solution, which is actually not unreasonable.



Suppose our PSU Access ID is xyz1234.  From a Unix or Linux or Mac OS X system, in a terminal window, login to the PSU Linux cluster with the command
ssh -l xyz1234 lxcluster.tlt.psu.edu
or with
ssh xyz1234@lxcluster.tlt.psu.edu
From Windows, use the SSH Client; once you log in, it should work the same way.

After entering your password (remember, it's a PSU system, not a CSE system), you will get a greeting message, and a command prompt from the Bash command shell (version 3.00), as follows:

-------------------------------------------------
#################################################
#              UPDATED NOTICE:                  #
#          please read below            #
#################################################
You have just logged into the ITS Linux cluster!

Please logout when you are done.  If you are
logged in for more than 14 days, your PASS space
credentials will have expired. You will need to
log out and log back in, or renew you Kerberos
credentials with the kinit command.

If you need help or have problems with this
server, please email CLC-LINUX@psu.edu and report
the specific server or lab machine, date, time
and your problem.

#################################################
#                    NOTICE:                    #
#################################################

Every night, this system will kill all processes
that are owned by any user that is not logged in.
-------------------------------------------------
-bash-3.00$

Commands we entered are highlighted in bold letters, and this example illustrates the situation for someone without many files, trying to do CMPSC 311 Project 1.  We added some comments in brackets.

-bash-3.00$ ls
Desktop  My Documents
-bash-3.00$ mkdir cmpsc311
[Create a new directory.]
-bash-3.00$ ls -l
total 48
drwx--x---  2 xyz1234 xyz1234 8192 Jan 16 09:58 cmpsc311
drwx--x---  2 xyz1234 xyz1234 8192 Aug 23  2010 Desktop
drwx--x--x  3 xyz1234 xyz1234 8192 Aug 23  2010 My Documents
[The permission bits already look wrong.  Too many x's.]
-bash-3.00$ cd cmpsc311
-bash-3.00$ mkdir project1
-bash-3.00$ cd project1
-bash-3.00$ vi pr1.1.c
[Copy-and-paste from the project description.]
-bash-3.00$ vi Makefile
[Copy-and-paste from the project description.]
-bash-3.00$ ls -l
total 16
-rw-------  1 xyz1234 xyz1234 1090 Jan 16 10:00 Makefile
-rw-------  1 xyz1234 xyz1234 5168 Jan 16 09:59 pr1.1.c
[This looks right.  These files should not be executable, and they are not.]
-bash-3.00$ make -n
gcc -std=c99 -Wall -Wextra -o pr1 -m32 pr1.1.c
./pr1 > m32
gcc -std=c99 -Wall -Wextra -o pr1 -m64 pr1.1.c
./pr1 > m64
diff m32 m64 > m32-m64-diff
rm pr1
[The make -n command simply lists what would be done, if we had typed make instead.  We'll do these commands interactively, by copy-and-paste.]
-bash-3.00$ gcc -std=c99 -Wall -Wextra -o pr1 -m32 pr1.1.c
pr1.1.c:32: warning: unused parameter 'argc'
pr1.1.c:32: warning: unused parameter 'argv'
[This looks right.  Those warnings are expected for this program.]
-bash-3.00$ ls -l
total 272
-rw-------  1 xyz1234 xyz1234 1090 Jan 16 10:00 Makefile
-rw-------  1 xyz1234 xyz1234 8719 Jan 16 10:00 pr1
-rw-------  1 xyz1234 xyz1234 5168 Jan 16 09:59 pr1.1.c
[The file pr1 should have permissions -rwx------ .  Something's wrong.]
-bash-3.00$ pr1
-bash: ./pr1: Permission denied
[So, we can't run the program because it doesn't have execute permission.]
-bash-3.00$ file pr1
pr1: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), dynamically linked (uses shared libs), not stripped
[But, it is indeed an executable file.]

Now open a Web browser and follow the instructions on how to enable execute permissions, using the new folder name cmpsc311-new in step 3 (no spaces!).

-bash-3.00$ cd
-bash-3.00$ ls -l
total 48
drwx--x---  3 xyz1234 xyz1234 8192 Jan 16 12:22 cmpsc311
drwx--x---  2 xyz1234 xyz1234 8192 Aug 23  2010 Desktop
drwx--x--x  3 xyz1234 xyz1234 8192 Aug 23  2010 My Documents
-bash-3.00$
[Before.  cmpsc311-new doesn't exist yet.]
-bash-3.00$ ls -l
total 64
drwx--x---  3 xyz1234 xyz1234 8192 Jan 16 12:22 cmpsc311
drwx--x--x  2 xyz1234 xyz1234 8192 Jan 16 12:30 cmpsc311-new
drwx--x---  2 xyz1234 xyz1234 8192 Aug 23  2010 Desktop
drwx--x--x  3 xyz1234 xyz1234 8192 Aug 23  2010 My Documents
-bash-3.00$
[After.  cmpsc311-new has been created, and has execute permissions enabled in all its descendents.  You can close the PASS File Permissions Manager webpage now, since the PASS Explorer webpage is still open.  Don't forget to logout from the PASS Explorer later.]
-bash-3.00$ cd cmpsc311-new
-bash-3.00$ mkdir project1
-bash-3.00$ cd project1
-bash-3.00$ vi pr1.1.c
-bash-3.00$ vi Makefile
-bash-3.00$ ls -l
total 16
-rwx--x--x  1 xyz1234 xyz1234 1090 Jan 16 12:41 Makefile
-rwx--x--x  1 xyz1234 xyz1234 5168 Jan 16 12:41 pr1.1.c
[This looks wrong.  These files should not be executable, but they are.]
-bash-3.00$ chmod -v 600 Makefile pr1.1.c
mode of `Makefile' changed to 0600 (rw-------)
mode of `pr1.1.c' changed to 0600 (rw-------)
[The "change mode" command is the proper way to change permission bits.  Its -v option provides confirmation that it did the right thing.  The mode numbers are in octal.]
-bash-3.00$ ls -l
total 16
-rwx--x--x  1 xyz1234 xyz1234 1090 Jan 16 12:41 Makefile
-rwx--x--x  1 xyz1234 xyz1234 5168 Jan 16 12:41 pr1.1.c
[Phooey, chmod doesn't actually work on this system.]
-bash-3.00$ gcc -std=c99 -Wall -Wextra -o pr1 -m32 pr1.1.c
pr1.1.c:32: warning: unused parameter 'argc'
pr1.1.c:32: warning: unused parameter 'argv'
-bash-3.00$ ls -l
total 272
-rwx--x--x  1 xyz1234 xyz1234 1090 Jan 16 12:41 Makefile
-rwx--x--x  1 xyz1234 xyz1234 8719 Jan 16 12:43 pr1
-rwx--x--x  1 xyz1234 xyz1234 5168 Jan 16 12:41 pr1.1.c
[Well, at least pr1 is executable, but there's too many x's.]

It is possible to use the PSU PASS Explorer (https://explorer.pass.psu.edu/explorer.cgi) to remove execute permission from individual files, so after about 12 clicks per file and recompiling, we can get to a somewhat better state,

-bash-3.00$ ls -l
total 272
-rw-------  1 xyz1234 xyz1234 1090 Jan 16 12:41 Makefile
-rwx--x--x  1 xyz1234 xyz1234 8719 Jan 16 12:52 pr1
-rw-------  1 xyz1234 xyz1234 5168 Jan 16 12:41 pr1.1.c
-bash-3.00$ pr1
[Program output as expected - it ran properly.  But pr1 has too many x permissions.]
-bash-3.00$ chmod -v 700 pr1
mode of `pr1' changed to 0700 (rwx------)
-bash-3.00$ ls -l
total 32
-rw-------  1 xyz1234 xyz1234 1090 Jan 16 12:41 Makefile
-rwx--x--x  1 xyz1234 xyz1234 8719 Jan 16 12:52 pr1
-rw-------  1 xyz1234 xyz1234 5168 Jan 16 12:41 pr1.1.c
-bash-3.00$
[Phooey, chmod doesn't actually work on this system.]

Use the CSE Dept. systems if having too many execute permissions bothers you.  It bothers me.



So, after all that, here's a reasonable workaround:  the source code and binaries (executable files) are placed in separate directories.

-bash-3.00$ mkdir cmpsc311
-bash-3.00$ mkdir cmpsc311/src
-bash-3.00$ mkdir cmpsc311/bin
-bash-3.00$ mkdir cmpsc311/src/project1
-bash-3.00$ mkdir cmpsc311/bin/project1
[Any mkdir commands that try to create something that's already there will fail, but that's ok here.]
[For the next project, create the directories cmpsc311/src/project2 and  cmpsc311/bin/project2 , and so on.]
-bash-3.00$ cd cmpsc311/src/project1
-bash-3.00$ vi pr1.1.c
-bash-3.00$ vi Makefile
[Copy pr1.1.c and Makefile from the project description, going into the src/project1 directory.]

Next, follow the instructions in http://clc.its.psu.edu/labs/linux/cluster/executingfiles and use the PASS Explorer to enable execute permission in all descendents of the directory cmpsc311/bin .  It won't necessary to do this again.

The original version of the Makefile, configured for the CSE Dept. systems, is like this:
# CMPSC 311, Project 1

SRC = pr1.1.c

# Solaris, Linux, Mac OS X
run-gcc: $(SRC)
gcc -std=c99 -Wall -Wextra -o pr1 -m32 $(SRC)
./pr1 > m32
gcc -std=c99 -Wall -Wextra -o pr1 -m64 $(SRC)
./pr1 > m64
-diff m32 m64 > m32-m64-diff
rm pr1

# etc.
The Makefile should now be rewritten like this:  (BINDIR is short for "binaries directory")

# CMPSC 311, Project 1
# This Makefile is configured for the PSU Linux cluster.

SRC = pr1.1.c

BINDIR = ../../bin/project1

# Solaris, Linux, Mac OS X
run-gcc: $(SRC)
        gcc -std=c99 -Wall -Wextra -o $(BINDIR)/pr1 -m32 $(SRC)
        $(BINDIR)/pr1 > m32
        gcc -std=c99 -Wall -Wextra -o $(BINDIR)/pr1 -m64 $(SRC)
        $(BINDIR)/pr1 > m64
        -diff m32 m64 > m32-m64-diff
        rm $(BINDIR)/pr1

# etc.

On the CSE Dept. lab systems and servers, you could use the same Makefile, except with the simpler definition

BINDIR = .

Unfortunately for Project 1, you will find that the PSU Linux cluster's compiler's -m64 option is not installed, and there's no point in continuing to use it.



Last revised, 17 Jan. 2012