Linux FAQ

This FAQ is meant to familiarize, or at least introduce, a user who is familiar with either Windows or Mac, but not Linux.

The Basics

What is Linux?

Linux, technically, refers to the Linux kernel, but it has grown to mean any operating system running the Linux kernel. This means that there are many 'distributions' of Linux, each with different goals and bases. Notre Dame uses the Red Hat Enterprise Linux distribution, which is a very stable distribution produced to cater to the commercial market. While Red Hat is not free, many free alternatives exist. See Linux computing on a personal computer for more information.

How do I log in?

To log in to a Linux system, simply type your AFS/netID at the graphical 'Username:' prompt and press Enter. Type your password into the same field and press Enter once again. You are now logged in. The GNOME graphical interface loads by default. The KDE interface, while available, will not be supported.

Where's my AFS drive?

When you log in with your AFS/netID, your AFS home directory is mounted automatically. Your desktop should contain an icon named "yourusername's Home". This will open a window of your home directory (~/). Navigation is very similar to any other modern operating system.

How do I open a terminal?

Right click on the desktop and click 'Open Terminal'. You can also open the main menu (click the far left icon on the GNOME panel, it looks like a red hat by default), highlight the 'System Tools' option and click 'Terminal'.

What do I do if I need more space for short-term use?

The Linux machines have a separate partition mapped to /scratch (HP computers: 10GB; Sun computers: 74GB). You may use this temporary storage or "scratch" space to place large files prior to burning them to a CD. Please note that this space is purged on a regular basis so DO NOT use it for long-term storage.

Using the terminal

Terminal Basics:

If you're in terminal, your starting directory will be your home directory.

  • cd directory changes your working directory ('moves') to directory. If you specify directory as "..", you will move up one directory.
  • ls lists all the non-hidden files in your working directory
  • pwd outputs your working directory's full path
  • cp file1 file2 copies file1 to file2, overwriting file2 if it exists
  • mv file1 file2 moves file1 to file2 (Effectively renaming file1)
  • rm file1 deletes file1. NB: file1 is gone forever; rm doesn't use a "recycle bin".

How do I print?

If you're in terminal:

lpr -PFitzpatrick148 filetoprint

For double-sided:

lpr -PFitzpatrick148_Duplex filetoprint

How do I run a command in the background?

command &

This terminal beep is driving me crazy. How do I disable it?

At terminal, type:

xset -b

What are some text editors I can use?

Many exist. Graphical editors:

  • gedit
  • kate
  • xemacs
  • gvim

Terminal:

  • pico
  • nano
  • vi
  • emacs -nw

What program should I use in terminal to open a file of type ___?

  • eps: gv or ggv
  • jpeg: eog or gimp
  • pdf: acroread or xpdf
  • ps: gv or ggv

How do I make a link to a folder?

Make a symbolic link. Usage:

ln -s /path/to/directorytolinkto nameofnewlink

How do I use modules?

See Using Programs at the Clusters (aka using "module").

AFS

How do I find out where my home directory (~/) lies on the AFS filesystem?

In terminal, run this command:

grep yourusername /afs/nd.edu/common/etc/passwd

This will output, among other things, your afsid, your full name, the location of your home directory, and your default shell.

How do I reconnect to the AFS after I run up2date to update the kernel in my computer?

Run up2date as root to update the kernel and those modules that need to be updated. In terminal run:

 su
 (Enter the root password) 
 up2date

After you select the most recent stable version of the kernel your PC will reboot. You will not be able to login using your AFS id since your present kernel no longer has the AFS module. Login as root, and open a terminal. Check your current kernel by typing

uname -r

Look in /lib/modules/<your past kernel> for the AFS module. In most cases it will be under ../fs Once you locate the AFS module, go back to the ../modules directory and run

cp -Rp /lib/modules/<past kernel>/fs /lib/modules/<new kernel>/fs/openafs

The p option maintains the permissions and access dates for the copied directory.

Finally you need to update the changes in module configuration by typing

depmod -a

Common Engineering Tasks

How do I compile and view LaTeX files?

With a LaTeX file named project.tex:

latex project.tex
dvips project.dvi
ps2pdf project.ps
xpdf project.pdf

If you are having issues with funky page sizes and want 8.5" x 11" then compile it as follows:

latex project.tex
dvips -t letter -Ppdf project.dvi -o
ps2pdf project.ps
xpdf project.pdf

The cause of this is the fact that LaTeX was developed in Europe and they have different document standards there.

How do I compile a FORTRAN program?

With a FORTRAN file named project.f:

f77 project.f

This will create an executable output file a.out. To specify the name of the output file:

f77 project.f -o outputname.out

Miscellaneous Linux Tasks

How do I make a shell script or make a file executable?

At the first line of a script, place the full pathname to your desired shell, preceded by a #!. Example:

#!/bin/csh

To make your script executable, use the chmod command in terminal:

chmod 755 yourfile

If you're curious, the 755 is an octal representation of your permissions. Click here for more info

How do I make an alias?

alias nickname=' whatever sequence of commands you want to execute '

Examples:

alias ll='ls -l'
alias nd='cd ~/schoolwork/07fall/'

How do I use the tar utility?

To make a .tar.bz2 archive of a directory:

tar cjvf filename.tar.bz2 /path/to/directory/

To unpack a .tar.bz2 archive:

tar xjvf filename.tar.bz2

For more info:

man tar

How do I use vi?

vi is a pretty complex editor with a steep learning curve, but once learned you won't go back to gedit again. It is different than other editors because it is modal- basically, vi has two modes: insert mode and command mode. Insert mode acts like editors you're used to (like gedit or kate). Some basic commands to get you started:

  • ESC: switch to command mode
  • i: switch to insert mode
  • I: switch to insert mode at the beginning of the line
  • x: delete character
  • dd: delete (cut) line
  • d$: delete to end of line
  • dnum: delete num of lines including current line after cursor e.g. d5 will delete current and 5 lines
  • yy: copy line
  • p: paste line
  • :wq: quit vi, saving the file. alternative: ZZ (read SHIFT+zz)
  • :q!: quit vi without saving anything
  • :r!shell_command: insert output of shell_command in your document e.g. :r!date inserts current date and time.
  • :%s/text/replacement/g: replace text throughout the entire document. Works just like regexp.

How do I do ____ with _____?

Read the manpages! To open the manpage for a particular command command:

man command

In the manpage, search for a keyword by typing "/keyword"

A lot of times a command may have multiple man pages for the same command. See:

man cron
SEE ALSO
        crontab(1), crontab(5), pam(8)

If you see the number in parentheses type:

man 5 crontab

apropos

will list an alternate manpage that covers the usage of a crontab file and how to format it.

If you do not know the precise name of the command, you can use apropos. Just type:

apropos searchword

Several commands, which have that keyword in the command description within its man page, will appear on screen. Check if you recognize the command you are looking for, or search the man pages for the commands that seem about right.

How can I use shell expansion?

A full coverage of shell expansion characters (and how they differ between shells) is beyond this scope of this page, but here are some basics to get you started.

  • * expands to any number (including zero) of characters
  • ? expands to one character

Example directory contents and usage:

[engcomp@gershwin ~]$ ls
herd herds heard heated
[engcomp@aswatama ~]$ ls herd
herd
[engcomp@aswatama ~]$ ls herd*
herd  herds
[engcomp@aswatama ~]$ ls he?rd
heard
[engcomp@aswatama ~]$ ls he*rd
heard  herd
[engcomp@aswatama ~]$ ls hea??
heard
[engcomp@aswatama ~]$ ls hea???
heated
[engcomp@aswatama ~]$ ls hea*
heard  heated
[engcomp@aswatama ~]$ ls *d
heard  heated  herd
[engcomp@aswatama ~]$ ls *ed
heated

How can I use regular expressions?

Regular expressions are extremely powerful tools for selecting blocks of text. In the following basic examples grep -e will be used to demonstrate how they work. grep searches a file for a particular string and outputs the line that it appears on; the -e option specifies explicitly that the search string is a regular expression.

Here's the text file with name from_mr_torvalds.txt .

commit 8c0863403f109a43d7000b4646da4818220d501f
Author: Linus Torvalds <torvalds@woody.linux-foundation.org>
Date:   Thu Nov 15 16:41:52 2007 -0800

    dirty page balancing: Get rid of broken unmapped_ratio logic
     
    This code harks back to the days when we didn't count dirty mapped
    pages, which led us to try to balance the number of dirty unmapped pages
    by how much unmapped memory there was in the system. 
     
    That makes no sense any more, since now the dirty counts include the
    mapped pages.  Not to mention that the math doesn't work with HIGHMEM
    machines anyway, and causes the unmapped_ratio to potentially turn
    negative (which we do catch thanks to clamping it at a minimum value,
    but I mention that as an indication of how broken the code is).

Some examples and their output:

[aashley2@aswatama ~]$ grep -e "Linus" from_mr_torvalds.txt
Author: Linus Torvalds <torvalds@woody.linux-foundation.org>
[aashley2@aswatama ~]$ grep -e "^ " from_mr_torvalds.txt
    dirty page balancing: Get rid of broken unmapped_ratio logic

    This code harks back to the days when we didn't count dirty mapped
    pages, which led us to try to balance the number of dirty unmapped pages
    by how much unmapped memory there was in the system.

    That makes no sense any more, since now the dirty counts include the
    mapped pages.  Not to mention that the math doesn't work with HIGHMEM
    machines anyway, and causes the unmapped_ratio to potentially turn
    negative (which we do catch thanks to clamping it at a minimum value,
    but I mention that as an indication of how broken the code is).
[aashley2@aswatama ~]$ grep -e "[A-Za-z]*:" from_mr_torvalds.txt
Author: Linus Torvalds <torvalds@woody.linux-foundation.org>
Date:   Thu Nov 15 16:41:52 2007 -0800
    dirty page balancing: Get rid of broken unmapped_ratio logic
[aashley2@aswatama ~]$ grep -e "^[A-Za-z]*:" from_mr_torvalds.txt
Author: Linus Torvalds <torvalds@woody.linux-foundation.org>
Date:   Thu Nov 15 16:41:52 2007 -0800

Troubleshooting

Someone is logged on to a Linux computer and the screen is locked- how can I log them off so I can use the computer?

If you're sure they haven't just stepped out for a moment, you can do one of two things:

  • 1) Press CTRL-ALT-Backspace. This restarts the X Window System, which logs them out. Use this, as it's much faster than (2).
  • 2) Reboot the computer manually using the power button. Depending on the computer, this might take a while, so use (1) if possible.


I need to open an rar file, but the cluster doesn't have an rar unpacking utility!

The Engineering Computing Consultants have made the utility unrar available:

cp /afs/nd.edu/user26/engcomp/Public/unrar-2.71.tar ~/
tar xvf unrar-2.71.tar
cd unrar-2.71
make

This creates an executable file unrar with which you can unpack rar files. Usage:

~/unrar-2.71/unrar e file.rar


I'm trying to use Mathematica through a remote SSH session, but I get an error.

This solution is for the following error message:

A serious error has occurred while Mathematica was starting up. Mathematica will probably not function properly until this problem is resolved. 
You may choose to continue anyway, but Mathematica may crash or exit without warning.

The Mathematica fonts are not properly installed in your system. Without these fonts, typeset mathematical expressions cannot be displayed properly.

See this link on the Wolfram support site.


Resetting your .login and .cshrc files

Reseting your .login and .cshrc files