24
Introducing UNIX EMBnet www.embnet.org slide 1 Introducing the UNIX Operating System

Introducing UNIX EMBnet slide 1 Introducing the UNIX Operating System

Embed Size (px)

Citation preview

Page 1: Introducing UNIX EMBnet  slide 1 Introducing the UNIX Operating System

Introducing UNIX EMBnet www.embnet.org slide 1

Introducing the

UNIXOperating System

Page 2: Introducing UNIX EMBnet  slide 1 Introducing the UNIX Operating System

Introducing UNIX EMBnet www.embnet.org slide 2

What is UNIX?

•A family of operating systems

IRIX

SOLARIS

AIX

LINUX

Digital UNIX

HP-UX

...

•Multitasking

Runs more than one program at the same time.

A busy system can be running several hundred or even thousands of programs at the same time.

•Multiuser

Many different people can use the system at the same time.

•Networked

It is designed to be linked to other computers and to allow people to work over a network.

The network IS the computer.

Page 3: Introducing UNIX EMBnet  slide 1 Introducing the UNIX Operating System

Introducing UNIX EMBnet www.embnet.org slide 3

XXprogX ·unix> help

Press ENTERto continue:

Disk storage

Memory

Network adapter

Modem

Screen

Keyboard

UNIX

Kernel

What does UNIX do?

The Computer

•Controls access to the hardware.•Prevents programs interfering with each other.•Provides an easy way for programmers to talk to the electronics.•Controls data storage and protection.

The Shell (or command line)•Allows the user to interact directly with the computer by typing commands.•The shell interprets these and instructs the kernel accordingly.•Very powerful but can be intimidating

Console programs•Run from the shell•Use one program actively at a time

The X Window System•Graphical interface (point, click, drag, drop etc.)•Network enabled•Can use many programs at once•Is a separate program•Easier to use than the shell but less powerful

Pointy, clicky program.•Any number of users can use any number of programs and methods to access the system from any number of remote machines at the same time.

usersUser Interaction•Many different users, typically accessing the system from remote machines in different ways

Page 4: Introducing UNIX EMBnet  slide 1 Introducing the UNIX Operating System

Introducing UNIX EMBnet www.embnet.org slide 4

Unix doesn’t really care where you log in from, though some system administrators might.

Logging in

Log in from anywhere you have permissionHave graphical output sent anywhere you have permission

You must have a username (login id) to use a unix system

This identifies you to the system so it can manage your work properly.

Every user is a member of one or more groups of users.

This helps the system manage different types of user properly.

Page 5: Introducing UNIX EMBnet  slide 1 Introducing the UNIX Operating System

Introducing UNIX EMBnet www.embnet.org slide 5

Connecting to embnet.orgConnected.

Welcome to the European Molecular Biology Network.

Login:

Logging in

Connect to the unix machine using a suitable program on your local machine.

TelnetXtermSecure ShellKermitOther terminal emulators

username

unix is case sensitive. username is not the same as Username or USERNAME

Password:

unix doesn’t show anything on the screen as you type your password.

The system will be unavailable on friday afternoon for maintenance.You have new mail.username@embnet ~>

You may get some messages here from the system administrator.

Page 6: Introducing UNIX EMBnet  slide 1 Introducing the UNIX Operating System

Introducing UNIX EMBnet www.embnet.org slide 6

The shell or command lineSeveral different shells but they behave more or less the same

username@embnet ~>

your usernamethe machine you are logged in to

your present locationThe prompt can be customised to look how you wish

1. The Prompt.

Page 7: Introducing UNIX EMBnet  slide 1 Introducing the UNIX Operating System

Introducing UNIX EMBnet www.embnet.org slide 7

The shell or command line2. Commands

username@embnet ~>

The shell breaks the command up into individual words

ls -ald *.txt

The first word is a command

ls -ald *.txtls -ald *.txt

The subsequent words form a list of arguments to the commandarguments beginning with - are options

ls -ald *.txtls -ald *.txt

* is a special character. It means ‘any group of characters’ (including none). The shell finds all the filenames that match anything.txt and adds them to the list of arguments

By default the boundary between words is a space.To get the shell to treat a phrase that includes spaces as a single word, put it in quotes like this: 'my word' or "my word".Options control how the program runs. '-a -l -d' is equivalent to '-ald'

Page 8: Introducing UNIX EMBnet  slide 1 Introducing the UNIX Operating System

Introducing UNIX EMBnet www.embnet.org slide 8

More Special Characters

* ? " '

& | > <

`` $ \

Any group of characters including none. Any single character.word delineation

Cause the process to run in the backgroundPipe.Pass the output of the command on the left as the input to the command on the right.

Redirect the commands output, eg. to a fileRedirect a commands input. eg. from a file instead of the keyboard.Backticks (not ').Take the output of the command as an argument

String or DollarTreat the next word as a variable and write out its value

Backslash.Change the meaning of the next character.

Some special characters can lose their special meaning if they are inside quotes.

;SemicolonSeperate commands typed in together.

Page 9: Introducing UNIX EMBnet  slide 1 Introducing the UNIX Operating System

Introducing UNIX EMBnet www.embnet.org slide 9

Organisation

"Everything is a file"

•An ordinary file contains data.•A directory contains other files.•A link is a file that is a shortcut to another file.

The data could be an image, a document, a set of instructions (a program) or any fixed information.This is also known as a folder on some systems. A directory can contain other directories (which are

then known as sub-directories.)Files can have more than one name, and be in

different directories at the same time

•There are many other types of file .

You don't need to worry about these. You probably won't come across one in normal use of the system.

Page 10: Introducing UNIX EMBnet  slide 1 Introducing the UNIX Operating System

Introducing UNIX EMBnet www.embnet.org slide 10

Organisation of the file system

//

The top of the file system is the directory '/', commonly known as the root directory

binbin usr etchome

Several subdirectories under the root directoryusername

Another subdirectory.project

seq2 seq1seq3seq4

letterprotAn example users home directory with a subdirectory and several files

Any file in the file system can be uniquely identified by describing the path to it from the root directory.

/home/username/prot

//

/home/username/prot

home

/home/username/prot

username

/home/username/prot

prot

Page 11: Introducing UNIX EMBnet  slide 1 Introducing the UNIX Operating System

Introducing UNIX EMBnet www.embnet.org slide 11

Organisation of the file system

//

binbin usr etchome

username

project

seq2 seq1seq3seq4

letterprot

Any process is located somewhere in the filesystem

The command 'pwd' will tell you where.

username@embnet ~> pwd/home/username '~' is a unix shortcut meaning

'your home directory'

Page 12: Introducing UNIX EMBnet  slide 1 Introducing the UNIX Operating System

Introducing UNIX EMBnet www.embnet.org slide 12

Looking at the file system

//

binbin usr etchome

username

project

seq2 seq1seq3seq4

letterprot

'ls' lists the files in a directory or directories

username@embnet ~> lsprot letter projectusername@embnet ~>project:seq1 seq2 seq3 seq4

ls project

Without an argument, ls lists all the files that don't start with . in the current directoryThere are many options to ls that allow you to select and control the information it presents.

Page 13: Introducing UNIX EMBnet  slide 1 Introducing the UNIX Operating System

Introducing UNIX EMBnet www.embnet.org slide 13

Moving around the file system

//

binbin usr etchome

username

project

seq2 seq1seq3seq4

letterprot

'directory' is the directory to which you want to move. The name can be written as the full path (from root) or as the relative path (from your current directory)

You can move to a different directory with the command 'cd directory '

username@embnet ~> cd /home/username/projectusername@embnet ~/project> pwd/home/username/project

username@embnet ~> cd projectusername@embnet ~/project> pwd/home/username/project

username@embnet ~/project> cd ..

'..' means the parent directory.'.' means the current directory.

..

username@embnet ~> pwd/home/username

username@embnet ~>

repeat using the relative path

Page 14: Introducing UNIX EMBnet  slide 1 Introducing the UNIX Operating System

Introducing UNIX EMBnet www.embnet.org slide 14

Changing the file system

//

binbin usr etchome

username

project

seq2 seq1seq3seq4

letterprot

You can create a new subdirectory in the current directory with the command ' mkdir directory '

username@embnet ~> mkdir modelusername@embnet ~>

model

Page 15: Introducing UNIX EMBnet  slide 1 Introducing the UNIX Operating System

Introducing UNIX EMBnet www.embnet.org slide 15

Changing the file system

//

binbin usr etchome

username

project

seq2 seq1seq3seq4

letterprot

You can delete an empty subdirectory with the command ' rmdir directory '

username@embnet ~> rmdir model

model

username@embnet ~>

modelYou can delete a file with the command ' rm file '

rm protusername@embnet ~>

You can delete a subdirectory and its contents with the command ' rm -rf directory '

Page 16: Introducing UNIX EMBnet  slide 1 Introducing the UNIX Operating System

Introducing UNIX EMBnet www.embnet.org slide 16

More about files: filenames

Filenames can contain any normal text character including spaces and special characters.

Filenames can be almost any length.It is best to stick to a-z, A-Z, _, -, and numbers.It is best to keep them short as it saves typing.

If a filename contains a special character or a space you may need to put quotes around the whole path.

Special characters in filenames can cause problems with some programs.

Page 17: Introducing UNIX EMBnet  slide 1 Introducing the UNIX Operating System

Introducing UNIX EMBnet www.embnet.org slide 17

More about files: reading files

You can print the contents of one or more files to the screen with the command: 'cat file1 file2 ...'

cat prints the whole file at once, so a file longer than just a few lines will run off the top of your screen.

You can view the contents of one or more files a page at a time on the screen with the command: ' more file1 file2 ...'

more will let you search through a file, go backwards and forwards and has many other functions.

You can print the first few lines of a file with the command: 'head file1 file2 ...'

The last few lines can be viewed with 'tail'

Page 18: Introducing UNIX EMBnet  slide 1 Introducing the UNIX Operating System

Introducing UNIX EMBnet www.embnet.org slide 18

More about files: editing files

You can change the content of text files and create new files with a text editor.

Text editors edit text. They do not try to format the text like word processors.

PICO

A novice friendly basic text editor used as standard on many systems. Start with the command 'pico filename'

EMACS

A powerful editing environment which can be programmed. It has many modes for auto layout of program code. Start with the command 'emacs filename'

VI

A powerful editor which can be somewhat confusing for newcomers. It is designed for rapid editing of text files and programming. Start with the command 'vi filename'

Page 19: Introducing UNIX EMBnet  slide 1 Introducing the UNIX Operating System

Introducing UNIX EMBnet www.embnet.org slide 19

If newfilename is a directory, then the file will be copied to 'newfilename/oldfilename'

You can copy a file with the command 'cp oldfilename newfilename'

username@embnet ~>letter projectusername@embnet ~>

More about files: copying files

ls

cp letter draftusername@embnet ~> lsdraft letter projectusername@embnet ~>Warning:

If a file called newfilename already exists then it will be overwritten.The command 'mv oldfilename newfilename'

can be used to rename a file

Page 20: Introducing UNIX EMBnet  slide 1 Introducing the UNIX Operating System

Introducing UNIX EMBnet www.embnet.org slide 20

•Permissions determine who can read, write, or execute a given file.

More about files: permissions

•Every file is protected to a greater or lesser extent.

OwnerGroupWorld

The user who owns the file

Other users in the same group as the user who owns the file. All the other users in the system.

•Files can have read, write or execute permission for each of the three types of user.

Page 21: Introducing UNIX EMBnet  slide 1 Introducing the UNIX Operating System

Introducing UNIX EMBnet www.embnet.org slide 21

You can view the permissions for a file by listing it in long format with the command 'ls -l filename'

username@embnet ~> ls -l letter-rwxr--r-- 1 username users 6048 Aug 17 16:07 letter

The letter lThe file type:- - ordinary filed - directoryl - link (shortcut)

Permissions for the owner

-rwxr--r--

Permissions for the owners group

-rwxr--r--

Permissions for everyone else

-rwxr--r-- username

The user who owns the file

users

The files group

6048

The files size

Aug 17 16:07

The date the file was last modified

letter

The files name

More about files: permissions

Page 22: Introducing UNIX EMBnet  slide 1 Introducing the UNIX Operating System

Introducing UNIX EMBnet www.embnet.org slide 22

change is the modification you want to make to the files permissions

username@embnet ~>

You can change the permissions for a file with the command 'chmod change filename'

-rwxr--r-- 1 username users 6048 Aug 17 16:07 letterusername@embnet ~>

More about files: permissions

ls -l letter

chmod o-r letterchmod o-r letter

For whom you are changing permissions:o - otherg - groupu - usera - all

chmod o-r letter

Permissions being changed:r - read permissionw - write permissionx - execute (run) permission

chmod o-r letter

How you are changing permissions:- - remove these permissions+ - add these permissions= - set permissions to this

username@embnet ~>-rwxr----- 1 username users 6048 Aug 17 16:07 letterusername@embnet ~>

ls -l letter

Page 23: Introducing UNIX EMBnet  slide 1 Introducing the UNIX Operating System

Introducing UNIX EMBnet www.embnet.org slide 23

You can get help on a command by using the command ' man command'

Getting help

This will bring up the manual page and show it to you screen by screen

If you do not know what a command is called, use the option '-k' to get a list of commands that may be relevant'man -k word'

This will find all manual pages containing word in the short description of the command.

Try using the options '-h', '-help', or '--help' if you can't find the man page.

Page 24: Introducing UNIX EMBnet  slide 1 Introducing the UNIX Operating System

Introducing UNIX EMBnet www.embnet.org slide 24

Useful literature

'Learning the UNIX operating system', O'Reilly press.

'UNIX Quickguide'EMBnet