Introduction to Linux

Linux is a Unix-like computer operating system assembled under the model of free and open source software development and distribution. It is packaged in a format known as a Linux distribution for desktop and server use. Some popular mainstream Linux distributions include Ubuntu, Fedora and Debian. If you do not yet have a Linux distribution installed on your system, you can use one of the following download links:

In order to communicate with Linux and issue commands (see below), the use of a terminal is useful. One such terminal (PuTTY) can be found with the following link:

Linux commands

In order to use COHERENS, some knowledge of basic Linux commands is necessary. As you start using COHERENS, you will quickly see that most of these commands will become second nature to you, and you will refer to these documents only sporadically.

There are three important things to know when working on the Linux command line:

  1. Linux commands and file names are . Thus Run is not the same as run.
  2. Linux can help you finish commands (especially file names and directories) when you press on the tab key. Try using this as often as possible.
  3. In Linux, files and folders are separated by a forward slash (/) not a backslash (\) that is used in Windows. Using the wrong slash can give very unexpected results!

In order to help you along, the most frequently used commands are listed and divided into relevant categories below. There is plenty of documentation available that extensively lists and describes these commands, for example here.

Getting help

If you do not know which command to use, use apropos. It will tell you which commands to use. For example, if you want to know how to copy a file, type:

$ apropos copy

This gives you many results, including the one you need, which is cp. In order to understand how to use this command, use man. Type:

$ man cp

Working with files

To see which files are in a directory use ls or ll. The latter gives more information. Try them both:

$ ls
$ ll

The command for copying a file is:

$ cp sourcefile destination

The command for moving a file:

$ mv sourcefile destination

The command for deleting a file is:

$ rm filetodelete

In case you want to use any of these commands on directories, you must add -r:

$ rm -r directorytodelete

In order to know how much free space there is on the hard disk, type:

$ df -h

Finally it is important to know that you can use the | symbol to send output from one program to another program. For example, in order to pass the results of the "check free space" command to a text file of the program less, you can type:

$ df -h | less

Exit less by typing the letter q.

Directory management

To change directory, type the following command:

$ cd directory

with directory the path of the directory you wish to enter. If you want to go up one folder, simply type:

$ cd ..

In order to create a directory (i.e. a folder), type the following:

$ mkdir directory

with directory the name of the directory you are creating.

Lastly, in order to create virtual links to another directory, type:

$ ln -s directory name

Here, the two arguments are first the location to which the link points and secondly the name of the link.

Searching for text

The command grep searches a text file for the occurrence of a word given by the user.

$ grep 2003 river0T.runlogA

This command looks for all occurrences of the string 2003 in the file river0T.runlogA.

If you wish, you can send the results to another program, called tail. Tail returns only the last lines of data. For sending information from one program to the next use a pipe, or the vertical line (|). Thus, for example, in order to find the last occurrence of the string 2003 in the file river0T.runlogA, use the command:

$ grep 2003 river0T.runlogA | tail -1

Documentation link

There are plenty of other commands you can use in Linux. You can find a comprehensive A-Z list of these commands at the following location:

http://ss64.com/bash/