programming language/리눅스

1. 기본 명령어 공부

공대키메라 2021. 7. 4. 15:10

ls : 내 디렉토리에 어떤 파일이 있는지 보여줌 - 감춰진 파일은 안보여줌

 

 예시 )

ec2-user:~/environment $ ls
empty_file.txt  hellolinus  README.md  test.py

 

ls -l : 내 디렉토리에 어떤 파일이 있는지 좀 더 자세하게 보여줌

ls -a : . 붙은 파일들까지 다 보여줌

ls -al : -l 하고 -a 짬뽕

ls -alS : 모든 파일들을 크기순으로 나열해서 보여줌

 

 예시)

ec2-user:~/environment $ ls -l
 total 8
   -rw-rw-r-- 1 ec2-user ec2-user   0 Jul  4 05:36 empty_file.txt
   drwxrwxr-x 2 ec2-user ec2-user   6 Jul  4 05:35 hellolinus
   -rw-r--r-- 1 ec2-user ec2-user 569 Jun 29 02:40 README.md
   -rw-r--r-- 1 ec2-user ec2-user  17 Jul  3 13:14 test.py

 

 => 맨 앞에 d가 붙어있으면 디렉토리라는 말이고

  그렇지 않은 것들은 파일이라는 뜻임

 

pwd : 내가 현재 위치한 경로를 보여줌

mkdir (디렉토리명): m(a)k(e) dir(ectory) -> 디렉토리를 생성

mkdir -p (디렉토리명) : 디렉토리에 해당하는 모든 부모 디렉토리도 함께 생성

예시)

ec2-user:~/environment $ mkdir -p dir1/dir2/dir3/dir4
ec2-user:~/environment $ cd dir1
ec2-user:~/environment/dir1 $ cd dir2

 

 

cd : change directory -> 경로를 변경

 

예시)

 cd hellolinux

 

cd .. :  현재 디렉토리의 부모 디렉토리로 이동

 

rm : r(e)m(ove) -> 디렉토리 삭제

리눅스는 실패하면 메시지를 띄워주고 성공하면 아무 말도 안한다.

 

예시 )

ec2-user:~/environment $ rm hellolinus
rm: cannot remove ‘hellolinus’: Is a directory
ec2-user:~/environment $ rm hellolinus
rm: cannot remove ‘hellolinus’: Is a directory
ec2-user:~/environment $ rm empty_file.txt
ec2-user:~/environment $

ec2-user:~/environment $ rm -r hellolinus

 

--help :  어떤 명령어에 대한 간단한 설명을 들을때 사용하는 명령어

예시 : rm --help , mkdir --help ...

 

man vs help : 

help는 현재 화면에서 보여줌 / man은 전용 페이지로 이동

q : man 페이지에 접속 후 빠져나가고 싶을 때 사용하는 명령어

예시)  

  man ls

 /(검색을 원하는 단어) : 설명 페이지에 접속하고 원하는 단어를 /뒤에 붙여서 입력하면

그 단어가 색칠해져서 ㅂㅗㅇㅣㄴㄷㅏ.

 

-------아니... 갑자기 한글이 전부 분리되서 쳐지는 현상이 생겨서

재부팅하고 다시 돌아옴 ㅠㅠ

ㅠㅠ...

사실 어떤 명령어 뒤에 --help 해서 검색해 보는게 가장 깔끔할 것 같긴 하다

 

예시 )

ec2-user:~/environment $ mkdir --help
Usage: mkdir [OPTION]... DIRECTORY...
Create the DIRECTORY(ies), if they do not already exist.

Mandatory arguments to long options are mandatory for short options too.
  -m, --mode=MODE   set file mode (as in chmod), not a=rwx - umask
  -p, --parents     no error if existing, make parent directories as needed
  -v, --verbose     print a message for each created directory
  -Z                   set SELinux security context of each created directory
                         to the default type
      --context[=CTX]  like -Z, or if CTX is specified then set the SELinux
                         or SMACK security context to CTX
      --help     display this help and exit
      --version  output version information and exit

GNU coreutils online help: <http://www.gnu.org/software/coreutils/>
For complete documentation, run: info coreutils 'mkdir invocation'
ec2-user:~/environment $ mkdir --version
mkdir (GNU coreutils) 8.22
Copyright (C) 2013 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>.
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

Written by David MacKenzie.

 

명령어 --version : 이 명령어의  version 확인 가능

 

 

 

'programming language > 리눅스' 카테고리의 다른 글

5. Linux 공부 / 2021-07-12  (0) 2021.07.12
4. 리눅스 공부 / 2021-07-06  (0) 2021.07.06
3. 리눅스 공부 / 2021-07-06  (0) 2021.07.06
2. 리눅스 공부 / 2021-07-04  (0) 2021.07.04
리눅스 공부 시작  (2) 2021.07.04