UNIX 101 - PowerPoint PPT Presentation

1 / 18
About This Presentation
Title:

UNIX 101

Description:

directory -v verbose -b makes backups -f force renaming -i prompts to overwrite. Examples: ... files recursively -R copies directories recursively. Examples: ... – PowerPoint PPT presentation

Number of Views:76
Avg rating:3.0/5.0
Slides: 19
Provided by: RLo17
Category:
Tags: unix | directories

less

Transcript and Presenter's Notes

Title: UNIX 101


1
UNIX 101
  • CS372 Operating Systems
  • TA Roberto E. Lopez-Herrejon
  • Spring 2002

2
ls
  • List the contents of the file directories
  • Syntax
  • ls options files/patterns
  • -l long format -a all the files
  • -f sorts by name -r sorts reverse order
  • -R lists dirs recursively
  • Examples
  • ls -l names2
  • ls -f this.cpp

3
find
  • Search for files in a file system
  • Syntax
  • find path expression
  • path where the search is done
    for expression
  • -name fname search for files that match
    fname expression
  • -print send output to
    standard out
  • -type file_type search for files of
    file_type
  • f - file, d - directory, l -
    link
  • Example
  • find ./CS372/ -name "Example.cpp" print

4
cat
  • Concatenate files and print on standard output
  • Syntax
  • cat options files
  • -n numbers the output lines
  • Examples
  • cat -n file1 file2
  • cat file1 file2 gt file3

5
tail
  • Output the last part of a file
  • Syntax
  • tail - number lbcr file
  • -l lines -b blocks
  • -c bytes -r reverse
  • Examples
  • tail -10l README last 10 lines of file
    README
  • tail 55l README last lines from 55th line

6
head
  • Displays the first few lines of files
  • Syntax
  • head -n number filename
  • head number filename
  • Examples
  • head -10 README
  • head -n 10 README

7
mv
  • Renames files
  • Syntax
  • mv options source dest
  • mv options source... directory
  • -v verbose -b makes backups
  • -f force renaming -i prompts to overwrite
  • Examples
  • mv oldname newname
  • mv -f files ./mydirect/

8
cp
  • Copy files
  • Syntax
  • cp options source dest
  • cp options source... directory
  • -b makes backups -f forces copying
  • -r copies files recursively -R copies
    directories recursively
  • Examples
  • cp -R directory1 directory2
  • cp -f .cpp ./Project1/

9
rm
  • Remove files
  • Syntax
  • rm -dfirvR path...
  • -f forces removing -i interactive -v
    verbose
  • -r or -R removes directories recursively
  • Examples
  • rm -i .cpp
  • rm -R directory1

10
rmdir
  • Remove empty directories
  • Syntax
  • rmdir -p dir...
  • -p remove parent directories if directory
    becomes empty
  • Examples
  • rmdir directory1

11
mdkir
  • Make directories
  • Syntax
  • mkdir -p dir...
  • -p makes sure the path exists
  • Examples
  • mkdir directory1
  • mkdir -p /full/path directory2

12
cmp
  • Compare two files
  • Syntax
  • cmp -cls file1 file2
  • -c prints differing characters -l vebose
    (line number)
  • -s silence
  • Output 0 - identical, 1 - differ, 2 - error
  • Examples
  • cmp -c myfile1 myfile2

13
diff
  • Display line-by-line differences between files
  • Syntax
  • diff options filename1 filename2
  • diff options directory1 directory2
  • -a treat files as text
  • -B ignore blank spaces differences
  • -H uses heuristics for search
  • Examples
  • diff -a file1 file2
  • diff -B file1 file2

14
chmod
  • Change the access permissions of files
  • Syntax
  • chmod -Rcfv mode file...
  • -R recursive changes -f silent
  • -c verbose output of files changed -v verbose
    output
  • mode symbolic representation (r,w,x,-,) or
    octal number for
  • the new permissions
  • Examples
  • chmod 700 file1
  • chmod x file2

15
ps
  • Report process status
  • Syntax
  • ps options
  • -a list all processes -l long listing of
    processes
  • -e list running processes
  • Examples
  • ps -a
  • PID PPID PGID WINPID TTY UID
    STIME COMMAND
  • 652 1 652 652 con
    1003 102033 /usr/bin/bash

16
kill
  • Send a signal to a process
  • Syntax
  • kill -signalnumber processid
  • Examples
  • kill -9 12312 sure kill
  • kill -15 12342 default signal

17
turnin
  • To submit your project, execute on a CS Unix
    machine
  • /p/bin/turnin -submit rlopez cs372 ltfilegt
  • To check your submissions
  • /p/bin/turnin -list rlopez cs372

18
References
  • Paul W. Abrahams, Bruce R. Larson
  • Unix for the impatient, 2nd ed.
  • Addison-Wesley, 1996
  • http//www.cs.utexas.edu/users/UTCS/online-docs/
    cluesheets/
Write a Comment
User Comments (0)
About PowerShow.com