1 / 17

Midterm Review

Midterm Review. IT244 - Introduction to Linux / Unix Instructor: Bo Sheng. Basic Utilities. ls , cat, echo ls –l, ls -a cat file1 file2 file3 … echo “hello world” > file echo $VAR, echo hello*. Basic Utilities. more, less, head, tail head -5 file tail -3 file pwd , cd

Download Presentation

Midterm Review

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Midterm Review IT244 - Introduction to Linux / Unix Instructor: Bo Sheng

  2. Basic Utilities • ls, cat, echo • ls –l, ls -a • cat file1 file2 file3 … • echo “hello world” > file • echo $VAR, echo hello*

  3. Basic Utilities • more, less, head, tail • head -5 file • tail -3 file • pwd, cd • cp, mv, rm, mkdir, rmdir • ‘-i’ option • ‘-r’ option: rm –r dir1 • rmdiran empty directory

  4. Basic Utilities • sort, wc, grep, |(pipe) • wc -l file, wc –c file • grep “keyword” file, grep -v • sort linux | head -5 • bzip2, gzip, tar (no compression)

  5. Filename and Path • Hierarchical tree structure • Absolute path name • ls /home/it244/it244 • Relative path name • cd /home/it244 • ls it244 • ‘.’ ‘..’ ‘~’ • ‘*’ ‘?’ • echo hello*, echo ./.?a*

  6. Access Permissions • r, w, x (chmod) • chmoda+rw file • chmod a=rx file • chmod 644 file • Execute permission of a directory • A directory is a table of files (filename:meta) • Executable means searchable

  7. Access Permissions • Operations on book/book1 • ls book/book1 • book ( x ) • cat book/book1 • book1 ( r ), book ( x ) • rm book/book1 • book ( xw ), book1 ( w )

  8. Links • Hard link and soft link • Hard link cannot refer to a directory • Soft link can point to a nonexistent file $ ln -s hello hello.sl $ rm hello $ echo “new” > hello $ cat hello.sl new

  9. Execute Commands • Foreground and background jobs • command &, CTRL+Z • difference between a suspended job and a background job, PID • jobs, ps, kill, bg, fg • Group commands • (cmd1; cmd2; cmd3)

  10. Processes • PID and PPID • sleep 10& • ps -f

  11. Redirection • Standard input, output, error output • cat file1 file2 > out 2>err • cat file1 file2 &> out • cat file1 file2 > out 2>&1 • Redirected output will not be displayed on the screen.

  12. Variables • System variables • $PATH, $PWD, $HOME • User defined variables • VAR=hello • export VAR=hello • declare; declare -x

  13. Expansion/ Quote • Types • echo hello*; echo ~ • echo $VAR • echo $(pwd) • echo $((1+1)) • VAR=hello* • echo $VAR • Single quote suspends all expansions

  14. Alias • Short names (commands) • alias rm=‘rm –i’ • alias ll=‘ls –l’ • alias mypwd1=“echo pwd is $PWD” • alias mypwd2=‘echo pwd is $PWD’

  15. Questions • Assume there are 3 files: file1, file2, and file3. After executing the following commands, how many files are there and what are the contents? $ cp file1 file2 $ mv file2 file3 $ rm file2 • Assume there are two directories dir1 and dir2, and dir1 contains a subdirectory dir3, what’s the result of $ cp -r dir1 dir2

  16. Questions • In command line, the order of command name and arguments can be changed as long as there is no ambiguous interpretation. We tried an example in class: ‘echo hello world > hello world’ generated a file ‘hello’ which contains ‘hello world world’. Now, if we execute “> echo echoecho” 1). What is the output: • Display “echo echo” • Create a file “echo echo” • Create a file “echo” which contains a line of “echo” • An error message of “command not found” 2). Which echo is the command name: a. The 1st b. The 2nd c. The 3rd

  17. Questions • Which of the following commands displays the value of the present working directory: • $pwd • echo pwd • echo $(pwd) • pwd | echo

More Related