A Small UNIX Tutorial - PowerPoint PPT Presentation

1 / 28
About This Presentation
Title:

A Small UNIX Tutorial

Description:

If no name is given list those files in current directory. ... mv works for directories in a similar fashion. More UNIX commands. rm file(s) delete file(s) ... – PowerPoint PPT presentation

Number of Views:67
Avg rating:3.0/5.0
Slides: 29
Provided by: zhen2
Category:

less

Transcript and Presenter's Notes

Title: A Small UNIX Tutorial


1
A Small UNIX Tutorial
  • By CGS3063 staff

2
Whats UNIX?
  • An operating system claimed to be standard
    from microcomputers to supercomputers
  • Invented by ATT Bell Labs in late 60s
  • Currently there are different versions of UNIX
    such as SunOS, Linux, DEC OSF/1, AIX, HP-UX 10,
    Solaris, IRIX, SCO UNIX, etc.

3
Why we need UNIX?
  • For this class you need to work from your class
    grove account to finish your homework and/or
    submit your term paper
  • Knowing basic UNIX commands is essential to
    finish your homework

4
UNIX Commands
  • ls names list files contained in a directory
    name or that match a file name. If no name is
    given list those files in current directory.
  • ls a list all files including hidden files
  • ls l list in long format (including details
    like permissions, owner, size, etc.), works very
    much like dir
  • ls al list all files (including hidden files)
    in long format
  • ls dl dir_name lists information about the
    directory, dir_name.

5
What is a Directory?
  • Your home directory might contain a public_html
    directory. Your public_html directory might
    contain an index.html file.

c3063xxx
public_html
index.html
6
What is a Directory?
  • A file cannot hold a directory or a file!

c3063xxx
public_html
index.html
New_file_or_directory
7
What is directory?
  • Directories can hold files and other directories

/
tmp
users
bin
etc
backup
usern
file1
user2

public_html
user1
index.html
8
Whats a directory?
  • Files are grouped in the directory structure.
    The file-system is arranged like hierarchical
    tree (inverted)structure.
  • The top of the tree is called root which
    usually contains several sub-directories. In UNIX
    /(forward slash) is used to present the root.

9
Pathnames
  • Absolute Pathnames
  • In the previous tree /users/usern/file1 is an
    absolute pathname.
  • Relative pathnames
  • If you are already in the users directory, the
    relative pathname for file1 is usern/file1.

10
Specifying Paths
  • What is the absolute path to index.html?

/
tmp
users
bin
etc
backup
usern
file1
user2

public_html
user1
index.html
11
Specifying Paths
  • What is the relative path to index.html (assuming
    that usern is your pwd)?

/
tmp
users
bin
etc
backup
usern
file1
user2

public_html
user1
index.html
12
More UNIX commands
  • pwd let you know the absolute pathname of your
    current working directory (Print Working
    Directory)
  • cd dir change directory
  • cd .. go back to parent directory. .. is the
    relative pathname to the parent directory.
  • . -stands for current (working) directory.
  • the tilde character can refer your home
    directory

13
More UNIX commands
  • mkdir directories create one or more
    directories. You can specify them by absolute or
    relative pathnames.
  • cp
  • cp file1 file2 copy file1 to file2. If theres
    already a file2, the old one will be overwritten.
  • cp file(s) directory file(s) will be copied to
    the directory.

14
More UNIX commands
  • mv sourcefile targetfile basically mv renames
    sourcefile to targetfile. If theres a file with
    the same name as targetfile, it will be
    overwritten. mv works for directories in a
    similar fashion.

15
More UNIX commands
  • rm file(s) delete file(s).
  • rmdir directories delete one or more empty
    directories.
  • rm r directories can be used to delete non
    empty directories. !!!WARNING!!! This will DELETE
    EVERYTHING in that directory!!!
  • You can not recover your files after you removed
    them (unlike Windows OS).

16
Permissions
  • There are three types of file access supported by
    UNIX.
  • r read, view the contents of a file or a
    directory
  • w write, edit file/directory contents
  • x execute, run executable file

17
Permissions
  • Heres an example
  • Suppose you type in ls -l and the result is
  • rwx r-x r-- 1 hans doc 858 Aug 22 2228 hw1
  • What do all these symbols mean?

18
Permissions
  • - rwx r-x r-- 1 hans doc 858 Aug 22 2228 hw1

owner
links
type
File name
size
Modification date/time
group
User permissions
Group permissions
Other Permissions
19
Permissions
  • User the person who created the file.
  • Group the group owns the file.
  • Other the rest of the world
  • 754 is a decimal number. But you can represent
    each digit with a binary number.
  • 4 gt read permission, 2 gt write permission,
  • 1gt execute permission

20
Permissions
  • read4write 2execute1
  • rwx r-x r--

4 2 1
4 0 1
4 0 0
7 5 4
21
Permissions
  • rwx r-x r-- is a symbolic way to specify file
    modes, while 754 is a numeric way (remember 7 ?
    111, 5 ?101, 4?100 ? ). How would you represent
    this file mode numerically?
  • --x --x wx
  • How would you represent this bit string
    symbolically?
  • 6 1 4

22
Permissions
  • chmod mode file(s) another UNIX command! Change
    the access mode of one or more files. Examples
  • chmod 751 my_file the owner of my_file has
    rwx(7) permission, the group has r-x(5)
    permission, others have --x permission.
  • Tell me what the following command will do?
  • chmod urwx, gr, owr my_file
  • Remember user, group and others?

23
Get started
  • Create a new directory in your grove account
    named public_html by using the following command,
  • mkdir public_html
  • Go to this directory
  • cd public_html
  • Use pico to create a new file named index.html

24
Editor in UNIX
  • Some short cuts for the pico editor
  • G Get Help
  • O WriteOut
  • R Read File
  • Y Prev Pg
  • K Cut Text
  • C Cur Pos
  • X Exit
  • J Justify
  • W Where is
  • V Next Pg
  • U UnCut Text
  • T To Spell

25
Get started
  • After you save the file index.html, change the
    mode of this file by using the following command,
  • chmod 644 index.html
  • (urw-, gr--, or--)
  • Check whether you did it right
  • ls l or dir
  • (What result should be displayed?)

26
Get started
  • Then go back to parent directory
  • cd ..
  • Change the mode of public_html directory
  • chmod 755 public_html
  • ( Whats the meaning of this command?)
  • Check if you got the mode set right
  • ls dl public_html

27
Where to get help?
  • Come to see us during the office hours
  • The CGS3063 tutorial available on line (technical
    info)
  • man subject(s) the UNIX help command.
  • e.g. to get help info about mv command you can
    type man mv to get detailed manual of mv command.

28
Thank you and good luck!
Write a Comment
User Comments (0)
About PowerShow.com