Learning UNIX - PowerPoint PPT Presentation

1 / 24
About This Presentation
Title:

Learning UNIX

Description:

Introduction to UNIX. Text Editor - NANO. Basic Commands. File Manipulation. Permissions ... Devices in UNIX are stored as... Commands in UNIX are case ... – PowerPoint PPT presentation

Number of Views:45
Avg rating:3.0/5.0
Slides: 25
Provided by: rich596
Category:
Tags: unix | commands | learning | unix

less

Transcript and Presenter's Notes

Title: Learning UNIX


1
Learning UNIX
  • CSWUG 2007
  • Richard Clark
  • Collaboratory for Advanced Computing
    Simulations
  • Department of Physics Astronomy
  • University of Southern California
  • Email richarac_at_usc.edu

2
Outline
  • Introduction to UNIX
  • Text Editor - NANO
  • Basic Commands
  • File Manipulation
  • Permissions
  • Processes
  • Important Utilities
  • Running a Program
  • Remote Login Procedures

3
Introduction to UNIX
  • What is UNIX?
  • UNIX is an operating system (OS) and
  • set of related utility programs
  • It is the manager of everything going on in your
    computer
  • Advantages of UNIX
  • Many Users can use the same computer at the same
    time
  • Can run many different things simultaneously

4
How Things Work in UNIX
  • A Few Terms to Know
  • Shell
  • The program you use to interact with the
    computer
  • File
  • Stored info and all your devices (like disk
    drives and printers)
  • Processes
  • All Programs that running
  • Rules for Names
  • Case Sensitive (ie. Happy.txt is different than
    happy.txt)
  • Extensions Irrelevant (for now)

5
Using the Shell
  • Login Procedure
  • login
  • password
  • Changing your Password
  • After logged in, type
  • passwd
  • (you will type in the old password once, and the
    new one twice)

6
Using Text Editor - NANO
  • Start with
  • nano - to start the editor with a new file
  • nano filename - to start editing filename
  • (creates if doesnt exist)
  • The commands are listed at the bottom of the
    window
  • Delete character d Ctrl-d
  • Save o Ctrl-o
  • Exit x Ctrl-x (also saves if desired)

7
Exercise Writing Files
  • Type nano and create a file called - unix.notes
  • Include in it answers to the following
  • A Shell is
  • A Process is
  • Devices in UNIX are stored as
  • Commands in UNIX are case-sensitive (T/F)
  • Save your file.

8
Format of Commands
  • General Format of Commands
  • The command line cswug_at_machine1 cswug
  • The command structure
  • command options arguments
  • Can have multiple options (-l -a) and arguments
    (file1.txt file2.txt), etc

9
Dealing with Files
  • ls - lists files
  • ls
  • ls -a (lists all hidden system files too)
  • mv - moves (and renames) file
  • mv oldfile newfile
  • cp - copies (renames) file
  • cp oldfile newfile
  • rm - deletes a file
  • rm oldfile

10
Exercise Files
  • Make 2 copies of your unix.notes with cp (call
    the copies unix2.notes and unix3.notes)
  • Rename the unix2.notes to unix4.notes with mv
  • Make sure you have 3 files with ls
  • Remove the unix4.notes copy with rm
  • Update your notes (in unix.notes)

11
Better Search Tactics
  • Wild Cards ? and and
  • Wild cards allow search for range of files
  • ? any 1 character here
  • file?.txt - selects file1.txt, but not
    file11.txt
  • any of characters
  • file.txt - selects file1.txt and file11.txt
  • allows selection of certain characters
  • file1-3.txt - selects file1.txt, file2.txt,
    file3.txt only

12
File Contents
  • less - displays file contents
  • less file1
  • head - displays first 10 lines of file
  • head file1
  • tail - displays last 10 lines of file
  • tail file1
  • grep - search file for given pattern
  • grep pattern file1
  • diff - compares 2 files and tells if different
  • diff file1 file2

13
Other Commands
  • man - short manual on command
  • man command
  • learn - tutorial on how to use certain topics
  • learn
  • df - shows how much disk space is used
  • df
  • date - shows current date and time
  • date
  • shutdown -shuts machine down
  • shutdown

14
Intro to Directories
  • Above is the tree structure
  • relative vs absolute pathway
  • Special Directories
  • / the root directory . the current
    directory
  • the home directory .. the parent directory

15
Using Directories
  • cd - changes directories
  • cd directoryname
  • pwd - display current path
  • pwd
  • mkdir - make new directory
  • mkdir newdirectory
  • rmdir - delete directory (requires that dir is
    empty)
  • rmdir olddirectory

16
Exercise Directories
  • Check current path with pwd
  • Make a new directory with mkdir called unix/
  • Change into that directory (cd) and make another
    directory called notes/
  • Delete the notes/ directory with rmdir
  • Go back to home directory with cd or cd ..
  • Move (mv) your unix.notes from here to your new
    folder unix/

17
Permissions and Other Users
  • Permissions describe who is allowed to read,
    write, or use your files.
  • To check permissions of files in your directory,
    type
  • ls l -displays permissions to all files in
    directory
  • ls l file1 -displays permission to file1
  • Results in form
  • d-rwx-rwx-rwx owner size updated
    filename
  • The first rwx is the permission for the owner
  • the next is for those in your group
  • the last is permission for everyone else
  • Each rwx read write execute permissions
  • If one of three is a -, then that user does not
    have permission to do that action

18
Changing Permissions
  • Chmod -changes the permissions on a file
  • chmod options who operationpermission
    file-list
  • who u (user), g (group), o (other), a (all)
  • operation (add permission), - (take away),
    (set)
  • permission r (read), w (write), x (execute)
  • Examples
  • chmod a r file1 - gives the read option
    to everyone for file1
  • chmod g -wx file2 -takes away the write and
    execute options
  • from group on file2
  • chown -changes owner of a file
  • chown newowner file

19
User Accounts
  • su -switch user (or super-user)
  • su newperson
  • useradd -adds new user
  • useradd newperson
  • userdel -deletes user account
  • userdel oldaccount

20
Processes
  • top - lists processes currently running (and get
    IDs)
  • top
  • (type q to get out of listing)
  • ps - lists status of a process
  • ps idnumber
  • kill - kills a process
  • kill idnumber
  • killall - kills all processes
  • killall

21
Important Utilities
  • gzip - zips a number of files (adds gz to
    extension)
  • gzip file1
  • gunzip - unzips a file
  • gunzip file1.gz
  • tar - clumps all files into archive
  • tar -cvf archivename filelist -creates an
    archive
  • tar -xvf archivename -extracts files from
    archive

22
Running Programs
  • Compiling a Program
  • Note For the compiler, the extension (.c or
    .f90) DOES matter!
  • gcc - C compiler
  • gcc mainfile.c
  • ifort - Fortran compiler
  • ifort file.f90
  • (The default name of a created program is
    a.out)
  • Executing a Program
  • ./ - Runs a compiled program
  • ./a.out

23
Remote Login
  • To login and work on a remote computer
  • ssh - secure shell program
  • ssh user_at_host
  • -opens a shell (interface) to the other
    computer. Use this shell just as you would your
    first computer. Type exit to close the
    connection.
  • To copy a file to a remote computer
  • scp - secure copy program
  • scp file user_at_host path
  • scp file1 myname_at_cswug1.usc.edu
    /somedirectory/

24
Thanks!
  • References
  • Sobell, Mark G. A Practical Guide to Unix System
    V - 2nd ed.
  • Nomura, Ken-ichi. Tutorial of UNIX/LINUX _at_
    CSWUG 2004
  • Sharma, Ashish. General Reference

Questions?
Write a Comment
User Comments (0)
About PowerShow.com