CSIL Linux/UNIX FAQ

Please read Getting Started as a CMPT Undergraduate page for basic information about our labs and how to gain access to them.

The Linux/UNIX Command Line Environment


The Linux/UNIX Command Line Environment

What is the Linux/UNIX command line?

The command line is a text-only interface that allows you to communicate directly with the Unix operating system (O/S). Although it is text-only, the command line is vastly more powerful than the Graphical User Interface (GUI - pronounced "goo-ey") that most Unix users use most of the time. All GUI applications on the Linux system rely heavily on the simple command line level Unix commands when they need to perform input/output of any sort. There are many Unix commands that can affect the O/S and its operation that can have a great deal of impact on the GUI applications but that the GUI user never sees.

Users can access the Unix command line from the GUI, by running an application called "Terminal". You can find this application in your list of applications inside your menus. Linux users also have access to Virtual Consoles. There are six Virtual Consoles on each Ubuntu Linux workstation in CSIL, and you invoke them from the keyboard by pressing the key sequence CTRL-ALT-F1 to F6. Pressing CTRL-ALT-F7 will take you back to the GUI session.

CRITICAL: You MUST log out of each Virtual Console that you log in to. Logging out of the GUI session is NOT sufficient. If you logged in to a Virtual Console and did not log out, any other user coming along to your workstation after you had left CSIL would have full access to your account.

We cannot teach you about all of the Unix command line commands in this FAQ. There is extensive help for both new and experienced users alike on the Web.

What is a command shell?

A command shell is a program that interprets what you type at the command line, and tries to make sense out of it. There are many different shells, each with its own peculiarities. Some popular ones are:

  • sh - the Bourne shell.
  • csh - the C shell.
  • tsh - the T shell.
  • bash - the Bourne-again shell.

Each time you log in to a Unix/Linux system, you are starting a shell. This is true even if you only log in to the GUI session. Every Unix user has a default shell, set by the system administrator who created your account. You cannot change this in CSIL, but you can run a sub-shell if you like. At the command line, simply type in the name of the new shell (for example, to invoke the 'bash' shell):

bash

To exit a sub-shell and return to the parent shell, enter the 'exit' command at the command prompt.

There is extensive documentation on the Web regarding Unix command shells and their features.

How is my CSIL Linux/UNIX environment set up?

Your Unix environment is controlled by your ENVIRONMENT and SHELL variable settings.

When you log on to any Unix/Linux system, Unix automatically sets a number of important environment and shell variables. Depending on which shell you are running, you can use the 'set' and/or 'setenv' commands on the command line to see these variables. Environment variables from your initial login are copied to each subshell that you open during that login session, but shell variables are not. Environment variable names are all upper case by convention, while shell variables are all lower case by convention.

The whole point of environment and shell variables is to store critical information that your applications rely on. For example, one of the most important environment variables is the PATH variable. The PATH variable holds the directories that are searched for application programs and their components, in the order of importance. If you have an application program or a program component that is in a directory that is NOT in your PATH, then the Unix system will be unable to find it if it is not in your current directory.

To illustrate, say you PATH variable is set to:

PATH=/usr/sbin:/bin:/usr/bin/:/usr/ucb:/usr/local/bin

and you wish to execute the XYZ application that is installed in the directory:

/var/bin/XYZ

Unless you are in the directory XYZ from command prompt, the Unix system will not be able to find your XYZ application.

Can I change my CSIL Linux/UNIX environment?

Yes. See the shell commands that are applicable for viewing and editing your default and preferred command shell environment and shell variables. You can almost always override the pre-set defaults that we have set up for you. For example, if your default Unix command shell is 'bash', check for web pages that match phrases like: 'setting bash environment variables'.

How do I share files with other Linux/UNIX users?

You can share files publicly, semi-publicly, to a group, or to a specific list of Unix users.

Sharing files Publicly

Create a directory in your home directory which is eXecutable and Readable by all. The goal of this is to let every Unix user list the file names in your directory without letting any other users write anything to your directory. Each file that you store in this directory should be readable by everyone, but likewise should not be writeable. For your directory then, enter the commands:

mkdir public
chmod a+rx public
chmod go-w public

This creates the sub-directory 'pub' in the current directory. Next, you can create files in this directory, and change their permissions to:

chmod a+r [one or more filenames]
chmod go-w [one or more filenames]

Sharing files Semi-Publicly

The goal here is similar to the above instructions, but here you create a directory in your home directory which is eXecutable but NOT Readable or Writeable by either the 'group' or 'others'. This approach prevents other Unix users from listing the names of your files within your directory unless you tell them the file names. This presumably prevents them from listing or copying your file's contents. This solution however has two big security holes. It is known as "Security through obscurity", and is therefore NOT SECURE. If any other Unix user can guess your directory's "hidden" file names, or someone who knows the names passes them on to other users, they can read or copy your files, just like users you do give your file names to:

mkdir semi_public
chmod a+x semi_public
chmod go-rw semi_public

Sharing files with a Group

Here the goal is to share files only with the Unix group. For undergraduate students in CSIL this isn't terribly helpful, as every undergraduate student taking a CMPT course is in the same group:

mkdir group_files
chmod o-rwx group_files
chmod g-w group_files
chmod g+rx group_files

Sharing files with a Speific List of Unix Users

This is not available on all Unix systems, but is available on the Ubuntu systems in CSIL. This facility is known as Access Control Lists (ACLs), and these are set via the setfacl command. You can view the currently set ACL for a file or directory with the getfacl command. Check the man pages on your system or search the Web for tutorials on how to set ACLs. Here is a simplistic example:

mkdir secret_files
setfacl -m mask:rwx secret_files
setfacl -m user:[allowed_userid]:r-x secret_files

To see your ACL settings enter:

getfacl secret_files

Where to save my files on CSIL Linux/UNIX system?

One and only one place: /home/{username}/sfuhome/

For Unix/Linux users in CSIL, your home directory is set to /home by the system. This space is actually not located on any physical workstation in CSIL, but is automatically mounted for you at login time from a file server. This way, no matter which Unix machine in CSIL that you log in to, you will have the same /home directory.

Note that this is NOT the place to save your files. You should save files to your SFU Campus home directory, which is mounted as /home/{username}/sfuhome/

Your CSIL /home directory is local to the CSIL network and may be ERASED without advanced notice. If you wish to save any of the files and directories you create while in CSIL on a permanent basis, you should save them to your SFU Campus home directory. To access your SFU Campus home directory ( /home/{username}/sfuhome ), open a terminal session from Applications accessories on Gnome panel, and make SFU home directory accessible for your login session with the command "mount.sfuhome".

How do I access SFU Campus home directory?

Open a terminal session from Applications accessories on Gnome panel, and make SFU home directory accessilbe for your login session with the command "mount.sfuhome". At the password prompt, enter SFU email password.

How do I remotely access CSIL Linux(Ubuntu) machines via ssh?

From Window secure shell client, enter fraser.sfu.ca as hostname, and SFU email password as password. After successful login, enter "ssh -p 24 {linux_machine}.csil.sfu.ca". Note: linux_machine is the hostname of Linux machines.


Known Linux Issues

I have logged into CSIL Unix/Linux machines previously but now I can't log on. What's wrong?

You may have a disk quota problem. Please read "User Disk Quota Problems" page for an answer. If the intstructions on this page do not resolve your login problems, please email helpdesk.

There is a runaway process or an application that seems to have 'frozen' and is not responding. How can I stop it?

Given the complex nature of computers and software, it is inevitable that applications sometimes 'freeze' or 'hang'. There are many reasons why an application stops responding to the user, but often it is because the application programmer has entered defective code into their program. When this happens, often the only thing the user can do is interrupt the program.

Every application on the Unix system runs as a separate process, and each process is assigned a process id number or pid. To read more on processes and how to terminate them, read the following page on How to kill Unix Processes.

Firefox won't start and claims that "Firefox is already running". What I should do?

Firefox stores start up information in its configuration directory, .mozilla/firefox/{profile}/, located in your home directory. When firefox terminates abnormally, sometimes it does not clean up the configuration directory properly. It may leave behind a lock and a .parentlock file in your profile sub-directory. Firefox uses these files to tell which profile is the active profile, as you can have more than one profile. If the lock and .parentlock files are present when firefox is not running, then it will not start up. If you manually delete these files, you will be able to run firefox. First:

cd ~/.mozilla/firefox/

then locate the profile directory. It will have a strange name, followed by a dot, followed by the name of the profile - normally default, for the default profile. For example:

cd gx93dladd0.default
ls -al

should show you the 'lock' and '.parentlock' files. Remove them and attempt to restart firefox.

For more information on firefox profiles, click here.

 

Search Computing Science