introduction to unix system & commands - welcome ... lecture on unix introduction to unix system...
TRANSCRIPT
A lecture on UNIX
Introduction to UNIX system & commands
Koichi KusakabeGraduate School of Engineering Science,
Osaka University
Let’s use the X window system
We use machines operated by UNIX system* .Each user is identified by user id & password.Push the monitor button and log in the system.
*In this workshop, terminal machines are operated by SUSE Linux.
Input your id, which is one of x60711~x60770.
Input your password written in your sheet.
Operation of KDE
Let’s see what happens, when you move your mouse and the cursor.Let’s push the left button of your mouse on . You will see a menu.
Slide your mouse to high-light the item that you want to use.When you retype the left button, you will see an action depending on the item you selected.You will see a terminal.
Selection of the terminalTerminal selected.
When you want to use a terminal window, please move the mouse cursor and click the window, so that the terminal is selected.Then, you will see a cursor.
Log off the systemWhen you end your whole job, please select ‘Log out…’ in the menu appearing by clicking. Here!
You can choose “End Current Session” to log out the terminal.Your terminal will show the login message again.You may leave the terminal. You do not have to turn off the power of the console by choosing “Turn Off Computer” in the second step above.
Operation of UNIX commands
You can make the UNIX OS perform an action by sending a command in a form,command [-option] [filename]
This format is a standard. In this operation,1. Command name is typed in lowercase,2. A return key is typed at the end of the
command.If you see a capital letter by typing a key, you may unlock the caps by retyping .Caps
Lock
Command name arguments
Examples
A command with a command name only.home/x60***> logout
A command with an argument, which may be omitted.
home/x60***> cat .bash_logouthome/x60***> cat
Let’s see. You can end the operation by in the second example.A command with an argument.home/x60***> manhome/x60***> man cat
Please also refer to a booklet , ``計算機(Linux)使用法’’.
Ctrl c+
Type Ctrl. Keeping it, then type c.
Abbrev. of concatenate
Look! What Unix OS sais?
To end, type q .
ls (LiSt) command
When you login Unix OS, you are doing a job at a point in a place called the file system.This point is a position in a real file system in a disk.To explain the system, I ask you to look at your ‘home position’ called the home directory. Please type ‘pwd’./home/x60***> pwd/sc/cmc/home/x60***Do you find a similar output on your screen?To see a list of file, please type a command ‘ls’./home/x60***> ls
Oops! You might not see anything but a cursor, or smaller numbers of tiles than that you have.Indeed, you have files. But they might be invisible by a definition. You need an option to see it.
Abbrev. of LiSt.
This means Print Working Directory.
. (dot) files for definition of environmentWe ask ‘ls’ to behave a little cleaver.
/home/x60***> ls –laF
Don’t you see something like this?total 52drwx------ 4 x60701 kyoudou 4096 2009-09-07 14:09 ./drwxr-xr-x 45 root root 24576 2009-08-21 19:53 ../.. ..-rw-r--r-- 1 x60701 kyoudou 1177 2009-09-07 19:53 .bashrc
‘-laF’ is the option. This represent a combination of l = long listing , a = all and F = append indicator .
(1) (2) (3) (4) (5) (6) (7) (8)
(1) File type(2) Access limitation(3) File numbers(4) Owner
(5) group(6) File size in bite (7) Date of last access(8) File name
Precisely, . (dot) files are not displayed, when ls is called without the option.
These are directries.
What is the file system?In the UNIX OS, everything is treated as a file.
A file stored in a hard diskThe hard distTerminalKey boardMouseMemory
All files are placed under the ‘root’ file. The whole system is the file system.Every user stands on a place called the current directory located at a position in the file system, for operation.In the terminal system, or in the machine ‘frontd’, the user is placed at /sc/csc/home/x60***.The file is the same for your terminal machine and frontd. So, it may be managed from both machines.
The file system has a tree structure.
Tree structure
/
bin etcdev sc usrtmplib sbin
bin
x60701 x60702
lib localcmclscp
less emacs vim
vi
bin : directory
: filecp
To identify a file, we have two ways.
Absolute path: identify a file hierarchically from the root ‘/’.
Relative path: identify a file using a relative position from the current directory.
/usr/bin/less
../../../usr/bin/less
/sc/cmc/home/x60701
~ Tilde represents the home directory../test
The period ‘.’ is the current directory.‘..’ means the parent directory.
root
home
How to change the directory?
The current directory is where you are.The parent directory of it is a directory where the current directory locates in the tree structure.The root is its own parent directory.
/
sc
home
x60701
cd sc
cd cmc
cd home
cd x60701
cd ..
cd ..
cd ..
cd ..
You can jump by ‘cd ~’ or ‘cd ‘.
Exam 1: Try!/home/x60***> cd //home/x60***> ls/home/x60***> cd ~
Note: If you lost the current directory, you can do ask ‘pwd’ to UNIX and check the files by ‘ls’.
Abbrev. of Change Directory
Exam 2: What happens?/home/x60***> cd ../home/x60***> ls/home/x60***> cd
cmc
The terminal does hung-up. You can do it.
No character appears for your keystroke, thenType . Or may restart the input, when the scroll is stopped.
No prompt (flushing cursor at /home/x60***> ) appears. Then, you can try one of these.
(When you call cat without arguments.)(When a command does not stop.)Then, you can search an unfinished command
using ‘ps’ command and stop it by ‘kill’. (This action may be required when does not work.)
If something wrong with the cursor, then.
Ctrl + q Ctrl + s
Ctrl + d
Ctrl + c
Ctrl + z
Ctrl + c
Ctrl + j
How to start your job?
Many programs are packaged and stored in a compressed file. You will perform un-compression.
Un-compression of a tar-archived file would be,/home/x60***> tar xvf test.tar/home/x60***> tar zxvf test.tgz
Un-compress
Compile
Write inputs
Run the program
Flow of usage Command in use
tar (tape archive), uudecode
make, ifort (follow your instructor.)
emacs, vi
Command made by compilation, qsub
For zip file
User interface
You have two user interfaces. Each of them has its own merits and demerits.
Graphical user interface (GUI)Easy, understandable at a look.Large requirements for memory and data traffic.
Character user interface (CUI)Fast operation, when you know commands.Beginners might feel difficulty in operation.
We recommend you to use X Windows and its functions.
Applications of X Windows:xterm, emacs, xcalc
Editors : for better creation of text files
Typical ones given in UNIXEmacs : Full-screen editor with GUI. It works in a terminal window as a character-based editor. vi : Text editor called ‘Visual editor’ by Bill Joy. It is very familiar in the UNIX world.
How to start up:Emacs
/home/x60***> emacs &/home/x60***> emacs -nw
vi/home/x60***> vi
Emacs will start as a background process.
No Window option: no new window will come & emacs start up in the terminal window.
How to use Emacs (basics)Let’s start Emacs up with new Window./home/x60***> emacs &
Don’t you find?In the first page, message to introduce Emacs is given.You can start editing a fileby typing . Please insert a file name atFind file : ~/
which is shown in a lower sub-window.You may edit test.txt by /home/x60***> emacs test.txt &which allows you to startEmacs up with the file shown.
/ represents the home directory.
Name of the target file.
Ctrl + x Ctrl + f
Emacs keystroke
Cursor upCursor downOne character left One character rightMove to the endMove to the topMove to next pageMove to former pageForward deleteDelete a characterDelete letters in the rightUndoDelete line in the rightDelete up to the file endShow on-line helpMarkingCut from the markYankCopy from the mark
Move to line endMove to line topForward searchBackward searchOpen a fileOverwrite the fileSave by a nameEnd (quit)Open one windowOpen two windowsUndo the commandStop the command
You can do copy or cut&pasteusing your mouse. Command may be called in the GUI menu line.To make completion, please type
, in a middle of writing a word.may be .
Ctrl + p
Ctrl + n
Ctrl + b
Ctrl + f
Esc , >
Esc , <
Ctrl + v
Esc , v
Ctrl + d
Del
Esc , d
Ctrl + _
Ctrl + k
Esc , k
Ctrl + h
Ctrl + Space
Ctrl + w
Ctrl + y
Esc , w> Shift + .
Ctrl + r
Ctrl + x
Ctrl + x
Ctrl + x
Ctrl + x
Ctrl + x
Ctrl + x
Ctrl + f
Ctrl + s
Ctrl + w
Ctrl + c
Ctrl + 1
Ctrl + 2
Ctrl s
Ctrl + e
Ctrl
+
+ a
Ctrl + g
Ctrl + Z
Tab
↑
↓
←
→
Modes of vi & some commands
Command mode(Just started)
Text mode(You can write!)
Command mode
/home/x60***> vi newtest.txtLet’s do start vi up by
Please typea (append)i (insert), orO, o (insert a line)
Push button afterfinishing the input.
Command mode
Esc
Text mode
a, i, o, O Esc
$ vi newtest.txt ZZ or:w & :q
SelectZZ (write & quit) or:w (write) & :q (quit)
If you have a trouble in vi
Undo a command just done:In the command mode (If you are in text mode, type and then) push ‘u’ (undo).Re-flesh the screen :
Push in the command mode.If you did some unwished operations:Type ‘1P’ in the command mode.If you cannot find a way by doing some solutions above, please consult instructors (teachers & tutors).
Esc
Ctrl + l