본문 바로가기

ETC/자격증

[리눅스마스터]제1501회 리눅스마스터 1급 2차 시험 단답식 풀이 1

반응형

1. 다음과 같이 사용자를 생성한 후 해당 정보를 변경하려 한다. ( 괄호 ) 안에 알맞은 옵션을 적으시오.

# useradd ( ① ) sysadmin test7
# usermod ( ② ) /bin/sh ( ③ ) admin test7

<조 건>
- test7 사용자를 sysadmin에 2차 그룹으로 포함되도록 생성한다.
- 생성된 test7 사용자의 2차 그룹을 admin으로 변경하고, 기본 로그인 셸은 /bin/sh로 변경한다.

 

<useradd 주요 옵션>

-u : 사용자의 UID 값을 지정
-d : 홈 디렉터리를 지정
-g : 기본 그룹을 지정
-G : 기본 그룹이외에 추가로 그룹에 속하게 할 경우에 쓴다.

 

<usermod 주요 옵션>

-l : 사용자의 아이디를 변경
-s : 사용자의 Shell 을 변경
-e : 만기 일자를 지정하거나 변경
-c : 사용자의 설명을 변경
-G : 부그룹 설정을 지정하거나 변경
-d : 사용자의 홈 디렉터리를 변경. 단, 변경할 디렉터리는 미리 생성되어야 한다.
-m : 사용자의 홈디렉터리 변경시 기존에 사용하던 파일 및 디렉터리를 옮겨주는 옵션
-e : 계정만기일을 변경한다. YYYY-MM-DD 또는 MM/DD/YY 형태로 지정

 

[root@server1 ~]# useradd -help
Usage: useradd [options] LOGIN
       useradd -D
       useradd -D [options]

Options:
  -b, --base-dir BASE_DIR       base directory for the home directory of the
                                new account
  -c, --comment COMMENT         GECOS field of the new account
  -d, --home-dir HOME_DIR       home directory of the new account
  -D, --defaults                print or change default useradd configuration
  -e, --expiredate EXPIRE_DATE  expiration date of the new account
  -f, --inactive INACTIVE       password inactivity period of the new account
  -g, --gid GROUP               name or ID of the primary group of the new
                                account
  -G, --groups GROUPS           list of supplementary groups of the new
                                account
  -h, --help                    display this help message and exit
  -k, --skel SKEL_DIR           use this alternative skeleton directory
  -K, --key KEY=VALUE           override /etc/login.defs defaults
  -l, --no-log-init             do not add the user to the lastlog and
                                faillog databases
  -m, --create-home             create the user's home directory
  -M, --no-create-home          do not create the user's home directory
  -N, --no-user-group           do not create a group with the same name as
                                the user
  -o, --non-unique              allow to create users with duplicate
                                (non-unique) UID
  -p, --password PASSWORD       encrypted password of the new account
  -r, --system                  create a system account
  -R, --root CHROOT_DIR         directory to chroot into
  -s, --shell SHELL             login shell of the new account
  -u, --uid UID                 user ID of the new account
  -U, --user-group              create a group with the same name as the user
  -Z, --selinux-user SEUSER     use a specific SEUSER for the SELinux user mapping
-G, --groups GROUP1[,GROUP2,...[,GROUPN]]]
    A list of supplementary groups which the user is also a member of. Each group is separated from the
    next by a comma, with no intervening whitespace. The groups are subject to the same restrictions as
    the group given with the -g option. The default is for the user to belong only to the initial group.

 

[root@server1 ~]# usermod -help
Usage: usermod [options] LOGIN

Options:
  -c, --comment COMMENT         new value of the GECOS field
  -d, --home HOME_DIR           new home directory for the user account
  -e, --expiredate EXPIRE_DATE  set account expiration date to EXPIRE_DATE
  -f, --inactive INACTIVE       set password inactive after expiration
                                to INACTIVE
  -g, --gid GROUP               force use GROUP as new primary group
  -G, --groups GROUPS           new list of supplementary GROUPS
  -a, --append                  append the user to the supplemental GROUPS
                                mentioned by the -G option without removing
                                him/her from other groups
  -h, --help                    display this help message and exit
  -l, --login NEW_LOGIN         new value of the login name
  -L, --lock                    lock the user account
  -m, --move-home               move contents of the home directory to the
                                new location (use only with -d)
  -o, --non-unique              allow using duplicate (non-unique) UID
  -p, --password PASSWORD       use encrypted password for the new password
  -R, --root CHROOT_DIR         directory to chroot into
  -s, --shell SHELL             new login shell for the user account
  -u, --uid UID                 new UID for the user account
  -U, --unlock                  unlock the user account
  -Z, --selinux-user SEUSER     new SELinux user mapping for the user account
-s, --shell SHELL
    The name of the user's new login shell. Setting this field to blank causes the system to select the
    default login shell.
-G, --groups GROUP1[,GROUP2,...[,GROUPN]]]
    A list of supplementary groups which the user is also a member of. Each group is separated from the
    next by a comma, with no intervening whitespace. The groups are subject to the same restrictions as
    the group given with the -g option.

    If the user is currently a member of a group which is not listed, the user will be removed from the
    group. This behaviour can be changed via the -a option, which appends the user to the current
    supplementary group list.

 

① -G

② -s

③ -G

 

2. 다음은 리눅스에서 파티션 테이블을 변경 하는 내용이다. ( 괄호 ) 안에 알맞은 내용을 적으시오.

# fdisk /dev/sda
Command (m for help): ( ① )
Partition number (1-6): 5
Hex code (type L to list codes): ( ② )

<조 건>
- 파티션 number 5번은 이미 생성되어 있다.
- 생성된 파티션을 LVM 시스템 ID 로 변경한다

 

[root@server1 ~]# fdisk /dev/sda
Welcome to fdisk (util-linux 2.23.2).

Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.


Command (m for help): help
h: unknown command
Command action
   a   toggle a bootable flag
   b   edit bsd disklabel
   c   toggle the dos compatibility flag
   d   delete a partition
   g   create a new empty GPT partition table
   G   create an IRIX (SGI) partition table
   l   list known partition types
   m   print this menu
   n   add a new partition
   o   create a new empty DOS partition table
   p   print the partition table
   q   quit without saving changes
   s   create a new empty Sun disklabel
   t   change a partition's system id
   u   change display/entry units
   v   verify the partition table
   w   write table to disk and exit
   x   extra functionality (experts only)

 

t   change a partition's system id

 

Command (m for help): l

 0  Empty           24  NEC DOS         81  Minix / old Lin bf  Solaris
 1  FAT12           27  Hidden NTFS Win 82  Linux swap / So c1  DRDOS/sec (FAT-
 2  XENIX root      39  Plan 9          83  Linux           c4  DRDOS/sec (FAT-
 3  XENIX usr       3c  PartitionMagic  84  OS/2 hidden C:  c6  DRDOS/sec (FAT-
 4  FAT16 <32M      40  Venix 80286     85  Linux extended  c7  Syrinx
 5  Extended        41  PPC PReP Boot   86  NTFS volume set da  Non-FS data
 6  FAT16           42  SFS             87  NTFS volume set db  CP/M / CTOS / .
 7  HPFS/NTFS/exFAT 4d  QNX4.x          88  Linux plaintext de  Dell Utility
 8  AIX             4e  QNX4.x 2nd part 8e  Linux LVM       df  BootIt
 9  AIX bootable    4f  QNX4.x 3rd part 93  Amoeba          e1  DOS access
 a  OS/2 Boot Manag 50  OnTrack DM      94  Amoeba BBT      e3  DOS R/O
 b  W95 FAT32       51  OnTrack DM6 Aux 9f  BSD/OS          e4  SpeedStor
 c  W95 FAT32 (LBA) 52  CP/M            a0  IBM Thinkpad hi eb  BeOS fs
 e  W95 FAT16 (LBA) 53  OnTrack DM6 Aux a5  FreeBSD         ee  GPT
 f  W95 Ext'd (LBA) 54  OnTrackDM6      a6  OpenBSD         ef  EFI (FAT-12/16/
10  OPUS            55  EZ-Drive        a7  NeXTSTEP        f0  Linux/PA-RISC b
11  Hidden FAT12    56  Golden Bow      a8  Darwin UFS      f1  SpeedStor
12  Compaq diagnost 5c  Priam Edisk     a9  NetBSD          f4  SpeedStor
14  Hidden FAT16 <3 61  SpeedStor       ab  Darwin boot     f2  DOS secondary
16  Hidden FAT16    63  GNU HURD or Sys af  HFS / HFS+      fb  VMware VMFS
17  Hidden HPFS/NTF 64  Novell Netware  b7  BSDI fs         fc  VMware VMKCORE
18  AST SmartSleep  65  Novell Netware  b8  BSDI swap       fd  Linux raid auto
1b  Hidden W95 FAT3 70  DiskSecure Mult bb  Boot Wizard hid fe  LANstep
1c  Hidden W95 FAT3 75  PC/IX           be  Solaris boot    ff  BBT

 

① t

② 8e

 

3. 다음은 실행 중인 프로세스에 대한 내용이다. ( 괄호 ) 안에 알맞은 내용을 적으시오.

# ps -l
F S UID PID PPID C PRI NI ADDR SZ WCHAN TTY TIME CMD
4 S 501 4305 4304 0 75 0 - 1350 wait4 pts/0 00:00:00 bash
# ( ① ) ( ② ) 4305
# ps -l
F S UID PID PPID C PRI NI ADDR SZ WCHAN TTY TIME CMD
4 S 501 4305 4304 0 85 10 - 1350 wait4 pts/0 00:00:00 bash

<조 건>
- 실행 중인 프로세스에 대하여 우선순위를 변경한다.
- 해당 프로세스의 우선순위를 10만큼 낮춘다.

 

renice : 실행중인 프로세스의 우선순위를 변경할때 사용하는 명령 / PID, 사용자 이름, 프로세스의 GID를 사용

 

<주요 옵션>

-p : PID를 지정하는 옵션(기본값)
-u : 사용자 이름을 지정하는 옵션
-g : 프로세스의 그룹 ID를 지정하는 옵션

 

[root@server1 ~]# renice -help

Usage:
 renice [-n] <priority> [-p|--pid] <pid>...
 renice [-n] <priority>  -g|--pgrp <pgid>...
 renice [-n] <priority>  -u|--user <user>...

Options:
 -g, --pgrp <id>        interpret argument as process group ID
 -n, --priority <num>   specify the nice increment value
 -p, --pid <id>         interpret argument as process ID (default)
 -u, --user <name|id>   interpret argument as username or user ID
 -h, --help             display help text and exit
 -V, --version          display version information and exit

For more information see renice(1).

 

SYNOPSIS
       renice [-n] priority [-gpu] identifier...

 

① renice

② 10

반응형