Linux Basics

The Linux operating system is a flavor of the Unix system. The Unix system as a whole is the dominating operating system used in scientific computation and complex instrument operation. It is also the most used platform for computer servers. Linux is a free open-source software. It has an increasingly wide applications including operating many hand-held devices such as certain cell phones using the Linux-based Android operating system.

Both Varian (now Agilent) and Bruker NMR instruments use Linux as its main operating system. A number of significant NMR processing packages, including nmrPipe/nmrDraw, are targeted for the Unix and Linux systems; some only work under Linux. Long-term stability of the Unix/Linux programming language, its less virus-prone system, overall system stability, open-source nature and frequent updates, scalability, and full user control are among the key Linux advantages.

Although newer Linux tends to look more like Windows with buttons and menus, the unique advantage of Linux still lies in part in its use of terminal window and commands. The following summarizes the basic file structure and commands in Linux. Note that a lot of simple file/folder operations such as rename, copy, delete, etc. can also be easily done with mouse button clicks just like in a Windows or Mac operating system.

Terminal Window

A terminal window can be opened by right button clicking inside Desktop and selecting Open Terminal, or accessed through Accessories→Terminal, depending on the specific Linux version.

Inside the terminal, commands can be entered after the prompt. The terminal line that contains the prompt is usually something likes this:

where the username (smith) and the computer name (nmr500) are shown, followed by the prompt ($).

Space and Case

Under all Unix systems, it is best not to use space in a file name, command name or any other naming. Doing so is asking for a lot of troubles. If you do have a Windows file shown or residing on Linux with spaces in the name, you will have to enclose the name with double quotes when the name is called in a command:

Under Unix, space is typically used to separate commands and list of arguments.

It is best to use underscore (_) rather than space or dash (-) in file names.

Dash (-) has special meanings in a Unix environment (often specifies optional arguments for a program) and may run into trouble when the file is called by certain programs with optional command argument supplied.

In all Unix systems, file and command names are case-sensitive. Therefore, nmrgroup and NMRGroup are two completely different folder names.

Linux File Structure: pathname

Under a Unix system, all files and folders can be addressed by a "path" name, a unique name that points to the location of a file or folder in the file structure. A folder is also called a directory. The file and folder concept is identical to what you see on Windows or Mac. Path name examples:

Each slash (/) separates a folder from its parent and child folder. The top slash (/) is called the root directory.

The location of a file can be specified in two ways:

1: Absolute path

2: Relative path

The current folder specification /home/NMRGroup/smith can be omitted in using the relative pathname.

To display current working directory name (or pathname), type:

Home Directory

The home directory contains a number of hidden setup files and is also the default directory when a user logs in. The location (thus the pathname specification) depends on how the system is set up by the administrator. Most often, a home directory is simply /home/smith for username smith . On our NMR instruments, all user home folders sit under their own group name folders (i.e. /home/Pettus/smith).

Under each user's home directory, there are more folders and files (such as *.fid folders). A folder named vnmrsys (/home/Pettus/smith/vnmrsys/) is an important Varian specific folder that contains a number of subfolders:

Do not change these files and folder structures unless you are sure what you are doing.

Change Folder and List Files

A command is entered after the prompt in a terminal window, followed by <ENTER> or <RETURN>.

In the last example, two dots (..) is an alias for one directory up (or parent folder).

From inside any folder, enter cd to return to home directory.

Permission

All Unix systems allow "permission" control. This includes file ownership (user and group), Read/Write/Execute permission, etc. Typically, by default only the owner of the files have read/write/execute permission of the user's files, other group users have only read and execute permission. The owner should be the only one who can modify or create files under his home directory (including subfolders) or other directories owned by the user.

Permission can be changed. But for beginners, it is best not to change default permission of files and folders.

Create New Folders and Copy Files

To create or copy files/folder to a specific location, it is best to first to travel down (with cd command) to the folder (target location) where you want the new folder to sit under or where you want to copy the files over. You must have write permission to the location where you create or copy files.

Rename and Delete Files or Folders

CAUTION: Be extremely careful with the rm command, particularly when it is combined with wildcard character (*). Some systems do not prompt for confirmation.

To rename a file or folder, use the mv command:

To move a file or folder from one location to another location where you have write permission:

To delete a file:

To delete a folder:

To delete all files with names starting with old and ending with txt:

To delete a few files and folders:

This deletes one file and two folders. The -r options works with both files and folders.

Other Commands and Programs


H. Zhou updated Sept 2011