본문 바로가기
네이버클라우드/Linux

Linux 5일차 (2023-04-28) Ubuntu Linux 설치 후 작업 및 실습

by prometedor 2023. 4. 28.

 

▶ 리눅스 5일차 수업

  1. 리눅스 설치, 설치 후 --> 이미지 내보내기
  
  2. 기초 필수 개발 패키지 설치(gcc, java, mysql 등)
  
  3. 개발 환경 테스트(C, C++, java, Python)
  
  4. mysql-설정 및 테스트
  
  5. 사용자 만들기 기본 값 설정
  
  6. 사용자 용량제한 설정하기 참고
    group NC, nc1, nc2, nc3
    
  7. 보너스 windows(D:\win) 폴더 /yes로 mount 해보기
  
  8. sqlite3를 소스컴파일 방식으로 /sql 
  
  축하합니다. 이미지로 내보내기 및 가져오기 확인
  
  date  --> 시간대 변경
  timedatectl set-timezone Asia/Seoul

 

리눅스 설치 후 이미지 내보내기

ㄴ 내보내고 싶은 가상 시스템 선택 > 파일 > 가상 시스템 내보내기

 

ㄴ 내보낼 가상 시스템 선택 > [다음] 선택

 

ㄴ [다음] 선택

 

ㄴ [Finish] 선택

 

 

내보내기 한 이미지 가져오기

ㄴ 파일  선택 > 가상 시스템 가져오기 선택

 

ㄴ 폴더 아이콘 선택

 

ㄴ 내보내기 했던 이미지 선택 > [열기] 선택

 

ㄴ [다음] 선택

 

ㄴ [Finish] 선택

 

ㄴ My UbuntuLinux  1 로 가져오기 성공

 

ㄴ 가져온 서버 로그인 성공

 

 

 


설치 후 기초 설정 및 필수 개발 패키지 설치

Putty root 로 로그인

ㄴ sudo -i  이용하여 root 로그인

 

vi를 이용한 Alias 설정 ( ~/.bashrc 파일)

vi ~/.bashrc

root@ysy:~# vi ~/.bashrc


alias ll='ls -alF'  --> 원래 셋팅
alias la='ls -A'  --> 원래 셋팅
alias l='ls -CF'  --> 원래 셋팅

alias h='history'
alias l='ls -AlF'
alias c='clear'
alias cp='cp -i'
alias mv='mv -i'
alias df='df -h'
alias du='du -sh'
alias li='ls -Ali'
alias lh='ls -Alh'

alias ai='apt -y install'
alias aq='apt list --installed | grep '
alias ac='apt list --installed | wc -l'

 

vi를 이용한 ~/.vimrc 파일 설정

vi ~/.vimrc

root@ysy:~# vi ~/.vimrc


se nu ai ci si
se ts=4 sw=4
se ruler title showmatch
syntax on
hi comment ctermfg=red

** 주의 : vi 이용하여 ~/.bashrc 와 vi ~/.vimrc 설정 시 재로그인 하는 효과를 주기 위해 . ~/.profile 을 해주어야 함

root@ysy:~# . ~/.profile

 

필수 개발 패키지 설치

gcc g++ default-jdk mysql-server 
apache2 mandoc sqlite3 rdate rename 
tree mailutils lynx tomcat9 glibc-doc
root@ysy:~# ai gcc g++ default-jdk mysql-server \
> apache2 mandoc sqlite3 rdate rename \
> tree mailutils lynx tomcat9 glibc-doc

 

리눅스 종료 후 재시작

#poweroff

login as: j
j@127.0.0.1's password:
Welcome to Ubuntu 23.04 (GNU/Linux 6.2.0-20-generic x86_64)

 * Documentation:  https://help.ubuntu.com
 * Management:     https://landscape.canonical.com
 * Support:        https://ubuntu.com/advantage

  System information as of Fri Apr 28 04:20:55 PM UTC 2023

  System load:    0.44             Processes:               128
  Usage of /home: 0.0% of 4.84GB   Users logged in:         0
  Memory usage:   34%              IPv4 address for enp0s3: 10.0.2.15
  Swap usage:     0%


2 updates can be applied immediately.
To see these additional updates run: apt list --upgradable


Last login: Fri Apr 28 16:20:56 2023

 

 

 


개발 환경 테스트(C, C++, java, Python)

java 파일 컴파일 하고 실행하기

root@ysy:~# vi j.java

 public class j{
 	public static void main(String[] str){
    		System.out.println("java 테스트");
    	}
 }

root@ysy:~# javac j.java
root@ysy:~# ls
j.class  j.java  snap
root@ysy:~# java j
java 테스트

 

c++ 파일 컴파일 하고 실행하기

root@ysy:~# vi cc.cpp

#include<iostream>
using namespace std;
int main(void)
{
    cout << "C++ 테스트" << endl;
    return 0;
}

root@ysy:~# g++ -o cc cc.cpp
root@ysy:~# ./cc
C++ 테스트

 

c 파일 컴파일 하고 실행하기

root@ysy:~# vi c.c

#include<stdio.h>
int main(void)
{
    puts("C 테스트");
    return 0;
}


root@ysy:~# gcc c.c -o c
root@ysy:~# ./c
C 테스트

 

python 파일 컴파일 하고 실행하기

root@ysy:~# vi p.py

print("python 테스트")

root@ysy:~# python3 p.py
python 테스트

 

 

 


mysql-설정 및 테스트

사전에 root에서 사용자(sy)를 만들어둠

root@ysy:~# useradd sy
root@ysy:~# passwd sy
New password:
Retype new password:
passwd: password updated successfully

 

mysql 설정 및 테스트 

ㄴ root 에서 mysql 설정하기

root@ysy:~# mysql
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 8
Server version: 8.0.32-0ubuntu4 (Ubuntu)

Copyright (c) 2000, 2023, Oracle and/or its affiliates.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> select user();
+----------------+
| user()         |
+----------------+
| root@localhost |
+----------------+
1 row in set (0.00 sec)

mysql> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
| sys                |
+--------------------+
4 rows in set (0.00 sec)

mysql> use mysql
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Database changed
mysql> alter user root@localhost identified \
    -> with mysql_native_password by 'jj';
    
mysql> create user mysy@localhost identified \
    -> with mysql_native_password by 'j';
Query OK, 0 rows affected (0.00 sec)

mysql> grant all privileges on syDB.* to mysy@localhost;
Query OK, 0 rows affected (0.00 sec)

mysql> exit
Bye

 

** 주의 할 것

=> 만들어 두었던 사용자(sy)로 로그인 하여 확인했을 때 home_dir 이 없는 것을 볼 수 있음

==> chsh 를 이용해서 기본 쉘을 바꿔주고 root 에서 홈 디렉터리를 만들어 주어야 함

==> 또는  root에서 useradd 의 기본 설정 변경해 주어야 함

 

1. sy 로그인 상태에서 기본 쉘 변경 후 root 에서 홈디렉터리 생성해줌

$ whoami
sy
$ chsh  --> 사용자가 로그인 쉘을 변경
Password:
Changing the login shell for k1
Enter the new value, or press ENTER for the default
        Login Shell [/bin/sh]: /bin/bash  --> /bin/sh 를 /bin/bash 로 변경해줌
        
--> 기본 쉘 /bin/bash 로 변경됨

$ echo ~
/home/sy
$ pwd
/
$ ls /home
j  lost+found
$

root에서 홈디렉터리 만들어줌
root@ysy:~# mkdir /home/sy

==> 재로그인

sy로 로그인하여 확인
sy@ysy:~$  ==> 홈 디렉터리가 생긴 것을 확인(~)
sy@ysy:~$ ls -Al /etc/skel/
total 16
-rw-r--r-- 1 root root  220 Jan  7 07:34 .bash_logout
-rw-r--r-- 1 root root 3771 Jan  7 07:34 .bashrc
-rw-r--r-- 1 root root  807 Jan  7 07:34 .profile
-rw-r--r-- 1 root root   86 Apr 30 04:49 .vimrc

sy1 로 로그인 하여 확인(여기서 sy1 은 홈 디렉토리 있게 만들어 둔 사용자)
sy1@ysy:~$ ls -Al
total 24
-rw------- 1 sy1 sy1   35 Apr 28 18:10 .bash_history
-rw-r--r-- 1 sy1 sy1  220 Jan  7 07:34 .bash_logout
-rw-r--r-- 1 sy1 sy1 3771 Jan  7 07:34 .bashrc
drwx------ 2 sy1 sy1 4096 Apr 28 17:29 .cache  --> 생김
-rw------- 1 sy1 sy1  356 Apr 28 18:04 .mysql_history
-rw-r--r-- 1 sy1 sy1  807 Jan  7 07:34 .profile

 

2. root에서 useradd 의 기본 설정 변경해 주어야 함(사용자를 생성할 때마다 홈 디렉터리 생성해 주도록)

ㄴ useradd 파일의 내용을 변경하면 이후 계정 생성 시 마다 계속 적용됨

root@ysy:~# useradd -D  --> useradd default 설정 확인
GROUP=100
HOME=/home
INACTIVE=-1
EXPIRE=
SHELL=/bin/sh
SKEL=/etc/skel
CREATE_MAIL_SPOOL=no
LOG_INIT=yes

root@ysy:~# nl /etc/default/useradd  --> useradd default 설정 확인
     1  # Default values for useradd(8)
     2  #
     3  # The SHELL variable specifies the default login shell on your
     4  # system.
     5  # Similar to DSHELL in adduser. However, we use "sh" here because
     6  # useradd is a low level utility and should be as general
     7  # as possible
     8  SHELL=/bin/sh  --> 기본이 /bin/sh 로 되어있음
     9  #
    10  # The default group for users
    11  # 100=users on Debian systems
    12  # Same as USERS_GID in adduser
    13  # This argument is used when the -n flag is specified.
    14  # The default behavior (when -n and -g are not specified) is to create a
    15  # primary user group with the same name as the user being added to the
    16  # system.
    17  # GROUP=100
    18  #
    19  # The default home directory. Same as DHOME for adduser
    20  # HOME=/home
    21  #
    22  # The number of days after a password expires until the account
    23  # is permanently disabled
    24  # INACTIVE=-1
    25  #
    26  # The default expire date
    27  # EXPIRE=
    28  #
    29  # The SKEL variable specifies the directory containing "skeletal" user
    30  # files; in other words, files such as a sample .profile that will be
    31  # copied to the new user's home directory when it is created.
    32  # SKEL=/etc/skel
    33  #
    34  # Defines whether the mail spool should be created while
    35  # creating the account
    36  # CREATE_MAIL_SPOOL=no
    
root@ysy:~# useradd -D -s /bin/bash  --> 기본 쉘 변경

 

ㄴ 기본 쉘 변경됨을 확인

 

root@ysy:~# nl /etc/default/useradd  --> 변경된 useradd 설정 다시 확인
 
--> SHELL=/bin/sh => SHELL=/bin/bash 로 변경되어 있음을 확인

 

 

ㄴ /etc/login.defs 파일 편집(CREATE_HOME yes 추가)

root@ysy:~# vi /etc/login.defs

--> 파일 편집 아래 한 줄을 13번 라인에 추가하면 useradd 시 자동으로 home_dir 생성됨

=> 다시 다른 사용자(sy2) 생성 (지금부터 생성하는 사용자는 모두 home_dir 이 자동으로 생성됨)

root@ysy:~# useradd sy2
root@ysy:~# passwd sy2
New password:
Retype new password:
passwd: password updated successfully

=> 새로 생성한 사용자(sy2)로 로그인

=>  home _dir 이 생긴 것을 확인할 수 있음

 

 

=> 다시 mysql 창으로 돌아가서 생성한 사용자(sy)가 mysql 을 사용할 수 있도록 설정해 줌

sy1@ysy:~$ mysql -u mysy -p  --> 생성한 사용자(sy1)가 mysql 을 사용할 수 있도록 설정

--> MySQL 데이터베이스에 mysy 사용자로 로그인하는 데 사용됨
    ㄴ -u  옵션 : MySQL에 로그인할 사용자 이름을 지정
    ㄴ -p 옵션 : 암호를 입력하도록 요청

Enter password:  
--> (root에서 mysy@localhost identified with mysql_native_password by 'j'; 로 설정했으므로 비밀번호 : j)

Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 11
Server version: 8.0.32-0ubuntu4 (Ubuntu)

Copyright (c) 2000, 2023, Oracle and/or its affiliates.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> select user();
+----------------+
| user()         |
+----------------+
| mysy@localhost |
+----------------+
1 row in set (0.00 sec)

mysql> use mysql
ERROR 1044 (42000): Access denied for user 'mysy'@'localhost' to database 'mysql'
--> 아직 데이터베이스를 설정하지 않았으므로 에러

mysql> create database syDB;  --> syDB 라는 이름으로 데이터베이스를 설정함
Query OK, 1 row affected (0.00 sec)

mysql> use syDB;  --> syDB 를 사용하겠다
Database changed
mysql> show tables;  --> table 목록 보기
Empty set (0.00 sec)

mysql> create table Man(  --> 새로운 Man 테이블 생성
    -> name char(20),
    -> age int);
Query OK, 0 rows affected (0.01 sec)

mysql> insert into Man values("손흥민", 32);
Query OK, 1 row affected (0.00 sec)

mysql> insert into Man values("이강인", 23);
Query OK, 1 row affected (0.00 sec)

mysql> select * from Man;  --> Man 테이블 조회
+-----------+------+
| name      | age  |
+-----------+------+
| 손흥민    |   32 |
| 이강인    |   23 |
+-----------+------+
2 rows in set (0.00 sec)

mysql> exit
Bye

 

 

 


사용자 만들기 기본 값 설정

사용자 만들기

root@ysy:~# useradd sy3
root@ysy:~# passwd sy3
New password:
Retype new password:
passwd: password updated successfully

 

사용자 기본 값 설정

 ㄴ /etc/skel/.bashrc (alias 설정)

alias ll='ls -alF'
alias la='ls -A' 
alias l='ls -CF'

--> 이것들은 기본 설정임

--> 아래만 추가해주면 됨

 

vi /etc/skel/.bash_aliases 설정 해주기

root@ysy:~# vi /etc/skel/.bash_aliases

alias h='history'
alias l='ls -AlF'
alias c='clear'
alias cp='cp -i'
alias mv='mv -i'
alias df='df -h'
alias du='du -sh'
alias li='ls -Ali'
alias lh='ls -Alh'

alias ai='apt -y install'
alias aq='apt list --installed | grep '
alias ac='apt list --installed | wc -l'

 

ㄴ /etc/skel/.vimrc 

root@ysy:~# cp .vimrc /etc/skel/  --> root한테 있는 .vimrc 를 /etc/skel 에 복사 해줌 
				  --> 일반 사용자도 쓸 수 있게 됨
cp: overwrite '/etc/skel/.vimrc'? y

 

ㄴ /etc/default/useradd 

root@ysy:~# nl /etc/default/useradd


ㄴ    /etc/login.defs  

root@ysy:~# vi /etc/login.defs

ㄴ .bashrc 수정

 

 

** 추가 >>  /etc/skel/.bashrc 수정하여 프롬프트(prompt)의 형식 변경 : PS1(환경변수)

 

ㄴ PS1 값을 변경해줌

#PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w\$ '
=> 아래와 같이 변경해줌

PS1='[::\! \h@ HELLOsy \u \w]\n \\$ '

 

ㄴ root 에서 sy4 라는 사용자를 추가한 후 sy4 로그인

ㄴ 프롬프트(prompt)의 형식 변경을확인

 

 

 

 


사용자 용량제한 설정하기

사용자 생성

ㄴ 그룹과 사용자 생성 후 각각의 사용자에게 비밀번호 생성해주기

root@ysy:~# groupadd NC  --> NC 그룹 생성

root@ysy:~# useradd -G NC nc1  --> NC 그룹 안에 nc1 사용자 생성
root@ysy:~# useradd -G NC nc2  --> NC 그룹 안에 nc2 사용자 생성
root@ysy:~# useradd -G NC nc3  --> NC 그룹 안에 nc3 사용자 생성

root@ysy:~# tail -5 /etc/group  --> 생성된 그룹 NC와 NC 그룹 안에 속하는 사용자 nc1, nc2, nc3 확인
sy3:x:1003:
NC:x:1004:nc1,nc2,nc3  --> nc1, nc2, nc3 는 NC 그룹 안에 속해있음
nc1:x:1005:  --> 사용자 nc1
nc2:x:1006:  --> 사용자 nc2
nc3:x:1007:  --> 사용자 nc3

--> 각각의 사용자에게 비밀번호 설정해주기
root@ysy:~# passwd nc1
New password:
Retype new password:
passwd: password updated successfully
root@ysy:~# passwd nc2
New password:
Retype new password:
passwd: password updated successfully
root@ysy:~# passwd nc3
New password:
Retype new password:
passwd: password updated successfully

 

/etc/fstab 파일 수정

root@ysy:~# vi /etc/fstab
ㄴ /home 설정 라인에 ,usrquota 추가

**주의

ㄴ defaults 뒤에 띄어쓰기 하면 안됨

 

ㄴ mount | grep /home 명령 시 오류 해결

root@ysy:~# mount | grep /home
/dev/sda5 on /home type ext4 (rw,relatime)
mount: (hint) your fstab has been modified, but systemd still uses
       the old version; use 'systemctl daemon-reload' to reload.
       --> 해결법 : systemctl daemon-reload 명령을 해준 후 재시도
root@ysy:~# systemctl daemon-reload
root@ysy:~# mount -o remount /home
root@ysy:~# mount | grep /home
/dev/sda5 on /home type ext4 (rw,relatime,quota,usrquota)  --> quota와 usrquota 가 생김

 

ㄴ quotacheck 오류 -> quota 설치

root@ysy:~# quotacheck -agum
Command 'quotacheck' not found, but can be installed with:
apt install quota  --> apt install quota 명령을 해주어 quota를 설치해줌
root@ysy:~# apt install quota  --> quota 설치
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
Suggested packages:
  libnet-ldap-perl rpcbind
The following NEW packages will be installed:
  quota
0 upgraded, 1 newly installed, 0 to remove and 2 not upgraded.
Need to get 211 kB of archives.
After this operation, 1,221 kB of additional disk space will be used.
Get:1 http://kr.archive.ubuntu.com/ubuntu lunar/main amd64 quota amd64 4.06-1build3 [211 kB]
Fetched 211 kB in 2s (116 kB/s)
Preconfiguring packages ...
Selecting previously unselected package quota.
(Reading database ... 101704 files and directories currently installed.)
Preparing to unpack .../quota_4.06-1build3_amd64.deb ...
Unpacking quota (4.06-1build3) ...
Setting up quota (4.06-1build3) ...
Processing triggers for man-db (2.11.2-1) ...
Scanning processes...
Use of uninitialized value in hex at /usr/share/perl5/NeedRestart/uCode/AMD.pm line 175.     ]
Scanning processor microcode...
Scanning linux images...

Running kernel seems to be up-to-date.

Failed to check for processor microcode upgrades.

No services need to be restarted.

No containers need to be restarted.

No user sessions are running outdated binaries.

No VM guests are running outdated hypervisor (qemu) binaries on this host.

 

quota 설정

파일 시스템에서 사용 가능한 디스크 공간을 제한하고 각 사용자 또는 그룹이 할당된 디스크 공간의 양을 제어

 

ㄴ 'edquota -u 사용자' 를 이용해 사용 가능한 디스크 공간 제한

root@ysy:~# ls /home/
j  lost+found  nc1  nc2  nc3  sy  sy1  sy3

root@ysy:~# quotacheck -aug
root@ysy:~# ls /home/
aquota.user  j  lost+found  nc1  nc2  nc3  sy  sy1  sy3

root@ysy:~# quotaon -aug
root@ysy:~# repquota -a
*** Report for user quotas on device /dev/sda5
Block grace time: 7days; Inode grace time: 7days
                        Block limits                File limits
User            used    soft    hard  grace    used  soft  hard  grace
----------------------------------------------------------------------
root      --    1304       0       0              4     0     0
j         --      32       0       0             11     0     0
sy1       --      28       0       0              8     0     0
sy3       --      40       0       0              9     0     0
nc1       --      28       0       0              7     0     0
nc2       --      28       0       0              7     0     0
nc3       --      28       0       0              7     0     0

root@ysy:~# edquota -t  --> 유예기간 설정 // 수정할 거 없음. 내용만 보기
root@ysy:~# edquota -u nc1  --> nc1 사용자의 soft 블럭 제한 : 5M(5000), hard 블럭 제한 : 6M(6000)

ㄴ 저장 : ^o (ctrl + o) > enter 키 > ^x (ctrl + x) 

 

 

root@ysy:~# repquota -a  --> quota 설정 보기
*** Report for user quotas on device /dev/sda5
Block grace time: 7days; Inode grace time: 7days
                        Block limits                File limits
User            used    soft    hard  grace    used  soft  hard  grace
----------------------------------------------------------------------
root      --    1304       0       0              4     0     0
j         --      32       0       0             11     0     0
sy1       --      28       0       0              8     0     0
sy3       --      40       0       0              9     0     0
nc1       --      32    5000    6000              9     0     0  --> nc1 설정 확인
nc2       --      28       0       0              7     0     0
nc3       --      28       0       0              7     0     0

 

nc1 의 quota 설정 nc2, nc3 에도 복사

root@ysy:~# edquota -p nc1 nc2 nc3  --> nc1 의 quota 설정을 nc2, nc3 에도 복사

root@ysy:~# repquota -a  --> nc1, nc2 에 nc1 의 quota 설정 복사됨을 확인
*** Report for user quotas on device /dev/sda5
Block grace time: 7days; Inode grace time: 7days
                        Block limits                File limits
User            used    soft    hard  grace    used  soft  hard  grace
----------------------------------------------------------------------
root      --    1304       0       0              4     0     0
j         --      32       0       0             11     0     0
sy1       --      28       0       0              8     0     0
sy3       --      40       0       0              9     0     0
nc1       --      32    5000    6000              9     0     0
nc2       --      28    5000    6000              7     0     0
nc3       --      28    5000    6000              7     0     0

 

fallocate 

ㄴ sy1 으로 로그인

nc1@ysy:~$ whoami
nc1
sy1@ysy:~$ ls -Alh
total 24K
-rw------- 1 sy1 sy1   35 Apr 28 18:10 .bash_history
-rw-r--r-- 1 sy1 sy1  220 Jan  7 07:34 .bash_logout
-rw-r--r-- 1 sy1 sy1 3.7K Jan  7 07:34 .bashrc
drwx------ 2 sy1 sy1 4.0K Apr 28 17:29 .cache
-rw------- 1 sy1 sy1  356 Apr 28 18:04 .mysql_history
-rw-r--r-- 1 sy1 sy1  807 Jan  7 07:34 .profile

sy1@ysy:~$ fallocate -l 0.1G k  --> -l 옵션은 공간을 얼마나 할당할 지 / k 는 생성하는 파일 이름
sy1@ysy:~$ ls -Alh  
total 103M
-rw------- 1 sy1 sy1   35 Apr 28 18:10 .bash_history
-rw-r--r-- 1 sy1 sy1  220 Jan  7 07:34 .bash_logout
-rw-r--r-- 1 sy1 sy1 3.7K Jan  7 07:34 .bashrc
drwx------ 2 sy1 sy1 4.0K Apr 28 17:29 .cache
-rw-rw-r-- 1 sy1 sy1 103M Apr 30 07:51 k --> k 라는 파일을 새로 만들며 0.1G 로 할당해줌
-rw------- 1 sy1 sy1  356 Apr 28 18:04 .mysql_history
-rw-r--r-- 1 sy1 sy1  807 Jan  7 07:34 .profile

sy1@ysy:~$ du -sh ~
103M    /home/sy1

sy1@ysy:~$ df -lh
Filesystem      Size  Used Avail Use% Mounted on
tmpfs           196M  1.2M  195M   1% /run
/dev/sda4        12G  4.9G  6.3G  44% /
tmpfs           976M     0  976M   0% /dev/shm
tmpfs           5.0M     0  5.0M   0% /run/lock
/dev/sda2       974M  155M  752M  18% /boot
/dev/sda5       4.9G  110M  4.5G   3% /home  --> k가 /home에 110M(0.1G) 할당된 것을 확인
/dev/sda6       9.8G  2.1M  9.3G   1% /data
tmpfs           196M  4.0K  196M   1% /run/user/1000
tmpfs           196M  4.0K  196M   1% /run/user/1003
tmpfs           196M  4.0K  196M   1% /run/user/1001
tmpfs           196M  4.0K  196M   1% /run/user/1002

 

 

 


[추가실습] windows(D:\win) 폴더 /yes로 mount 해보기

윈도우 D드라이브에 win폴더 생성해 두기

ㄴ D 드라이브 에 win 폴더 생성

 

장치 -> 게스트 확장 설치

ㄴ 시스템 선택 > 설정

 

ㄴ 저장소 > 컨트롤러: IDE - 비어있음 선택 > [CD 아이콘] 클릭

 

ㄴ C:/ProgramFiles\oracle\VirtualBox > VBoxGuestAdditions.ios > [열기] 선택

 

아래 순서로 게스트 확장 설치

root@ysy:~#mount -r /dev/cdrom /media
root@ysy:~#cd /media/
root@ysy:~#./VBoxLinuxAdditions.run

 

Vbox 머신  -> 설정 -> 공유 폴더 설정(win)

ㄴ 공유 폴더 >  [폴더+] 아이콘 선택

 

ㄴ 폴더 경로, 마운트 지점, 자동 마운트 / 항상 사용하기 체크박스 체크  > 확인 선택 > 확인 선택

 

 

시스템 재시작

 

putty 로 root(j) 로그인 하여 진행

root@ysy:~# mount -r /dev/cdrom /media
root@ysy:~# cd /media/
root@ysy:/media# ./VBoxLinuxAdditions.run

 

** 추가

ㄴ repo 변경 방법

root@ysy:~# vi /etc/apt/sources.list

 

 

mount 하기

ㄴ /yes 디렉터리 생성 후 마운트

root@ysy:/media# mkdir /yes
root@ysy:/media# mount -t vboxsf win /yes

root@ysy:/media# df -h  --> windows(D:\win) 폴더 /yes로 mount 해보기
Filesystem      Size  Used Avail Use% Mounted on
tmpfs           196M  1.1M  195M   1% /run
/dev/sda4        12G  4.9G  6.3G  44% /
tmpfs           976M     0  976M   0% /dev/shm
tmpfs           5.0M     0  5.0M   0% /run/lock
/dev/sda2       974M  155M  752M  18% /boot
/dev/sda5       4.9G  110M  4.5G   3% /home
/dev/sda6       9.8G  2.1M  9.3G   1% /data
tmpfs           196M  4.0K  196M   1% /run/user/1000
/dev/sr0         52M   52M     0 100% /media
win             6.1G   28M  6.1G   1% /yes

--> 윈도우에서 txt 파일 만들고 리눅스에서 확인 가능

 

 

 


sqlite를 소스컴파일 방식으로 /sql 하기

https://sqlite.org/index.html 접속 > [Download] 선택

ㄴ Sorce Code 에서 tar 파일 우클릭 > 링크 주소 복사 

 

root@ysy:~/s# wget https://sqlite.org/2023/sqlite-autoconf-3410200.tar.gz
--2023-05-01 16:55:49--  https://sqlite.org/2023/sqlite-autoconf-3410200.tar.gz
Resolving sqlite.org (sqlite.org)... 45.33.6.223, 2600:3c00::f03c:91ff:fe96:b959
Connecting to sqlite.org (sqlite.org)|45.33.6.223|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 3125545 (3.0M) [application/x-gzip]
Saving to: ‘sqlite-autoconf-3410200.tar.gz’

sqlite-autoconf-3410 100%[===================>]   2.98M  2.26MB/s    in 1.3s

2023-05-01 16:55:51 (2.26 MB/s) - ‘sqlite-autoconf-3410200.tar.gz’ saved [3125545/3125545]

ㄴ wget 이용 : wget 뒤에 복사한 tar 파일 붙여넣기

 

root@ysy:~/s# ls
sqlite-autoconf-3410200.tar.gz
root@ysy:~/s# tar xf sqlite-autoconf-3410200.tar.gz

ㄴ tar xf  명령 이용하여 sqlite-autoconf-3410200.tar.gz 파일 묶음 해제 한 번에 하기

 

root@ysy:~/s# cd sqlite-autoconf-3410200
root@ysy:~/s/sqlite-autoconf-3410200# ./configure --prefix=/sql


--> make : Makefile을 읽어 소스 코드를 컴파일하여 실행 가능한 프로그램을 생성
    ㄴ  Makefile은 소프트웨어 프로젝트의 빌드 과정을 정의하는 파일
--> make install : "make" 명령으로 컴파일한 실행 파일과 관련 라이브러리, 헤더 파일 등을 시스템에 설치

root@ysy:~/s/sqlite-autoconf-3410200# make && make install  
Command 'make' not found, but can be installed with:  --> make 설치해줘야 함
apt install make        # version 4.3-4.1build1, or
apt install make-guile  # version 4.3-4.1build1
root@ysy:~/s# apt install make  --> make 설치
root@ysy:~/s/sqlite-autoconf-3410200# make && make install  --> 다시 시도
root@ysy:~/s/sqlite-autoconf-3410200#

ㄴ  --prefix 옵션을 사용하여 /sql  디렉터리에 sqlite 를 설치하도록 지정

ㄴ make && make install 이용하여 sqlitet 설치

 

root@ysy:~/s/sqlite-autoconf-3410200# ls /sql/bin
sqlite3

ㄴ  /sql/bin 디렉터리에 sqlite3 바이너리 파일이 생성되어 있는지 확인

 

root@ysy:~/s/sqlite-autoconf-3410200# /sql/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>

ㄴ sqlite3 데이터베이스 실행 확인

 

 

 

** 추가 >> date 시간 대 변경

ㄴ timedatectl set-timezone Asia/Seoul

root@ysy:~# date
Sun Apr 30 09:24:28 AM UTC 2023
root@ysy:~# timedatectl set-timezone Asia/Seoul
root@ysy:~# date
Sun Apr 30 06:25:48 PM KST 2023