[Linux] 리눅스 명령어 정리

2023. 1. 26. 13:07Server/Linux

cd 디렉터리 이동
cd .. 디렉터리 이전 으로 이동

cd ~ home/user 최상위 디렉터리 이동

cd - home 최상위 디렉터리 이동

cd ../etc/systemd/network/ 상대경로

cd /tmp 절대경로

/가 최상위라는 뜻

pwd 현제 폴더 위치

mkdir 폴더 생성

vi [폴더명] 폴더 진입 

ls 현재 폴더의 구성 
ls -l 현재 폴더의 자세한 구성

ls -l 디렉터리 안에 있는 내용 출력

       ㄴ - 일반 파일
           d 디렉터리
            l 링크파일
           s 소켓파일
           b 블랙파일

ls -al 현재 폴더의 더 자세한 구성
sudo 관리자 권한 사용
dpkg 폴더 찾기
dpkg -l | grep [찾고자 하는 폴더]
clear 클리어
sudo apt-get remove -y mysql -server mysql 삭제

who 현재 서버에 누가 있는지 보여주는 명령어

 

허가권
drwxrwxr-x 디렉터리
-rw-r--r-- 일반파일

rwx / rwx / rwx
유저 / 그룹 / 그외
root / root
소유자 / 소유그룹

r 읽기
w 쓰기
x 실행

 

허가권 바꾸는 명령어
문자 명령어
chmod u-r [디렉터리명]

chmod g+w [디렉터리명]

chmod ugo-rwx [디렉터리명]

chmod a-rwx [디렉터리명]

숫자 명령어
chmod 744 [디렉터리명]
chmod 000 [디렉터리명]

 

폴더 디렉터리 소유자 변경 명령어

chown [계정명] [디렉터리]

소유그룹 변경

chgrp [계정그룹] [바꿀디렉터리]

소유자 소유그룹 변경

chown [계정명.계정그룹] [바꿀 디렉터리]

 

계정생성
useradd [유저명] 입력
passwd [유저명] 치면 passwd입력하는 게나옴

출력 명력어
cat - 전체를 다보여달라
tail - 밑에서 부터 보여달라
head - 위에서부터 보여달라
more - 전체 다
less

 

user 계정 생성 되었는지 확인 하는 명령어

tail -1 /etc/passwd

 

root 계정 진입

su

비밀번호 입력

 

:/$ 일반계정
:/# 관리자계정

 

/tmp 공유 디렉터리

 

blkid 블럭 아이디

 

링크파일 = 바로가기

 

파일 생성 명령어
touch abc

 

파일 나가기 명령어

:q

파일 저장하고 나가기
:wq

 

i-node 주소보기 명령어
ls -i

 

심볼릭링크 명령어

ln -s [바로가기 만들 파일] [바로가기 파일 이름]

 

학드링크 명령어

ln [바로가기 만들 파일] [바로가기 파일 이름]

 

2023-01-25 썻던 명령어

1  tail /etc/passwd
    2  tail -1 /etc/passwd
    3  useradd test2
    4  passwd test2
    5  tail -1 /etc/passwd
    6  tail -3 /etc/passwd
    7  tail -4 /etc/passwd
    8  cd /tmp
    9  mkdir test123
   10  ls
   11  ls -l
   12  chown test test123
   13  ls -l
   14  chgrp test test123
   15  ls -l
   16  chown root.root test123
   17  ls -l
   18  chown .test test123
   19  ls -l
   20  cd ..
   21  cd /
   22  cd tmp
   23  cd /
   24  cd /tmp
   25  cd ..
   26  cd etc/sysconfig/network-scripts
   27  ls
   28  cd etc
   29  ls
   30  systemd
   31  cd systemd/network/
   32  cd /
   33  ls
   34  tmp
   35  cd tmp
   36  cd ../etc/systemd/network/
   37  blkid
   38  cd /tmp
   39  touch abc
   40  ls
   41  vi abc
   42  ls -l
   43  ls -i
   44  ln -s abc abc12
   45  ls
   46  ls -l
   47  ls -i
   48  ls abc abc34
   49  ln abc abc34
   50  ls -i
   51  ls -l
   52  vi abc34
   53  vi abc12
   54  rm abc
   55  ls
   56  ls -i
   57  ls -l
   58  vi abc34
   59  touch abc
   60  vi abc
   61  ls -i
   62  vi abc12
   63  vi abc34
   64  ls -l
   65  rm abc
   66  vi abc
   67  ls -l
   68  clear
   69  history

 

vi
입력모드 insert
EX모드 :wq
커멘드모드 esc

 

vi ex모드 에서 쓸수 있는 명령어

o 개행

i 지금줄커서에서 insert
a 다음줄커서에서 insert

yy 복사
p 붙여넣기

dd 삭제

u 되돌리기

 

줄보기

:set nu

:set number

 

강제나가기

:q! 

 

80줄위치로 이동

:80 

 

fh찾기

:/fh 

내커서 위치 부터 밑으로 찾음

n 다음
N 이전

 

방향키

h 왼쪽 j 위쪽 k 아래쪽 l 오른쪽

글자 바꾸기

%s/13/30
%문서에대한 전체 / old / new

x 한글자 지우기
R 한글자 치환

 

드래그 
드래그하고 싶은 위치 에서 v키

 

2023-01-26 썻던 명령어

    1  ls -l
    2  home
    3  dc ~home
    4  ls
    5  ls -l
    6  cd a
    7  ls
    8  cd b
    9  ls
   10  cd c
   11  ls
   12  ls -l
   13  vi aa
   14  ls
   15  pwd
   16  cd..
   17  who
   18  ls -l
   19  cd a
   20  cd b
   21  cd c
   22  ls
   23  ls -l
   24  vi aa
   25  -rw-rw-r--
   26  cd..
   27  ..cd
   28  cd ..
   29  ls
   30  cd etc
   31  ls -l
   32  /etc/passwd
   33  cd /etc/passwd
   34  cd passwd
   35  cat /etc/passwd
   36  tail -l
   37  tail -1
   38  tail -1 /etc/passwd
   39  useradd test
   40  passwd test
   41  tail -1 /etc/passwd
   42  useradd test
   43  cd ..
   44  useradd test
   45  tail -1 /etc/passwd
   46  useradd test
   47  tail -1 /etc/passwd
   48  adduser test
   49  tail -1 /etc/passwd
   50  root
   51  sudo adduser test
   52  tail -1 /etc/passwd
   53  sudo useradd test1
   54  tail -1 /etc/passwd
   55  sudo passwd test1
   56  sudo passwd root
   57  su
   58  vi
   59  ls
   60  a
   61  b
   62  c
   63  d
   64  ls
   65  cd a
   66  cd b
   67  cd c
   68  ls
   69  vi aa
   70  cd /etc/passwd
   71  cd ..
   72  ls
   73  cd ..
   74  ls
   75  cd etc/passwd
   76  cd etc
   77  ls
   78  cd passwd
   79  tail -1 /etc/passwd
   80  cd psswd
   81  vim /etc/passwd
   82  history

 

파일 복사 
cp /tmp/test /root

 

디렉터리 복사

cp -r /tmp/test /root

 

디렉터리 옮기기
mv /tmp/test1 /root/aa

다른이름으로 옮기기
mv /root/aa/test1 /tmp/test2

 

이름 바꾸기
mv test1 test2

 

grep 패턴찾기
| pipe(명령어 통로)
ps 프로세스확인(옵션 ef)

top 실시간 프로세스 확인

 

명령어 연결 시켜줄때
명령어 | 명령어

명령어 붙여쓸때
명령어 && 명령어 && 명령어

프로세스 확인

ps -ef 

ps -ef | grep -v grep | grep ksmd

 

입출력 재지정

> 덮어쓰기

>> 붙여넣기

ls -l > /tmp/pass

내용 뒤에 붙여 넣기
cat /etc/passwd >> /tmp/pass

 

압축

tar -cvf test1.tar /etc/test

  압축파일 이름   저장 경로

 

압축 풀기
tar -xvf

 

압축 옵션 주기
tar -cjvf test.tar.bz2 aa bb cc dd

z = gzip
j = bzip2
J = xz

 

2023-01-27 썻던 명령어

    1  tail /etc/passwd
    2  tail -1 /etc/passwd
    3  useradd test2
    4  passwd test2
    5  tail -1 /etc/passwd
    6  tail -3 /etc/passwd
    7  tail -4 /etc/passwd
    8  cd /tmp
    9  mkdir test123
   10  ls
   11  ls -l
   12  chown test test123
   13  ls -l
   14  chgrp test test123
   15  ls -l
   16  chown root.root test123
   17  ls -l
   18  chown .test test123
   19  ls -l
   20  cd ..
   21  cd /
   22  cd tmp
   23  cd /
   24  cd /tmp
   25  cd ..
   26  cd etc/sysconfig/network-scripts
   27  ls
   28  cd etc
   29  ls
   30  systemd
   31  cd systemd/network/
   32  cd /
   33  ls
   34  tmp
   35  cd tmp
   36  cd ../etc/systemd/network/
   37  blkid
   38  cd /tmp
   39  touch abc
   40  ls
   41  vi abc
   42  ls -l
   43  ls -i
   44  ln -s abc abc12
   45  ls
   46  ls -l
   47  ls -i
   48  ls abc abc34
   49  ln abc abc34
   50  ls -i
   51  ls -l
   52  vi abc34
   53  vi abc12
   54  rm abc
   55  ls
   56  ls -i
   57  ls -l
   58  vi abc34
   59  touch abc
   60  vi abc
   61  ls -i
   62  vi abc12
   63  vi abc34
   64  ls -l
   65  rm abc
   66  vi abc
   67  ls -l
   68  clear
   69  history
   70  clear
   71  sds
   72  clean
   73  clear
   74  cd /root
   75  ls
   76  mkdir aa
   77  ls
   78  rm aa
   79  ls
   80  mkdir aa
   81  ls
   82  cd /emp
   83  cd /tmp
   84  ls
   85  cp /tmp/aa /root/aa/aa
   86  cd /root
   87  ls
   88  cd aa
   89  ls
   90  pwd
   91  cd /tmp
   92  mkdir test
   93  cp /tmp/test /root
   94  man cp
   95  cp -r /tmp/test /root
   96  cd /root
   97  ls
   98  man mv
   99  cd /tmp
  100  ls
  101  mkdir test1
  102  mv /tmp/test1 /root/aa
  103  ls
  104  cd /root/aa
  105  ls
  106  mv /root/aa/test1 /tmp/test2
  107  ls
  108  cd /tmp
  109  ls
  110  mv /tmp/aa /root/aa/bb
  111  ls
  112  cd /root/aa
  113  ls
  114  mv aa
  115  mv --help
  116  ls
  117  mv /root/aa
  118  history
  119  /tmp/test1 /root/aa
  120  cd /tmp
  121  ls
  122  touch aa
  123  ls
  124  ls-l
  125  ls -l
  126  ls -l aa
  127  ls -l | grep aa
  128  ps -ef
  129  ps -ef | grep crond
  130  Systrmctl start crond
  131  top
  132  systemd start crond
  133  top
  134  ps -ef | grep crond
  135  systemd start crond
  136  top
  137  ps -ef | grep systemd
  138  ps -ef | grep ksmd
  139  clear
  140  ps -ef | grep ksmd
  141  ps -ef | grep -v ksmd
  142  ps -ef | grep -v grep | grep ksmd
  143  cat /etc/passwd
  144  cat /etc/passwd > /tmp/pass
  145  ls
  146  cd pass
  147  vi pass
  148  ls -l
  149  ls -l > /tmp/pass
  150  vi pass
  151  cat /etc/passwd >> /tmp/pass
  152  vi pass
  153  cat < /tmp/pass
  154  cat /tmp/pass
  155  tail -4 /etc/passwd
  156  tail -4 /etc/passwd > /etc/test
  157  cd /etc
  158  vi test
  159  man tar
  160  ls
  161  tar -cvf test.tar /etc
  162  ls
  163  ls -l
  164  tar -cvf test1.tar /etc/test
  165  tar -cvf test1.tar /test
  166  tar -cvf test1.tar test
  167  ls -l
  168  rm test1.tar
  169  ls -l
  170  etc
  171  ls
  172  cd mysql
  173  ls -l
  174  cd ..
  175  tar -cjvf test2.tar.bz2 mysql test.tar test
  176  ls -l
  177  mkdir
  178  mkdir test222
  179  mv /etc/test2.tar.bz2 /etc/test222
  180  cd test222
  181  ls
  182  tar -xvf test2.tar.bz2
  183  ls -l
  184  ps

반응형