D10: CLI, nvm/npm, Node.js, Git

devfish·2022년 12월 28일
0

git

목록 보기
1/2
post-thumbnail

Tips to share

  • drag folder into terminal to copy path
  • -lkhrt
    cat > file1 create new file, write content via command line, then close it out with ctrl+D
  • after installing, source ~/.zshrc - different shells (this is mac OS)
    • read & execute the file -- defines environment variables
    • e.g. PATH - whenever you run and executable (any command), the system will look up every directory inside this path until it finds the executable)
    • will reset as if you restarted the terminal without actually restarting
  • pull vs pull request
  • 외부 모듈 불러들이는 방법: require('파일 경로')
  • GIT workspace vs. index

Todos

Command Line Interface

Use Cases

  • When you need to edit files remotely, like in a remote server environment (AWS)

Essentials

  • pwd : print working directory (현재 작업 중 폴더 위치 출력)
  • cd : change directory
  • Relative paths:
    . : current(root) directory, .. : parent directory
    • cd .. : go to parent folder
    • cd ../../ : go to parent's parent folder
    • cd ./hi : go to hi folder, which is inside current folder
    • cd : home directory (user)
    • cd ~ : user directory
    • cd / : root directory - DO NOT USE
  • mkdir : make new directory
  • touch :make file
  • open . : open current directory in GUI
  • -h, --help : lists command help cp --help
  • ls : list folders inside current directory
  • ls -l : list detailed view of folders
  • ls -a : all, shows hidden files/folders starting with '.'
  • ls -al : combination of -a & -l
  • ls -la : same !
  • ls -lkh : by size (KB), list human-readable (h)
  • -rt : reverse time (sort by reverse modification time)
  • -lkhrt : list all by KB (human readable), sorted by time (reverse)
  • dash- : options. can appear later, the order doesn't matter

Edit commands

  • rm: removes files
    • does not go to trash, but deletes it permanently
  • rm -rf: removes folders
  • -rf : recursive force (r: for deleting folders, f: without questioning)
  • mv : move directory of folder mv bye.text bye
    - rename mv oldName newName
    • mv text.txt ../../
  • cp : copy & paste cp [원본 파일 이름] [복사할 파일 이름]
    • cp helloWorld.txt hiComputer.txt
    • cp -rf dir1 dir2

Permissions

  • whoami: username
  • sudo: temporarily use admin rights (root)
    • to edit anything outside of User folders, you need sudo
  • d로 시작: directory (폴더), - 로 시작: 파일
  • r: reading rights, w: writing rights, x: execution rights
    • first line: sung has reading/writing but no execution rights, any staff has only reading rights, other users who do not belong to the group staff have only reading rights
    • -drwxr-xr-x : sung has all rwx rights, staff has r & x, others have r& x
  • cat : concatenate
    • cat [options] [filenames] [-] [filenames]
    • cat file1 file2 file3 : show content of all these files
    • cat file(s) > file2 : combines files into (new) file
    • cat file1 >> file2 : appends file1 to the bottom of file2
    • cat > newfile : creates new file, then you can type in the content, close it by ctrl+D
    • cat file | more : displays content of the file one screen at a time
    • cat - file5 > file6 : creates new file6 with text typed in from the keyboard followed by file5 content
    • cat file7 - > file8 : creates new file8 with file7 content followed ty text typed in from the keyboard
    • useful options
      • -b: 줄번호를 화면 왼쪽에 나타낸다. 비어있는 행은 제외한다.
      • -e: 제어 문자를 ^ 형태로 출력하면서 각 행의 끝에 $를 추가한다.
      • -n: 줄번호를 화면 왼쪽에 나타낸다. 비어있는 행도 포함한다.
      • -s: 연속되는 2개이상의 빈 행을 한행으로 출력한다
      • -v: tab과 행 바꿈 문자를 제외한 제어 문자를 ^ 형태로 출력한다
      • -E: 행마다 끝에 $ 문자를 출력한다
      • -T: 탭(tab) 문자를 출력한다.
      • -A: -vET 옵션을 사용한 것과 같은 효과를 본다.

nano

texteditor inside terminal!

Linux packages

  • 여러 파일을 모아 하나의 파일로 저장하고 있는 압축 파일
  • 패키지 매니저의 유용성: 패키지의 관리를 편하게 해주는 도구 (업데이트, 각종 프로그램 설치) - 개별적으로 프로그램 설치, 업데이트, 어디에 있는지 기억해줄 필요가 없음
    • 특정 프로그램 설치 요청, 재다운로드, 업데이트 확인, 제거 등에 사용

brew

  • brew update, brew outdated : see which files need updating, brew upgrade 프로그램 이름, brew search 검색어, brew info 프로그램 이름, brew install 프로그램 이름, brew uninstall 프로그램 이름, brew list

wget

  • url를 통해 파일 다운로드 하는 프로그램 non-interactive network retriever
  • 예: wget -O goodjob.txt https://bit.ly/37sJqCo

neofetch

Node.js

웹 브라우저 말고도 javascript를 실행 가능하게 하는 환경 (javascript runtime environment)

  • nvm 설치 (node version manager)
  • nvm install --lts, node -v (lts: long term support)
    • nvm ls -> nvm install version# -> nvm use version#
  • npm - node package mgr. can download node-related modules with this
    • npm init -> creates package.json
    • npm init -y: instant creation without going through hoops
  • package.json:
    • 프로젝트 카탈로그 개념
      what modules are necessary/incl. etc to get the program working correctly
    • 프로젝트에 관한 정보, CLI에서 사용가능한 명령, 개발과 관련 dependency들
    • 이 프로그램을 실행시키기 위한 모듈 종류, 실행 방법, 테스트 방법 명시
    • 실제 모듈들은 node_modules 폴더에 저장됨
    • devDependencies: 개발환경에 필요한 모듈 (프로젝트 동작에 직접 영향 주지 않음)
    • dependencies: 프로젝트 동작에 반드시 필요한 모듈
      • npm install react npm install --save react: 자동으로 dependencies에 추가됨
      • npm install mocha --save-dev : 자동으로 devDependencies에 추가됨
    • scripts: CLI에서 사용가능한 명령 (npm script)
      • npm run scriptname

practice:

  • nano helloWorld.js -> node helloWorld.js (node로 자바스크립트 파일 실행)
  • 과제 시작 전 package.json 확인, npm install (all dependencies..)

Git

  • commit vs. push
  • fork vs. clone
  • https vs. ssh
  • Git으로 관리되는 파일: Github, GitLab, Bitbucket
  • 기본 개념 | git ready reference
  • git clone은 로칼 디렉토리로 한번 복사하는 행동이고, git pull는 그 로칼 복사본을 업데이트시키는 행위, 그니깐 그 원격디렉토리의 새로운 업데이트 다 반영하는 행위
  • If you use git pull, you pull the changes from the remote repository into yours. If you send a pull request to another repository, you ask their maintainers to pull your changes into theirs (you more or less ask them to use a git pull from your repository).

$ git config --global user.name "kimcoding"
$ git config --global user.email "kimcoding@example.com"
$ git config --global core.editor nano
ssh-keygen

range.range(a, b, c) --- range 라는 객체 안에 range 라는 함수

VS Code Shortcuts

Terminal in Code

  • Cmd + Shift + P : open terminal
  • Ctrl + Shift + N: run code runner
profile
la, di, lah

0개의 댓글