tianwainanfeng的个人博客分享 http://blog.sciencenet.cn/u/tianwainanfeng

博文

Unix/Mac Terminal Commands常用

已有 1891 次阅读 2015-6-17 10:45 |个人分类:Programming|系统分类:科研笔记| 常用, Mac, UNIX, 终端

1. rm filename:  remove a file

2. date: displays the current date and time

3. who: displays a list of each logged-on user’s username, terminal number and login time

4. who am i: tells you who is logged in at your terminal

5. up-arrow key on the keyboard: gives the previous command line

6. CTRL-C: cancel the command line

7. CTRL-U: erases the whole input line

8. exit: logout

9. logout: logout

10. CTRL-D: logout

11. sort -o sorted -n sortme: sort reads the file sortme, and writes to the file sorted

12. ls: displays a list of files

13. ls -l: displays an entire line of information for each file

14. ls -a: list all files including hidden files

15. ls -al  =  ls -a -l  : multiple options

16. pwd: print current working directory

17. cd: change direcotory

18. less: read a file (less filename: the first “page” of the file appears.  -M: show the filename and position in the file.  -q: quit less; -h: help; -b,-w,-z,-y forward/backward a line/ a window)

19. chmod: set permissions  (chmod u=rwx,go=rx filename:  three category: u-user, g-group, o-other; three permissions: r-read, w-write, x-execute; add permission: (+); delete permission:(-); specify permission:(=))

20. TAB key: complete file or directory names

21. passwd: change password

22. file name with space: “a confusing name”  (rm “a confusing name”)

23. wildcards:

   * an asterisk stands for any number of characters in a filename: ae* would match aegis, gerie, geon, etc.

   ? a question mark stands for any single character: h?p matches hop or hip, etc

   [] square brackets can surround a choice of single characters:[Cc]hapter would match either Chapter or chapter,  [ch]apter would match captor or hapter; chap[1-3] would match chap1, chap2 or chap3

24. Text Editor:

   CTRL-F: move forward a charter

   CTRL-E: move to the end of a line

   CTRL-A: go to the start of a line

25. mkdir: create a directory  (mkdir hello world: create two directories named hello and world)

   

26. cp: copy a file (cp old new: example, cp /etc/passwd password: copy the /etc/passwd file into a file called password in your working directory)

27. mv: move a file from one directory to another or rename a file

28. find: find a file (find . -type f -name “cha*” -print : find files with name starting with cha)

29. rmdir: remove a directory (if the directory is empty)

30. rm -r: remove a directory and everything in it

31. cd .. : go to the parent directory

32. CTRL+command: insert special characters

33. cat: short for “concatenate”, reads files and outputs their contents one after another, without stopping. (cat file > new: the file contents are diverted into another file called new)

34. cat > filename: create a text file and write something thing in it (use CTRL-D to end the text)

35. cat file1 file2 > new file: create a bigger file from smaller files

36. > filename: the output is diverted from the standard output(output on terminal screen) to the named file

37. >> filename: add more text to the end of an existing file, instead of replacing its contents

38. pipe: connect two or more programs so that the output from one program becomes the input of the next program (to make a pipe, put a vertical bar (|) on the command line between two commands)

39. grep: searches a file or files for lines that have a certain pattern, g/re/p, ”globally search for a regular expression and print all lines containing it” (grep “pattern” file(s), example, grep “pattern” *: grep all filenames in the directory)

40. some grep options:

  -v: print all lines that do not match pattern

  -n: print the matched line and its line number

  -l: print only the names of files with matching lines(lowercase letter “L”)

  -c: print only the count of matching lines

  -i: match either upper- or lowercase

41. sort: arranges lines of text alphabetically or numerically. sort doesn’t modify the file itself; it reads the file and writes the sorted text to the standard output

42. some sort options:

   -n: sort numerically(example: 10 sorts after 2), ignore blanks and tabs

   -r: reverse the sorting order

   -f: sort upper0 and lowercase together

43. Remote login: typical programs for connecting over a computer network are telnet, ssh(“secure shell”), rsh(“remote shell”) or rlogin (“remote login”)

44. ftp: file transfer protocol, is a standard way to transfer files between two computers. (ftp hostname: start ftp)(build a web…)

45. talk: interactive chat(it hasn’t been tested)

46.(Multitasking) Running a command in the background: to run a program in the background, add the “&” character at the end of the command line before you press the “return” key. The shell then assigns and displays a process ID number for the program. ps: check the status

47. kill: cancel a process(kill PID(s))  PID: process ID  (kill -9 PID: a sure kill and can destroy almost anything, be careful)

48. man: Manual

49.  info: to document system programs

50. 解压tar: tar -xvf filename.tar (实际中,可能直接为tar -xvf filename)



https://blog.sciencenet.cn/blog-692375-898597.html

上一篇:美不胜收(13)
下一篇:美不胜收(14)
收藏 IP: 131.225.23.*| 热度|

1 icgwang

该博文允许注册用户评论 请点击登录 评论 (0 个评论)

数据加载中...

Archiver|手机版|科学网 ( 京ICP备07017567号-12 )

GMT+8, 2024-9-27 21:26

Powered by ScienceNet.cn

Copyright © 2007- 中国科学报社

返回顶部