본문 바로가기
CodeStates/└ Ubuntu

Command Line 사용법

by Dream_World 2020. 6. 24.

파일 보기

@STUDY  /  ls
bin   cdrom  etc   initrd.img      lib    lost+found  mnt  proc  run   snap  sys  usr  vmlinuz
boot  dev    home  initrd.img.old  lib64  media       opt  root  sbin  srv   tmp  var  vmlinuz.old
 @STUDY  /  ls -al
합계 105
drwxr-xr-x  24 root root  4096  6월 24 08:53 .
drwxr-xr-x  24 root root  4096  6월 24 08:53 ..


ls        :  list directory contents
ls -al
-a, --all : do not ignore entries starting with .
-l        : use a long listing format
  
명령어 확인
ls --help

 

디렉토리로 이동

 @STUDY  /  cd ~
 @STUDY  ~  cd Downloads 
 @STUDY  ~/Downloads  pwd
 /home/j/Downloads
 @STUDY  ~/Downloads  cd ..
 @STUDY  ~  cd .

 ~          : 홈 디렉토리
 cd [파일명] : 원하는 파일 디렉토리 이동
 pwd        : 현재 디렉토리 확인
 cd ..      : 부모 디렉토리
 cd .       : 현재 디렉토리

 

파일 생성, 이동, 복사, 삭제

 @STUDY  ~  touch test.txt
 touch [파일 이름] : 빈 파일 생성
 
 @STUDY  ~  mkdir test
 mkdir [폴더 이름] : 빈 폴더 생성
 
 @STUDY  ~  vi test.txt
 vi : test.txt 편집 도구
 
 @STUDY  ~  cat test.txt 
 TEST "확인"
 cat : test.txt 내용 확인
 
 @STUDY  ~  mv test.txt tool.txt
 mv : 이동 명령어를 통하여 파일 이름 변경 tool.txt
  @STUDY  ~  ls
 Documents  Downloads  examples.desktop  git  snap  test  tool.txt
 ls 명령어를 통한 tool.txt 이름 변경 확인
 
 @STUDY  ~  mv tool.txt ./test 
 mv : 이동 명령어를 통하여 test 폴더로 이동
 @STUDY  ~  ls
 Documents  Downloads  examples.desktop  git  snap  test
 @STUDY  ~  cd test 
 @STUDY  ~/test  ls
 tool.txt
 tool.txt 파일이 test 폴더에 들어간 것을 확인
 
 @STUDY  ~/test  cp tool.txt ../
 cp : 복사 명령어를 이용하여 부모 디렉터리로 복사
 @STUDY  ~/test  cd ..  
 @STUDY  ~ ls
 Documents Downloads examples.desktop git snap test tool.txt
 tool.txt 부모디렉터리로 복사된 것을 확인
 
 @STUDY  ~  rm tool.txt
 rm : 삭제 명령어를 통하여 tool.txt 삭제
 @STUDY  ~ ls
 Documents Downloads examples.desktop git snap test vscode 
 tool.txt 삭제 된 것을 확인

 [명령어 정리]
 touch : 빈 파일 생성
 mkdir : 빈 디렉터리 생성
 vi    : 편집기 실행
 cat   : 파일 내용 확인
 mv    : 파일 이동, 덮어쓰기
 cp    : 파일 복사
 rm    : 삭제

 

관리자 권한으로 실행

@STUDY  ~  sudo cat /etc/passwd
root:x:0:0:root:/root:/bin/bash
daemon:x:1:1:daemon:/usr/sbin:/usr/sbin/nologin
bin:x:2:2:bin:/bin:/usr/sbin/nologin
sys:x:3:3:sys:/dev:/usr/sbin/nologin

sudo 명령어 : 관리자 권한
"superuser do”에서 유래하였으나, 후에 프로그램의 기능이 확장되며 
“substitute user do”(다른 사용자의 권한으로 실행)의 줄임말로 해석

위키백과 참조 : https://ko.wikipedia.org/wiki/Sudo

 

파일 소유권 변경

@STUDY  ~/test  ls -al
합계 12
drwxr-xr-x  2 j j 4096  6월 24 23:10 .
drwxr-xr-x 33 j j 4096  6월 24 23:32 ..
-rw-r--r--  1 j j   14  6월 24 23:09 tool.txt
@STUDY  ~/test  sudo chown root.root tool.txt 
@STUDY  ~/test  ls -al                       
합계 12
drwxr-xr-x  2 j j 4096  6월 24 23:10 .
drwxr-xr-x 33 j j 4096  6월 24 23:32 ..
-rw-r--r--  1 root        root          14  6월 24 23:09 tool.txt

파일 관리자 권한으로 소유권을 파일 관리자로 변경
sudo chown root.root [파일명]

 

GUI 프로그램 실행

@STUDY  ~/test  xdg-open .
@STUDY  ~/test  nautilus . 

xdg-open .		: 현재 디렉터리에서 실행
nautilus .		: 현재 디렉터리에서 실행
파일 탐색기 실행

'CodeStates > └ Ubuntu' 카테고리의 다른 글

oh-my-zsh 설치  (0) 2020.12.04
yarn 설치가 안될 때  (0) 2020.08.26
deb 파일 설치  (0) 2020.07.25
Ubuntu 18.04 Setup  (0) 2020.06.23

댓글