Introduction to Linux
What is Linux? Windows
Linux is an open-source operating system
Mac
Terminal
- During this course, you will manipulate Linux using a command-line interface.
- You will create files and directories, use text editor, plot graphs, and compile Fortran programs by typing
commands.
- When you type commands in Linux, you interact with the operating system (OS) through a special
program called a shell.
- All commands described below are bash shell features.
- We refer to a window in which a shell is executing commands as terminal.
An example of the terminal :
Files and Directories
There are three different types of files:
- regular files, such as plain text, source code, executables and postscript files.
- directory files, which contain other files such as regular files or/and directories.
- special files such as block files, character device files, named pine files, symbolic link files,
and socket files.
Pathnames and working directories
- In Linux, all file systems are rooted in the special directory called '/'.
- The pathnames of all files within a file system start with a '/'.
e.g: /home/honors/[Link]
The file named [Link] is in a directory with absolute pathname honors which itself found in
directory /home.
Files and Directories
Characteristic of the filenames
- The filenames should not contain more than 255 charaters.
- Any character except the forward slash ('/') and 'null' may be used.
- However, avoid using characters which are special to shell such as (, ), *, ?, $, as well as
blank spaces.
- If you want to separate word, it is suggested to use underscore '_' or '-'.
eg. /example1_derivative_honors
square_root_calculation.txt
Overview of Linux commands
The general structure of Linux commands is
command_name [options] [arguments]
File Handling commands File Handling commands (contd.)
- mkdir : make directories - mv: rename or move files
eg. mkdir honors eg. mv [Link] [Link]
- ls : list directory contents - rm: remove files or directories
eg. ls honors eg. rm [Link] [Link]
- cd : changes directories - find: search for files in a directory
eg. cd honors eg. find [Link]
- pwd print name of current working directory - history: prints recently used commands
- vi (vim): a programmers text editor
eg. vi [Link]
- cp : copy files and directories
eg. cp [Link] [Link]
Overview of Linux commands
The general structure of Linux commands is
command_name [options] [arguments]
Text Processing System Administration
- cat : concatenate files and print on the standard - chmod: change file access permissions
output eg. chmod u+x [Link]
eg. cat [Link]
- who : show who is logged on
- echo: display a line of text
eg. echo I love physics
- grep: print lines matching a pattern
eg. grep energy [Link]
Exercises (practice):
From your terminal window, do the followings in red and try to answer questions
$ cd / $ cp -r example1 example2
$ pwd $ ls
( what do you see ? ) ( what do you see ? )
$ ls
$ cd $ cp -r example2 ../example3
$ pwd $ ls
$ ls ( what do you see ? ) ( why you don't you see example3 ? )
$ mkdir exercise1 $ mv ../example3 .
$ ls $ ls
$ cd exercise2 ( why do you get an error here ? )
$ ln -s example3 example4
$ ls
$ cd exercise1
( why example4 is in green ? )
$ ls
$ mkdir example1 $ rm -r example1
$ ls
$ ls
$ cp /etc/passwd . $ rm -r example2
$ ls $ ls
$ mv passwd example1 $ rm -r example3 example4
$ ls $ ls ( what do you see ? )
$ mv passwd example1 ( why do you get an error here ? )
Introduction to Xmgrace
Xmgrace
- It is a useful plotting package available with linux operating system.
- It is a 2D plotting tool which allows you to interactively modify plots, to set all kind of plot parameters,
change the appearance of your figure, and to save the figure in the format of your choice.
Plotting data
- To launch xmgrace, open a terminal window.
- Type xmgrace.
- Select Data icon at the top of the window with your left mouse button.
- Selecting Import and ASCII. You should get a list of all the files in your directory which end with .dat,
.agr and .xmgr.
- Highlight the desired filename with the left mouse button, and then select the OK icon from the bottom
of the box.
- you should get the plot. You can import additional plots in the same way.
Or
Type in terminal xmgrace your_data_name.dat
Saving your work
- To save your work click on the file icon and then choose “Save As”.
- It is conventional to use the suffix '.agr' or '.xmgr' 'to denote an xmgrace file (eg. [Link]).
- You can re-open it with xmgrace. (xmgrace [Link])
Refining your plot- Data Sets
Xmgrace makes certain choices automatically, like the numerical ranges of the horizontal and vertical
axes, the color of the line segments connecting the data points, etc. These can all be changed by you to
more desirable values.
You can modify many axis properties
Using “Axis properties” dialog box, try to obtain plot on the right
Next using “Set appearance” dialog box, try to obtain plot on the right
Final step is to export (print) figure in .eps format
- Click on “Apply”
- do “Ctrl+P” from keyboard or
choose file and click on “Print”.
- Open generated [Link] using
evince
evince ~/[Link] &