본문 바로가기

학교 & 학원 이론 수업/네이버 클라우드 AIaaS 개발자 양성 과정

4.19 Linux 3일차 수업

6장 파일 분류 권한의 이해



 ▼ 명령 프롬프트 설정  
  * 주 > PS1
   - 변수를 조절함 
  [sun@my ~]$ PS1='[\h "좌우명" \u \d \t ] \\$'
  - 바뀜 [my "좌우명" sun Wed Apr 19 10:02:05 ] $


   [my "좌우명" sun Wed Apr 19 10:02:18 ] $PS1='[\!  \w ] >'
   [251  ~ ] >who
    root     tty1         2023-04-19 09:27
    root     pts/0        2023-04-19 09:27 (10.0.2.2)
    sun      pts/1        2023-04-19 09:56 (10.0.2.2)
   [253  ~ ] >date
    Wed Apr 19 10:04:34 KST 2023
   [254  ~ ] >PS1='\w >'
    ~ >cd /usr/local
   /usr/local >


  *보조 > PS2
    - 오류 안내문 설정 

* 디렉토리 만들기 
[sun@my ~]$ mkdir d3 && cd d3

* 둘중 하나가 참이면 .. 그래서 위에가 참이니까 뒤에꺼 출력 안함
 [sun@my ~/d3]$  cal || date
     April 2023
Su Mo Tu We Th Fr Sa
                   1
 2  3  4  5  6  7  8
 9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30

* 둘다 참이여야 함 . 앞에서 거짓이라 오류 뜸 

①[sun@my ~/d3]$ ddddf && cal
-bash: ddddf: command not found

②[sun@my ~/d3]$ cal && 56
     April 2023
Su Mo Tu We Th Fr Sa
                   1
 2  3  4  5  6  7  8
 9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30
-bash: 56: command not found

▼ c 언어 코딩 
 [sun@my ~/d3]$  vi a.c

i - insert

  1 #include <stdio.h>
  2 int main (void)
  3 {
  4     puts("\n c 언어가 짱이다 \n");
  5     return 0;
  6 }

esc : x - 저장후 종료 

[sun@my ~/d3]$ gcc a.c -o a
[sun@my ~/d3]$ a

 c 언어가 짱이다

명령어 
  277  ll /etc
  278  ll /dev
  279  ll /run
  280  find /run -type s 2>/dev/null
  281  find /run -type s -exec ls -al {} \;  2>/dev/null
      ==for each 문 
{} 이 안에 
exec 실행 
ls -al 자세히 보여줘 


[sun@my ~/d3]$ file /run/initctl
/run/initctl: fifo (named pipe)
 fifo -  stack 선입선출 
 lifo - queue 

파일 종류 보는 명령어 p44
  - 참고 확장자 종류 p44
 - 리눅스는 모든 것을 file 취급함, 확장자 개념이 없다 (ex.exe)
 - .c .java 컴파일 입력 파일은 확장자를 따짐 

  286  file /bin/ls
  287  file /etc
  288  file /dev/tty
  289  file /dev/sda
  290  file /etc/bashrc
  291  file /dev/log
  292  ll /dev/log
  293  mkfifo aa  -aa 파일 만들기 
  294  ls    - 위에 aa 만든것 확인 
       rm aa - aa 파일 지우기


=====================
[sun@my ~/d3]$ cp a cpa  카피한다 a 파일을 cpa라는 이름으로 

[sun@my ~/d3]$ ll -i
 total 60 
  --- 포인터 관련, 하드디스크 번지 (주소값), 운영체제가 file 을 관리하는 번호 




[sun@my ~/d3]$ ln a lna  a를 lna 으로 새로만듬
[sun@my ~/d3]$ lna 

 c 언어가 짱이다

[sun@my ~/d3]$ l
total 88
9640537 -rwxr-xr-x. 2 sun sun 25792 Apr 19 10:25 a*
9640538 -rw-r--r--. 1 sun sun    88 Apr 19 10:25 a.c
9640539 -rwxr-xr-x. 1 sun sun 25792 Apr 19 11:16 cpa*
9640537 -rwxr-xr-x. 2 sun sun 25792 Apr 19 10:25 lna*
[sun@my ~/d3]$ ln -s a sa2
[sun@my ~/d3]$ l
total 88
9640537 -rwxr-xr-x. 2 sun sun 25792 Apr 19 10:25 a*
9640538 -rw-r--r--. 1 sun sun    88 Apr 19 10:25 a.c
9640539 -rwxr-xr-x. 1 sun sun 25792 Apr 19 11:16 cpa*
9640537 -rwxr-xr-x. 2 sun sun 25792 Apr 19 10:25 lna*
9640540 lrwxrwxrwx. 1 sun sun     1 Apr 19 11:26 sa2 -> a*

 sa2 -> a* 
=== 복사 한게 아니라 포인터를 reference 함 

int a[100] 배열 100개 
output(a) 400 byte 
복사 (a 증가)
a  a  a  = 용량  초과 = 컴퓨터 다운
그래서 reference 이용 
(번지수 전달 = 포인터)

- reference 이동할 통로를 제공해 주겠다 

▼ 링크 파일 

process - PID 
file    - I-node, index- node 
user    - UID
group   - GID

p51 외부 명령어 
-프로그램 설치 없이 있는 빌트인을 볼 수 있는 명령어 
[sun@my ~/d3]$ compgen -b | column | nl
[sun@my ~/d3]$ compgen -a | column | nl
[sun@my ~/d3]$ compgen -k | column | nl
[sun@my ~/d3]$ compgen -c | column | nl
 

[sun@my ~/d3]$ ifconfig
-bash: ifconfig: command not found
 - 프로그램이 설치가 되어야 하는 명령어 


8장 리눅스 설치

 

8장 리눅스 설치 

* cmd 창 = ipcinfig /all
   물리적 주소 - 맥 주소 
   ipv4 =  ip addr
   서브넷 마스크 = netmask 
   게이트웨이 = gateway
              = dns

cpu 갯수 2개 이상 

▼ 우분투 다운 파일 
 
virtualBox

tap, 스페이스. 방향키 , 엔터 

리눅스 (할줄 아는것)
- Linux 설치, 원본 백업 
- linux 설치 후 작업 
- 필수 패키지 설치 
  p82 우분투 설치 방법 있음 
      locky 설치 방법 작성 예정
- 기차 환경 설정, 백업

sudo useradd moon 
sudo passwd moon

## root 권한 으로  실행하려면 (p81)
①sudo ....
②sudo -i
 확인 --#whoami

# 날짜 변경하기 (p81) 
timedatectl set-timezone Asia/Seoul

확인 -- date 

# 초기 package 수 확인하기 
apt list --installed |wc -l
apt list --installed | nl

# 한글 locale 설정 (p81)

# package 설치 확인 방법 
apt list --installed | grep java

# vim 다운 (ncla cal프로그램),(다른 package 다운 p82)
apt -y install vim ncal

# 새로운 유저 만들기 
 adduser 이름 

# 만든 사용자 확인하기
ls/ home

# 설치 때 만든 파티션 확인 
df -h

# 앞에 사용자 바꾸기 
PS1 ='[\! \u@\h \w] \\$ '

# 집 만들고 집 권한 넘겨주기 (root → mbs)
root@j:~# mkdir /home/mbs
root@j:~# chmod 770 /home/mbs
root@j:~# chown mbs.mbs /home/mbs
root@j:~#


# 다운 방법 
root@j:~# mkdir /down
root@j:~# cd /down
 (sqlite 홈페이지  source code 왼쪽 클릭 링크복사 붙여넣기)
root@j:/down# wget https://www.sqlite.com/2023/sqlite-autoconf-3410200.tar.gz

# 삭제하기
apt remove sqlite3

#조회하기 
apt list --installed | grep sqlite

# sqlite3 들어가고 나가기 

root@j:/down# sqlite3
  SQLite version 3.37.2 2022-01-06 13:25:41
  Enter ".help" for usage hints.
  Connected to a transient in-memory database.
  Use ".open FILENAME" to reopen on a persistent database.
sqlite> .q

=======================================================================
# 다운할폴더만들고, 소스코드 복사하기 
root@j:~# mkdir /down
root@j:~# cd /down
 (sqlite 홈페이지  source code 왼쪽 클릭 링크복사 붙여넣기)
root@j:/down# wget https://www.sqlite.com/2023/sqlite-autoconf-3410200.tar.gz

# 수동으로 알집 풀기 (프로그램 설치)
root@j:/down# gunzip sqlite-autoconf-3410200.tar.gz
root@j:/down# ls
sqlite-autoconf-3410200.tar

root@j:/down# tar xf sqlite-autoconf-3410200.tar
root@j:/down# ls
sqlite-autoconf-3410200  sqlite-autoconf-3410200.tar
root@j:/down# cd sqlite-autoconf-3410200
root@j:/down/sqlite-autoconf-3410200#

#파일 열기 
root@j:/down# ls
   sqlite-autoconf-3410200  sqlite-autoconf-3410200.tar
root@j:/down# cd sqlite-autoconf-3410200
root@j:/down/sqlite-autoconf-3410200# ls
  INSTALL            README.txt    config.sub    ltmain.sh  sqlite3.h      tea
  Makefile.am        Replace.cs    configure     missing    sqlite3.pc.in
  Makefile.fallback  aclocal.m4    configure.ac  shell.c    sqlite3.rc
  Makefile.in        compile       depcomp       sqlite3.1  sqlite3ext.h
  Makefile.msc       config.guess  install-sh    sqlite3.c  sqlite3rc.h
root@j:/down/sqlite-autoconf-3410200# vi README.txt


# 위치지정 
  // 컴파일 환경설정 
root@j:/down/sqlite-autoconf-3410200# ./configure --prefix=/s3
  // 컴파일
root@j:/down/sqlite-autoconf-3410200# make
  // 복사 
root@j:/down/sqlite-autoconf-3410200# make install

----s3 존재 확인 -----
root@j:/down/sqlite-autoconf-3410200# ls /
  backup  dev   home   lib64       media  proc  s3    srv       tmp
  bin     down  lib    libx32      mnt    root  sbin  swap.img  usr
  boot    etc   lib32  lost+found  opt    run   snap  sys       var


root@j:/down/sqlite-autoconf-3410200# cd /s3
root@j:/s3# ls
   bin  include  lib  share

root@j:/s3# cd bin
root@j:/s3/bin# ls
  sqlite3

// 실행
root@j:/s3/bin# ./sqlite3
  SQLite version 3.41.2 2023-03-22 11:56:21
  Enter ".help" for usage hints.
  Connected to a transient in-memory database.
  Use ".open FILENAME" to reopen on a persistent database.
sqlite>
=======================================================================================
ls 목록열기 
nl 파일하나 자세히 보기?

redhat 계열 
  yum -y install
ubuntu
  dnf -y install

==================

10장 process 관리 


#top
 q 끝내기 
 h 도움말 
tastk = process
 
#process 검색 방법
root= ps -ef
mbs 에서 돌아가는거 검색 
root= ps -ef | grep mbs
mbs 에서만 돌아가는 것
ps -ef | grep ^mbs
mbs  강퇴 (ps -ef | grep ^mbs 검색 결과 2번쨰 숫자들이 아이디값임 그것을 kill 하면 됨)
 kill -9 12390

root@j:/etc/apt# ps -ef | grep ^mbs
   mbs         8068       1  0 15:35 ?        00:00:00 /lib/systemd/systemd --user
   mbs         8093    8065  0 15:35 ?        00:00:00 sshd: mbs@pts/2
   mbs         8094    8093  0 15:35 pts/2    00:00:00 -sh
   mbs        12389   12369  0 17:23 ?        00:00:00 sshd: mbs@pts/5
   mbs        12390   12389  0 17:23 pts/5    00:00:00 -sh
root@j:/etc/apt# kill -9 12390
root@j:/etc/apt# ps -ef | grep ^mbs
   mbs         8093    8065  0 15:35 ?        00:00:00 sshd: mbs@pts/2
   mbs         8094    8093  0 15:35 pts/2    00:00:00 -sh
====
삭제 전 

root@j:/etc/apt# who
moon     tty1         2023-04-19 14:33
moon     pts/0        2023-04-19 14:35 (10.0.2.2)
j        pts/1        2023-04-19 14:36 (10.0.2.2)
j        pts/3        2023-04-19 14:55 (10.0.2.2)
j        pts/4        2023-04-19 14:55 (10.0.2.2)
mbs      pts/2        2023-04-19 15:35 (10.0.2.2)
mbs      pts/5        2023-04-19 17:23 (10.0.2.2)
===삭제 후 

root@j:/etc/apt# who
moon     tty1         2023-04-19 14:33
moon     pts/0        2023-04-19 14:35 (10.0.2.2)
j        pts/1        2023-04-19 14:36 (10.0.2.2)
j        pts/3        2023-04-19 14:55 (10.0.2.2)
j        pts/4        2023-04-19 14:55 (10.0.2.2)
mbs      pts/2        2023-04-19 15:35 (10.0.2.2)


# 설치된 프로그램 검색 


root@j:/etc/apt# apt list --installed | grep tomcat

   WARNING: apt does not have a stable CLI interface. Use with caution in scripts.

   libtomcat9-java/jammy-updates,now 9.0.58-1ubuntu0.1 all [installed,automatic]
   tomcat9-common/jammy-updates,now 9.0.58-1ubuntu0.1 all [installed,automatic]
   tomcat9/jammy-updates,now 9.0.58-1ubuntu0.1 all [installed]

#간편하게 alias 지정해서 검색하기 

root@j:/etc/apt# alias ag='apt list --installed | grep'
root@j:/etc/apt# ag tomcat

톰캣 실행?
root@j:/etc/apt# systemctl start apache2
root@j:/etc/apt# systemctl status apache2
● apache2.service - The Apache HTTP Server

 - virtualBox - 설정 - 포트 - 80 추가 

인터넷 창 : localhost 



root@j:/etc/apt# cd /var/
root@j:/var# ls
backups  crash  local  log   opt  snap   tmp
cache    lib    lock   mail  run  spool  www
root@j:/var# cd www
root@j:/var/www# ls
html
root@j:/var/www# cd html/
root@j:/var/www/html# ls
index.html
root@j:/var/www/html# mv index.html old.html
root@j:/var/www/html# ls
old.html
root@j:/var/www/html# echo "이름" > a.text
root@j:/var/www/html# vi index.jtml
root@j:/var/www/html# ls
a.text  index.jtml  old.html
root@j:/var/www/html# mv index.jtml index.html
root@j:/var/www/html# ls
a.text  index.html  old.html
root@j:/var/www/html# vi index.html


 

 

'학교 & 학원 이론 수업 > 네이버 클라우드 AIaaS 개발자 양성 과정' 카테고리의 다른 글

세미 프로젝트  (0) 2023.05.01
04.28(금) Thymeleaf  (0) 2023.04.28
4.18 Linux (2)  (1) 2023.04.18
4.17 Linux(1)  (1) 2023.04.18
4.12~ 4.14 수업정리 - Spring Boot (1)  (0) 2023.04.14