rosieblue
article thumbnail
728x90

Background - /etc/passwd ํŒŒ์ผ

์ด ํŒŒ์ผ์—์„œ๋Š” ์‚ฌ์šฉ์ž ์ด๋ฆ„, ์•”ํ˜ธ, ๊ทธ๋ฃน ๋“ฑ์˜ ์ •๋ณด๋ฅผ ๋‹ค๋ฃฌ๋‹ค. 
tail -5 /etc/passwd ๋ช…๋ น์–ด๋กœ ํ•ด๋‹น ํŒŒ์ผ์˜ ๋งˆ์ง€๋ง‰ 5ํ–‰์„ ์ถœ๋ ฅํ•ด ๋ณด์•˜๋‹ค.

ํŒŒ์ผ ๋‚ด์šฉ์ด ์˜๋ฏธํ•˜๋Š” ๊ฒƒ์€ ๋‹ค์Œ๊ณผ ๊ฐ™๋‹ค.
์‚ฌ์šฉ์ž์ด๋ฆ„ : ์•”ํ˜ธ : UID : GID : ๊ทธ ์™ธ ์ •๋ณด : ํ™ˆ ๋””๋ ‰ํ† ๋ฆฌ : ์…ธ (UID, GID๋Š” ๊ฐ๊ฐ ์‚ฌ์šฉ์ž ์•„์ด๋””, ๊ทธ๋ฃน ์•„์ด๋””์˜ ์•ฝ์ž)
cf) adduser ๋ช…๋ น์–ด๋กœ ์‚ฌ์šฉ์ž๋ฅผ ์ถ”๊ฐ€ํ•  ๋•Œ ๋”ฐ๋กœ UID์™€ GID๋ฅผ ์„ค์ •ํ•˜์ง€ ์•Š์œผ๋ฉด ์ด์ „ ์‚ฌ์šฉ์ž์˜ ์•„์ด๋””์— +1ํ•œ ๊ฐ’์œผ๋กœ ์„ค์ •๋œ๋‹ค.

 

๊ถ๊ธˆ์ฆ

root์˜ uid, gid๊ฐ€ 0์œผ๋กœ ์„ค์ •๋˜์–ด์žˆ์Œ

์ € ํŒŒ์ผ์„ ๋ณด๋‹ค๊ฐ€ ๊ถ๊ธˆํ•ด์ง„๊ฑด๋ฐ root์˜ uid๋Š” ํ•ญ์ƒ 0์ธ๊ฒƒ ๊ฐ™๋‹ค. ํ .. ๊ทธ๋ ‡๋‹ค๋ฉด ์–˜๋Š” ๊ผญ 0์ผ๊นŒ? ์•„๋‹ˆ๋ฉด ๋ฐ”๊ฟ€ ์ˆ˜ ์žˆ์„๊นŒ? ๊ทธ๋ฆฌ๊ณ  ๊ทธ๋ƒฅ uid=0์ธ์• ๋กœ ์ ‘๊ทผํ•˜๋ฉด ๋ฃจํŠธ ๋”ฐ๋‚ธ๊ฒƒ๊ณผ ๋™์ผํ•œ ํšจ๊ณผ์ผ๊นŒ?

์Šคํƒ์˜ค๋ฒ„ํ”Œ๋กœ์šฐ์—์„œ ์ด์™€ ๊ฐ™์€ ์งˆ๋ฌธ์„ ํ•œ ์‚ฌ๋žŒ์ด ์žˆ์—ˆ๋‹ค. ๊ทธ๋ž˜์„œ ๊ฐ€์ ธ์™€๋ดค๋‹ค.

 

Does the superuser account always have uid/gid 0/0 on Linux?

Yes. As is pointed out by Rich Homolka in a comment, there's code in the kernel which explicitly checks for uid 0 when needing to check for the root user, which means that root always has at least uid 0.

 

Is the name of the user account with uid 0 always root?

No. root is just a name, listed in /etc/passwd or some other authentication store. You could just as well call the account admin, and the OS itself won't care, but some applications might not quite like it because they expect there to exist a privileged account named root. Calling the uid 0 account on a *nix root is a very strongly held convention, but it isn't required by the system (though it may be required by certain userland software, possibly including system administration utilities).

 

์ถœ์ฒ˜ : https://superuser.com/questions/626843/does-the-root-account-always-have-uid-gid-0/626845#626845

 

Does the root account always have UID/GID 0?

On all the Linux systems I've managed, the root account has a GID and UID of 0. Is this guaranteed, or is it possible that the system will give root a different ID?

superuser.com

์ฆ‰, ์ปค๋„์— uid==0์ธ์ง€ ํ™•์ธํ•˜๋Š” ์ฝ”๋“œ๊ฐ€ ์žˆ๋‹ค๊ณ  ํ•œ๋‹ค. ์ฆ‰ uid==0์ธ ์œ ์ €๋ฅผ superuser๋กœ ์ธ์‹ํ•˜๋Š” ๊ฒƒ ๊ฐ™๋‹ค.

 

๊ทธ๋Ÿฐ๋ฐ ๋ฃจํŠธ์˜ uid ๋ณ€๊ฒฝํ•  ์ˆ˜๋Š” ์žˆ์„๊นŒ? ํ•ด์„œ ๋ณ€๊ฒฝํ•ด๋ดค๋‹ค (๋ณ€๊ฒฝํ•˜์ง€๋งˆ์„ธ์š”...๋งค์šฐ ๊ท€์ฐฎ์•„์ง ใ…ˆใ…‚ใ…ˆใ…‚ใ…ˆใ…‚)

3000์œผ๋กœ ๋ฐ”๊ฟ”๋ดค๋‹ค

๊ทธ๋Ÿฐ๋ฐ....์ด๋ ‡๊ฒŒ ๋ฐ”๊พธ๊ณ  ๋‚˜๋‹ˆ๊นŒ sudo๊ฐ€ ์ ์šฉ์ด์•ˆ๋œ๋‹ค..๋งค์šฐ ๋”์ฐํ•œ ์ผ์ด ๋ฒŒ์–ด์ง ใ…‹ใ…‹

์™œ๋ƒํ•˜๋ฉด ์ปค๋„์ด uid==0์„ super user๋กœ ์ธ์‹ํ•˜๋Š”๋ฐ ์ด์ œ ๋”์ด์ƒ ์‹œ์Šคํ…œ์— uid==0์ธ ์œ ์ €๊ฐ€ ์—†๊ธฐ ๋•Œ๋ฌธ์ธ ๊ฒƒ ๊ฐ™๋‹ค... 

 

์ฐพ์•„๋ดค๋Š”๋ฐ ๋‚˜๊ฐ™์€ ์ง“์„ ํ•œ ์‚ฌ๋žŒ๋“ค์ด ๋‘ ๋ช…์ •๋„ ์žˆ์—ˆ๋‹ค,, (๊ทธ๋‚˜๋งˆ ์ฐพ์€๊ฒŒ 2๋ช…์ž„ ์•„๋ฌด๋„ ์ด๋Ÿฐ ์ง“ ์•ˆํ•œ๋“ฏ..)

https://superuser.com/questions/1223133/changed-root-uid-in-ubuntu

 

changed root UID in ubuntu

I was tinkering with the /etc/passwd file when accidentaly changed the root UID and GID. When I enter into the recovery mode, I still have no superuser powers, as any user exists on the passwd file...

superuser.com

ํ .. ๊ทธ๋Ÿฐ๋ฐ ์ €๊ธฐ์—๋Š” ์ž์„ธํžˆ ์„ค๋ช…์ด ์•ˆ๋˜์–ด์žˆ์—ˆ๋‹ค

๊ทธ๋ž˜์„œ ์˜ˆ์ „์— ๋‚ด๊ฐ€ ๋ฃจํŠธ ๋น„๋ฒˆ ์žƒ์–ด๋ฒ„๋ ธ์„ ๋•Œ ํ–ˆ๋˜ ๋ฐฉ๋ฒ•์„ ํ™œ์šฉํ–ˆ๋‹ค.

https://m.blog.naver.com/PostView.naver?isHttpsRedirect=true&blogId=wnstj7798&logNo=221929001805 

๊ทธ๋žฌ๋”๋‹ˆ ๋‹ค์‹œ ์ •์ƒ์ ์œผ๋กœ sudo๊ฐ€ ๋จนํ˜”๋‹ค...ใ…œใ…œ
 (๋ฃจํŠธ pid๋ฅผ ์ง€๊ธˆ์ฒ˜๋Ÿผ ์ด์ƒํ•œ๊ฑธ๋กœ ๋ฐ”๊ฟ”์„œ ๋จนํ†ต๋˜๊ฒŒ ํ•˜๋Š”๊ฒƒ๋„..์–ด์ฉŒ๋ฉด ํ•ดํ‚น์ ์œผ๋กœ ๊ดœ์ฐฎ์„์ง€๋„?)

 

์•„๋ฌดํŠผ ๋˜ ๊ถ๊ธˆํ•œ๊ฒŒ ์ƒ๊ฒผ๋Š”๋ฐ, ์–ด๋–ค ์œ ์ €์˜ uid๋ฅผ 0์œผ๋กœ ์„ธํŒ…ํ•˜๋ฉด ์–ด๋–ป๊ฒŒ๋ ๊นŒ? -> ๊ทธ๋ž˜์„œ ์ œ๊ฐ€ ํ•ด๋ดค์Šต๋‹ˆ๋‹ค

(ํ˜น์‹œ ๋ชฐ๋ผ ์ƒˆ๋กœ์šด ์œ ์ €๋ฅผ ๋งŒ๋“ค๊ณ  ์–˜๋กœ ์ง„ํ–‰ํ–ˆ์Œ)

์˜ค ๊ทธ๋Ÿฐ๋ฐ UID 0์ด ๋‘๋ช… ์ด์ƒ ์žˆ๋‹ค๊ณ  ํ•ด์„œ ์•ˆ๋œ๋‹ค๊ณ  ๋–ด๋‹ค! ->๋ณด์•ˆ์ ์œผ๋กœ root ๋ง๊ณ  ๋‹ค๋ฅธ ์œ ์ €๊ฐ€ UID 0 ๊ฐ€์ง€๋Š” ๊ฒƒ์„ ๋ฐฉ์ง€ํ•˜๋Š” ๊ฒƒ ๊ฐ™๋‹ค ~!ใ…Žใ…Ž ์—ญ์‹œ ๋˜‘๋˜‘์ด ๋ฆฌ๋ˆ…์Šค!

 

๊ทธ๋ž˜์„œ ์ด์™€ ๊ด€๋ จํ•œ ๊ธ€์ด ์žˆ๋Š”์ง€ ์ฐพ์•„๋ดค๋‹ค.

https://skynarciss.tistory.com/87

 

[Linux ๋ณด์•ˆ] ๋ฆฌ๋ˆ…์Šค ๊ณ„์ •๊ด€๋ฆฌ - root ์ด์™ธ์˜ UID๊ฐ€ '0' ๊ธˆ์ง€

[Linux ๋ณด์•ˆ] ๋ฆฌ๋ˆ…์Šค ๊ณ„์ •๊ด€๋ฆฌ - root ์ด์™ธ์˜ UID๊ฐ€ '0' ๊ธˆ์ง€ โ–  ๋Œ€์ƒ OS : SunOS, Linux, AIX, HP-UX โ–  ์ทจ์•ฝ์  ๊ฐœ์š” - root(UID=0)์™€ ๋™์ผํ•œ *UID(User Identification)๋ฅผ ๊ฐ€์ง„ ๊ณ„์ • ์กด์žฌ ์‹œ root ๊ถŒํ•œ์œผ๋กœ ์‹œ์Šคํ…œ ์ ‘๊ทผ์ด

skynarciss.tistory.com

https://reddb.tistory.com/12

 

(๋ฆฌ๋ˆ…์Šค ์„œ๋ฒ„ ๋ณด์•ˆ) 2. root ๊ณ„์ • ์™ธ์— UID์™€ GID๊ฐ€ 0์ธ ๊ณ„์ •์ด ์—†๋Š”์ง€ ์ ๊ฒ€

๋ฆฌ๋ˆ…์Šค ์„œ๋ฒ„ ์ทจ์•ฝ์  ๋ณด์•ˆ ์ทจ์•ฝ์  ์ ๊ฒ€ํ•ญ๋ชฉ: 2. root ๊ณ„์ • ์™ธ์— UID์™€ GID๊ฐ€ 0์ธ ๊ณ„์ •์ด ์—†๋Š”์ง€ ์ ๊ฒ€ ์ทจ์•ฝ์  ์ ๊ฒ€๊ธฐ์ค€ - ์–‘ํ˜ธ๊ธฐ์ค€: root ๊ณ„์ •๊ณผ ๋™์ผํ•œ UID๋ฅผ ๊ฐ–๋Š” ๊ณ„์ •์ด ์กด์žฌํ•˜์ง€ ์•Š๋Š” ๊ฒฝ์šฐ ์–‘ํ˜ธํ•ฉ๋‹ˆ๋‹ค

reddb.tistory.com

 

์˜ค์˜น ์œ„ ๊ธ€์—๋„ ์ž˜ ์„ค๋ช…๋˜์–ด์žˆ์—ˆ๋‹ค!! ์˜ค๋Š˜ ์•Œ์•„๋‚ธ ๊ฒƒ์„ ์•„๋ž˜์— ์ •๋ฆฌํ•ด๋ณด์•„๋”ฐ ใ…Žใ…Žใ…Žใ…Ž

์ •๋ฆฌ

  • UID๊ฐ€ 0์ด๋ฉด superuser๋กœ ์ธ์‹๋œ๋‹ค(๊ทธ๋ž˜์„œ root์˜ uid๊ฐ€ 0์ด๋‹ค)
  • ์ปค๋„์—์„œ UID๊ฐ€ 0์ธ์ง€ ํ™•์ธํ•˜๋Š” ์ฝ”๋“œ๊ฐ€ ์žˆ๋‹ค
  • ๋งŒ์•ฝ root์˜ uid๋ฅผ 0์ด ์•„๋‹Œ ๋‹ค๋ฅธ ์ˆ˜๋กœ ๋ฐ”๊พธ์–ด์„œ(๋ฐ”๊ฟ€ ์ˆ˜๋Š” ์žˆ์Œ) ์•„๋ฌด๋„ UID๊ฐ€ 0์ด ์•„๋‹ˆ๋ผ๋ฉด, ์•„๋ฌด๋„ superuser ๊ถŒํ•œ์„ ์“ธ ์ˆ˜ ์—†๊ฒŒ๋œ๋‹ค
  • ๋ฆฌ๋ˆ…์Šค์—์„œ๋Š” ๋ณด์•ˆ์„ ์œ„ํ•ด UID๊ฐ€ 0์ธ ๊ณ„์ •์ด ์˜ค์ง 'ํ•˜๋‚˜'์ธ์ง€ ๊ฒ€์‚ฌํ•œ๋‹ค
profile

rosieblue

@Rosieblue

ํฌ์ŠคํŒ…์ด ์ข‹์•˜๋‹ค๋ฉด "์ข‹์•„์š”โค๏ธ" ๋˜๋Š” "๊ตฌ๋…๐Ÿ‘๐Ÿป" ํ•ด์ฃผ์„ธ์š”!