[생활코딩] Linux - File & Directory

Ian Choi·2022년 3월 4일
0

TIL

목록 보기
2/6

TIL

📌 준비과정

클라우드 엔지니어가 되기 위해서 공부를 시작했다.

어디서부터 공부해야 할지 찾아봤는데 인프라의 기본인 리눅스를 공부하기로 결정했다.

Virtualbox 로 리눅스 환경 구축하기에는 귀찮아서 AWS에서 서비스하고 있는 Cloud9을 이용하기로 했다.

https://aws.amazon.com/ko/cloud9/

AWS에 처음 가입하면 프리 티어 사용자로 등록해서 12개월간 무료로 사용할 수 있다.

📌 본문

리눅스는 문자를 입력해서 제어를 한다 -> CLI 환경 (Command Line Interface)

CLI 환경에서는 현재 작업하고 있는 디렉토리를 알고 있는 것이 매우 중요하다.

pwd 명령어를 통해서 현재 디렉토리를 확인할 수 있다.

ec2-user:~/environment $ pwd
/home/ec2-user/environment

mkdir 명령어를 통해서 새로운 디렉토리를 만들 수 있다.

ec2-user:~/environment $ mkdir hello_linux
ec2-user:~/environment $ ls
hello_linux  README.md

ls 명령어에 -l 파라미터를 붙히면 파일의 리스트를 자세하게 보여준다.

ec2-user:~/environment $ ls -l
total 4
drwxrwxr-x 2 ec2-user ec2-user   6 Mar  4 10:32 hello_linux
-rw-rw-r-- 1 ec2-user ec2-user   0 Mar  4 10:33 new_file.txt
-rw-r--r-- 1 ec2-user ec2-user 569 Feb 15 03:57 README.md

cd 명령어를 통해서 원하는 디렉토리로 이동할 수 있다.

상대경로를 이용해서 이동
ec2-user:~/environment $ cd hello_linux/
ec2-user:~/environment/hello_linux $ pwd
/home/ec2-user/environment/hello_linux

절대경로를 이용해서 이동
ec2-user:~/environment/hello_linux $ cd /home/ec2-user/environment/
ec2-user:~/environment $ pwd
/home/ec2-user/environment

상위 디렉토리로 이동
ec2-user:~/environment/hello_linux $ cd ..
ec2-user:~/environment $ pwd
/home/ec2-user/environment

최상위 디렉토리로 이동
ec2-user:~/environment/hello_linux $ cd /
ec2-user:/ $ ls
"  bin  boot  dev  etc  home  lib  lib64  local  media  mnt  opt  proc  root  run  sbin  srv  sys  tmp  usr  var

rm 명령어를 통해서 파일을 삭제할 수 있다.

ec2-user:~/environment $ rm new_file.txt 
ec2-user:~/environment $ ls
hello_linux  README.md

-r 파라미터를 이용해 디렉토리를 삭제할 수 있다.
ec2-user:~/environment $ rm -r hello_linux/
ec2-user:~/environment $ ls
README.md

리눅스에는 이처럼 다양한 명령어가 있어서 기억하기 힘들다.

그럴 때는 --help 파라미터를 붙히면 도움말이 뜬다.

ec2-user:~/environment $ rm --help
도움말은 너무 길어서 생략
profile
신입 시스템 엔지니어

0개의 댓글

관련 채용 정보