Lesson Working with Unix

13 36 0
Lesson Working with Unix

Đ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

Lesson Working with Unix present the content: Unix command syntax, each Unix command has a defined syntax; special characters, basic commands; the following tables list some of the available Unix commands with their usage and examples.

Working with Unix Working With Unix Unix Command Syntax Unix Overview Unix Command Syntax Each Unix command has a defined syntax: • Abbreviated spelling • Required elements Most Unix commands have options: • The long (-l) or all (-a) used by ls Unix Command Syntax There are methods to research the syntax of Unix commands too see a complete list of requirements and options • Use the man command and browse the Man Help Pages -> man Unix Overview Unix Command Syntax • Type in the command name at the Unix prompt and hit enter -> • Use a Google search -> Unix command Unix Command Syntax • Use the man command Unix Overview Unix Command Syntax • type command at prompt Unix Command Syntax Use a Google search Unix Overview Unix Command Syntax Results of Google search Working With Unix Special Characters Unix Overview Special Characters In Unix, special characters such as input or output redirection, regular expressions (such as wildcards and delimiters), and other special pattern-matching characters have a special meaning Special Characters Unix special characters might not work in every Unix shell or might have different options in different shells Simply try the special character and see if it works in the current shell Unix Overview Special Characters Special Characters Explanation * Matches any set of characters ? Matches a single character - Often used to prefix a parameter / Directory marker and root directory \ Line continuation or other escapes The current directory < or > Redirect Input or Output | Pipe output & Run command in background $ Prefix for environment variable Special Characters * Command – match all characters • ls t* -> list all files starting with letter t ? Command – match character • ls prog?.cob -> list all 5-character prog cob files Unix Overview Special Characters < Command – redirect input • runproc < data_in -> get input data from data_in not keyboard > Command – redirect output • runproc > data_out -> print output to file data_out not monitor Special Characters | Command – pipe redirection • command1 | command2 -> use the output from command1 as input to command2 & Command – run command in background • command1 & Unix Overview Working With Unix Basic Commands Basic Commands The following tables list some of the available Unix commands with their usage and examples Unix Overview Basic Commands File Commands cat Usage: Display a files contents to the screen Example: cat myfile -> list file on screen chgrp Usage: Change group ownership of a file Example: chgrp newgroup filename chmod Usage: Change permissions of a file Example: chmod 777 myfile -> use octal chmod rwxr r myfile -> use permissions chmod u=rwx,g=r,o=r -> use each group chmod a=rwx -> use all group cp Usage: Copy files Example: cp oldfile newfile Basic Commands File Commands Unix Overview cd Usage: Change directories Example: cd -> go to home directory cd -> go back directory cd /…./ -> change directory path ls Usage: List directory contents Example: ls -> list file names ls –a -> list all files ls –l -> list file attributes ls –r -> reverse order ls –t -> based on modification ls –alrt -> combination 10 Basic Commands File Commands mkdir Usage: Create a directory Example: mkdir newdir mv Usage: Rename file Example: mv oldfile newfile -> renames to newfile pwd Usage: Print working directory Example: pwd rm Usage: Remove a file Example: rm oldfile rmdir Usage: Remove a directory Example: rmdir touch Usage: Create an empty file Example: touch newfile Basic Commands Process Commands Unix Overview ps Usage: Show processes and their PID Example: ps -> show my processe ps –ef -> show all processes kill Usage: Send signal to process Example: kill -20 -> suspend process kill -9 -> stop process & Usage: Run command in background Example: command1 & z Usage: Suspend a running process to regain the Unix prompt d Usage: End of input Usage: Alternate way to logout 11 Basic Commands Miscellaneous Commands clear Usage: Clear screen Example: clear df Usage: Display disk information Example: df diff Usage: Display file differences Example: diff myfile yourfile exit Usage: End Unix session Example: exit find Usage: find a file name – start in this directory and find a file named “myfile” and print the path to it Example: find –name “myfile” -print finger Usage: Check for active users or user existence Example: finger finger accountName Basic Commands Miscellaneous Commands Unix Overview grep gzip Usage: find specified text in files gunzip Usage: Restore compressed files history Usage: Display list of commands Example: history man Usage: Invokes Man Help Pages Example: man cp more Usage: Display first page of file to screen and the use to display more c return to prompt Example: more myfile Usage: Compress a set of files Compressed file extension tar.gz 12 Basic Commands Commands Unix Overview passwd Usage: changes password – follow prompts Example: passwd w Usage: Gives summary of users Example: w wc Usage: Counts number of lines, words, bytes Example: cat myfile | wc -> lines, bytes, words who | wc –l -> number users ps –e | wc –l -> number of processes who Usage: Displays list of active users Example: who whoami Usage: Displays logon ID Example: whoami 13 ... at prompt Unix Command Syntax Use a Google search Unix Overview Unix Command Syntax Results of Google search Working With Unix Special Characters Unix Overview Special Characters In Unix, special... background • command1 & Unix Overview Working With Unix Basic Commands Basic Commands The following tables list some of the available Unix commands with their usage and examples Unix Overview Basic... command name at the Unix prompt and hit enter -> • Use a Google search -> Unix command Unix Command Syntax • Use the man command Unix Overview Unix Command Syntax

Ngày đăng: 06/08/2020, 04:52

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

  • Đang cập nhật ...

Tài liệu liên quan