unix command line

12 282 0
unix command line

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

Thông tin tài liệu

Mastering the UNIX Command Line Howard Mao March 28, 2013 UNIX Created by Ken Thompson and Dennis Ritchie in 1970 Modern descendants include Linux, OSX, and BSD Looking up Information Man Pages: man Google is your friend Stackexchange Sites stackoverflow.com serverfault.com superuser.com unix.stackexchange.com Basic Filesystem Navigation look around - ls move about - cd, pushd, popd move, copy, delete - mv, cp, rm file info - stat, du, file changing permissions - chmod, chown More About Permissions Three types of permissions: read (r), write (w), execute (x) Three categories: user (u), group (g), other (o) Also represented by an octal number: read (4), write (2), execute (1) Add them together to get number One octal digit for each category Ex 644 means read + write for user, read only for group and other, execute for nobody Execute permission for directory means you can list files in directory Globbing Match everything * Choices {foo,bar,baz} Characters [abc] Numbers {0 5} The Almighty Find Find allows you to search for files By Name: find -name \*.txt By Type: find -type d By Timestamp: find -mtime And many many more Can also run commands on files find -name txt -exec rm {} \; I/O Redirection I/O Commands: echo, cat, less Input from File: command < input.txt Output to File: command > output.txt Pipes : command1 | command2 Filters Search lines with grep Find and Replace with sed Select columns with cut and awk Manipulating Processes Start in background: command & One after another: command1; command2 If successful, then: command1 && command2 If unsuccessful, then: command1 || command2 Suspend and resume: command +Z; [bg|fg] See running procs: ps, ps -au $USER, ps aux Networking Server info - ping, traceroute, host, whois Sending raw traffic - nc, telnet The World Wide Web - wget, curl What’s my address? - ip addr, ip link What ports are open - ss, nmap Who’s on the port - lsof Scripting Believe it or not, the shell is turing complete Variables : VAR=abc If statements : if [ "$VAR" ]; then echo $VAR; fi For loops : for i in {1 5}; echo $i; done While loops : while true; echo "forever"; done User input : read var; echo $var Functions : function func () { something }

Ngày đăng: 28/08/2016, 13:23

Từ khóa liên quan

Tài liệu cùng người dùng

Tài liệu liên quan