*nix - basic commands


/ Published in: Bash
Save to your folder(s)

some basic *nix terminal commands


Copy this code and paste it in your HTML
  1. # For more details on a command see the man page for the command. For example, to see more information about the command rm, enter the command
  2. man rm
  3.  
  4.  
  5. # To display a list of commands related to a topic enter
  6. man -k topic
  7. # or
  8. apropos topic
  9.  
  10. # Remember: UNIX COMMANDS ARE CASE SENSITIVE!
  11.  
  12. # |||||||||||| ACCOUNT |||||||||||||||||
  13.  
  14. passwd # ... set a new password for your account
  15. assets # ... view information on resource use by your account, including connectivity time, cpu use, and disk space. (Availableon C&C systems only.)
  16.  
  17.  
  18. # ||||||||||||| DIRECTORIES ||||||||||||||||||
  19.  
  20. # DO: TO:
  21. # --------------- ---------------------------------------------
  22. pwd # ... find out what your current working directory is
  23. mkdir playdir # ... create a new subdirectory called 'playdir'
  24. rmdir junkdir # ... remove subdirectory 'junkdir' (must be empty of files and subdirectories)
  25. cd /usr/bin # ... change to '/usr/bin' directory
  26. cd .. # ... change to directory one level above current working directory
  27. cd # ... change to home directory for the account you are using
  28. du # ... display the number of disk blocks in use (the total combined size of all files) in each directory and subdirectory.
  29.  
  30.  
  31. # |||||||||||||||| FILES |||||||||||||||||||
  32.  
  33. # DO: TO:
  34. # --------------- ---------------------------------------------
  35. ls # ... list files in the current working directory
  36. ls notes # ... list file in the subdirectory named 'notes'
  37. ls -l # ... list all files in the current working directory, along with each file's permission, owner, size in bytes and date of last modification.
  38. ls -a # ... list files in the current working directory, including dot files (those files with names beginning with a period)
  39. ls -F # ... list files in the current working directory, indicating executable files with an asterisk (*) and subdirectories with a /
  40. find docs -name \\*\.memo -print # ... list all files in the directory 'docs' and any subdirectories of 'docs' with filenames ending in '.memo'. The \ is necessary before the * to insure that is is interpreted as a wild character.
  41. cp file1 file2 # ... copy the file 'file1' to a file named 'file2' (original file remains intact with the same name)
  42. mv oldf newf # ... move the file 'oldfile' to a file named 'newfile' (equivalent to renaming a file)
  43. rm badfile # ... remove the file 'badfile' (the file is permanently removed and cannot be recovered)
  44. rm -i *.c # ... remove all files in the current directory with the suffix '.c' and be asked for confirmation on each file
  45. chmod a+r resul # ... grant read access of the file 'resul' to all users
  46. cat shortfile # ... display the file 'shortfile'
  47. more longfile # ... display the file 'longfile', a screenful at a time
  48. head big # ... display the first ten lines of file 'big'
  49. head -25 big # ... display the first 25 lines of file 'big'
  50. tail big # ... display the last ten lines of file 'big'
  51. tail -25 big # ... display the last 25 lines of file 'big'
  52. grep done tasks # ... display all lines within file 'tasks' containing the string 'done'
  53.  
  54.  
  55.  
  56. # |||||||||||||||||||| JOBS ||||||||||||||||||||||
  57.  
  58. # DO: TO:
  59. # --------------- ---------------------------------------------
  60. ps # ... list the status of your jobs by process identifier (PID)
  61. ps -aux # ... list the status of all jobs by process identifier (PID)
  62. jobs # ... list the status of all jobs by job number
  63. z # ... suspend the job currently running in the foreground
  64. bg # ... resume the most recently suspended job into the background
  65. bg %2 # ... resume job number 2 in the background
  66. fg %2 # ... resume job number 2 in the foreground
  67. fg %3 # ... bring job number 3, which is running in the background, into the foreground
  68. kill %2 # ... kill job number 2
  69. kill 1234 # ... kill job with PID 1234
  70.  
  71.  
  72.  
  73. # ||||||||||||||||||||| NETWORKING |||||||||||||||||||||
  74.  
  75. # DO: TO:
  76. # --------------- ---------------------------------------------
  77. ssh becker.u # ... establish an interactive session on computer 'becker'
  78.  
  79. ftp sun.latin.washington.edu # ... transfer a file to or from computer 'sun.latin.washington.edu'
  80.  
  81.  
  82.  
  83. # |||||||||||| COMMS WITH OTHERS |||||||||||
  84.  
  85. # DO: TO:
  86. # --------------- ---------------------------------------------
  87. who # ... find out who is logged on to the computer
  88. w # ... find out who is logged on to the computer and what they are doing
  89. finger suzz # ... display information about user 'suzz'
  90. biff y # ... be notified if mail arrives. To turn off notification, enter the command 'biff n'
  91. pine # ... start pine mailer. Pine is an alternative to 'mail' that many people find easier to use than 'mail'
  92.  
  93.  
  94.  
  95.  
  96. # ||||||||||||||| MISC ||||||||||||||||||
  97.  
  98. # DO: TO:
  99. # --------------- ---------------------------------------------
  100. cal 6 1990 # ... display a calendar of June, 1990.
  101. date # ... display current date and time
  102. script # ... start recording of all screen interactions
  103. exit # ... stop script recording (text from recorded session will be in a file named typescript )
  104. alias dir ls -Fal # ... alias 'dir' to represent the command 'ls -Fal'
  105. unalias dir # ... remove the alias for 'dir'
  106. alias # ... show all current aliases
  107.  
  108.  
  109.  
  110. # |||||||||||| CONTROL CODES (USED WHEN AT UNIX COMMAND LINE) ||||||||||||
  111.  
  112. # DO: TO:
  113. # --------------- ---------------------------------------------
  114. u # Delete entire line
  115. w # Delete the preceding word
  116. h # Delete the preceding character
  117. c # Abort the program currently running
  118. z # Suspend the program currently running (use fg or bg to resume the program in the foreground or background, respectively)
  119.  
  120. # Redirecting and Piping
  121.  
  122. cc myprog.c > listing # ... run C compiler on 'myprog.c' source file, redirecting compilation messages to a file named 'listing'. The resulting file would NOT include any diagnostic messages.
  123. cc myprog.c >& listing # ... run C compiler on 'myprog.c' source file, redirect compilation messages, including diagnostic messages, into a file named 'listing'.
  124. ps -aux | more # ... list all current jobs on the system, piping the result to more for viewing one screen at a time
  125. cat frog >> rat # ... concatenate the contents of file 'frog' onto the end of file 'rat'

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.