Skip to content

Latest commit

 

History

History
52 lines (43 loc) · 1.63 KB

T2.md

File metadata and controls

52 lines (43 loc) · 1.63 KB

CS T2

upload files with scp

  • if config SSH setup
    • scp <local-path-of-file> comp30023:
  • if not
    • scp -i <path-to-private-key> <local-path-of-file> <username>@<ip>:
  • download file
    • scp comp30023:<remote-path-of-file>
  • directories can be transferred using the -r flag
  • rsync to synchronise local and remote

basic

  • sell command: cd
  • coreutils commands: pwd, mkdir, rm, ls, cat
  • using man to read usage
  • $ signifies a user prompt, and # signifies a root

files

  • tar xf <filename> to extract files

  • cp a b (copy file a to b)

  • grep <search_pattern> <path-to-file> (to do a search)

  • line endings

if a file end without a line terminators, the next command will display directly
following the file:

haomfeng@comp30023-share-60:~/cli$ file welcome
welcome: ASCII text, with no line terminators

haomfeng@comp30023-share-60:~/cli$ cat welcome
welcome haomfeng@comp30023-share-60:~/cli$ cat welcome
  • change output
  • haomfeng@comp30023-share-60:~/cli$ cat welcome comp30023 > out1

  • or using tee

others

  • which to show the full path of (shell commands), which ssh
  • wc -l or nl to count the number of lines in a file
  • grep with regex, grep -E 'COMP|INFO|SWEN' subjects
  • uniq to hide repeated
    • -c to calculate occurring
  • cat subjects | cut -b 1-9
    • this code retrieves the first nine bytes of each line
    • the '|' connects the output of one command to the input of another. It allows chaining commands to process data step by step.
    • first cat subjects and pass the result to the cut -b 1-9 as target
    • grep COMP subjects | wc -l => the number of lines contain COMP