It seems to be a famous book so I bought it <a target="_blank" href="https://www.amazon.co.jp/gp/product/4797328355/ref=as_li_tl?ie=UTF8&camp=247&creative=1211&creativeASIN=4797328355&linkCode=as2&tag=lespacetranqu-22&linkId=b690c3257ff896f2239f1107e > Ordinary Linux programming The royal road of gcc programming that can be learned from the mechanism of Linux <img src = "// ir-jp.amazon-adsystem.com/e/ir?t=lespacetranqu-22&l=am2&o=9&a=4797328355" "width =" 1 "height =" 1 "border =" 0 "alt =" "style =" border: none! Important; margin: 0px! Important; "/> <a target="_blank" href="https://www.amazon.co.jp/gp/product/B075ST51Y5/ref=as_li_tl?ie=UTF8&camp=247&creative=1211&creativeASIN=B075ST51Y5&linkCode=as2&tag=lespacetranqu-22&linkId=aa0915aa60a5a > Ordinary Linux programming 2nd edition: The royal road of gcc programming that can be learned from the mechanism of Linux <img src = "// ir-jp.amazon-adsystem.com/e/ir?t=lespacetranqu-22&l=am2&o=" 9 & a = B075ST51Y5 "width =" 1 "height =" 1 "border =" 0 "alt =" "style =" border: none! Important; margin: 0px! Important; "/>
Try normal Linux programming Part 1 https://qiita.com/uturned0/items/b9ae846f2aff5865c074 Try normal Linux programming Part 2 https://qiita.com/uturned0/items/56beac990cdd6f1059ed Try normal Linux programming Part 3 https://qiita.com/uturned0/items/675092da8aa89c4b1ff0 Part 4 https://qiita.com/uturned0/items/8f5765cfc0f0be8a1981 Part 5 https://qiita.com/uturned0/items/ab97deb489c994a836da
Chapter 4
Think of directory as "a file that records information about other files"
If directory is -x, it cannot be accessed regardless of the file permissions in it. Basically, dir is always + x You can't just have + r
Is that so? I tried chmod 644, but I could see the file list in dir normally. The file inside cannot read anything. You can see the file list if you have r. But the contents of the file itself cannot be seen without x. Ah, is that so? So be.
Accessed by user A = Accessed by process of user A. Since process acts for user A, it is called a credential or credential. I'm a certificate that works with the permission of user A. Police notebook.
I am making a process at login. The credit encials are copied to the child process.
If it is centos, bash will start at login. It's quick to see. Let the user name be tanuki
.
$ pstree -u tanuki
git-credential-
sshd───bash───tail <--------This is a parent-child relationship
bash
What's interesting about this is that sshd is started by root and has become a child user just before bash after login.
$ ps -aef --forest -u tanuki
root 119287 1 0 Jul20 ? 00:00:00 /usr/sbin/sshd -D
root 37261 119287 0 22:42 ? 00:00:00 \_ sshd: tanuki [priv]
tanuki 37265 37261 0 22:42 ? 00:00:00 \_ sshd: tanuki@pts/0
tanuki 37266 37265 0 22:42 pts/0 00:00:00 \_ -bash
tanuki 37335 37266 0 22:42 pts/0 00:00:00 \_ tail -f /var/log/messages
For the time being, whatever tanuki does after this, he basically creates a process with tanuki's credits.
tty = Teletype = A terminal that can now input / output (display) An era when computers have no monitors or keyboards Input is printed on paper tape, output is printed on paper with a printer Character terminal = An era in which a keyboard is attached but the screen is like a straight line 8 of a digital clock (level before resolution) What became like a liquid crystal display Software simulation of the terminal Even if it evolves, all tty = terminal Terminal with key input and screen set
console and terminal have almost the same meaning
linux has a virtual console. It can be switched with ctrl + alt + F1 ~ 6.
However, access must be done from a physical machine, not remotely. You can't do it with ssh.
https://qiita.com/Kernel_OGSun/items/bdccbe8bc4092f33b43e
ASCII character code has mysterious characters other than a-z 0-9
DEL, BS, LF, TAB, etc. Used to operate the character terminal. Characters are displayed with a character code like a-Z, but BS erased the characters. Although it is a character code, it contains an instruction code! It was just a table of what to do when this came. Things that aren't just for letters have come to be used that way. Hey.
The centos I'm using now had 64 ttys and 4 ttyS.
$ ll /dev/tty*
crw-rw-rw- 1 root tty 5, 0 2020-11-04 09:34:24 /dev/tty
crw--w---- 1 root tty 4, 0 2020-07-16 18:30:24 /dev/tty0
crw--w---- 1 root tty 4, 1 2020-07-16 18:30:32 /dev/tty1
crw--w---- 1 root tty 4, 10 2020-07-16 18:30:24 /dev/tty10
crw--w---- 1 root tty 4, 11 2020-07-16 18:30:24 /dev/tty11
crw--w---- 1 root tty 4, 12 2020-07-16 18:30:24 /dev/tty12
crw--w---- 1 root tty 4, 13 2020-07-16 18:30:24 /dev/tty13
crw--w---- 1 root tty 4, 14 2020-07-16 18:30:24 /dev/tty14
crw--w---- 1 root tty 4, 15 2020-07-16 18:30:24 /dev/tty15
crw--w---- 1 root tty 4, 16 2020-07-16 18:30:24 /dev/tty16
crw--w---- 1 root tty 4, 17 2020-07-16 18:30:24 /dev/tty17
crw--w---- 1 root tty 4, 18 2020-07-16 18:30:24 /dev/tty18
crw--w---- 1 root tty 4, 19 2020-07-16 18:30:24 /dev/tty19
crw--w---- 1 root tty 4, 2 2020-07-16 18:30:24 /dev/tty2
crw--w---- 1 root tty 4, 20 2020-07-16 18:30:24 /dev/tty20
crw--w---- 1 root tty 4, 21 2020-07-16 18:30:24 /dev/tty21
crw--w---- 1 root tty 4, 22 2020-07-16 18:30:24 /dev/tty22
crw--w---- 1 root tty 4, 23 2020-07-16 18:30:24 /dev/tty23
crw--w---- 1 root tty 4, 24 2020-07-16 18:30:24 /dev/tty24
crw--w---- 1 root tty 4, 25 2020-07-16 18:30:24 /dev/tty25
crw--w---- 1 root tty 4, 26 2020-07-16 18:30:24 /dev/tty26
crw--w---- 1 root tty 4, 27 2020-07-16 18:30:24 /dev/tty27
crw--w---- 1 root tty 4, 28 2020-07-16 18:30:24 /dev/tty28
crw--w---- 1 root tty 4, 29 2020-07-16 18:30:24 /dev/tty29
crw--w---- 1 root tty 4, 3 2020-07-16 18:30:24 /dev/tty3
crw--w---- 1 root tty 4, 30 2020-07-16 18:30:24 /dev/tty30
crw--w---- 1 root tty 4, 31 2020-07-16 18:30:24 /dev/tty31
crw--w---- 1 root tty 4, 32 2020-07-16 18:30:24 /dev/tty32
crw--w---- 1 root tty 4, 33 2020-07-16 18:30:24 /dev/tty33
crw--w---- 1 root tty 4, 34 2020-07-16 18:30:24 /dev/tty34
crw--w---- 1 root tty 4, 35 2020-07-16 18:30:24 /dev/tty35
crw--w---- 1 root tty 4, 36 2020-07-16 18:30:24 /dev/tty36
crw--w---- 1 root tty 4, 37 2020-07-16 18:30:24 /dev/tty37
crw--w---- 1 root tty 4, 38 2020-07-16 18:30:24 /dev/tty38
crw--w---- 1 root tty 4, 39 2020-07-16 18:30:24 /dev/tty39
crw--w---- 1 root tty 4, 4 2020-07-16 18:30:24 /dev/tty4
crw--w---- 1 root tty 4, 40 2020-07-16 18:30:24 /dev/tty40
crw--w---- 1 root tty 4, 41 2020-07-16 18:30:24 /dev/tty41
crw--w---- 1 root tty 4, 42 2020-07-16 18:30:24 /dev/tty42
crw--w---- 1 root tty 4, 43 2020-07-16 18:30:24 /dev/tty43
crw--w---- 1 root tty 4, 44 2020-07-16 18:30:24 /dev/tty44
crw--w---- 1 root tty 4, 45 2020-07-16 18:30:24 /dev/tty45
crw--w---- 1 root tty 4, 46 2020-07-16 18:30:24 /dev/tty46
crw--w---- 1 root tty 4, 47 2020-07-16 18:30:24 /dev/tty47
crw--w---- 1 root tty 4, 48 2020-07-16 18:30:24 /dev/tty48
crw--w---- 1 root tty 4, 49 2020-07-16 18:30:24 /dev/tty49
crw--w---- 1 root tty 4, 5 2020-07-16 18:30:24 /dev/tty5
crw--w---- 1 root tty 4, 50 2020-07-16 18:30:24 /dev/tty50
crw--w---- 1 root tty 4, 51 2020-07-16 18:30:24 /dev/tty51
crw--w---- 1 root tty 4, 52 2020-07-16 18:30:24 /dev/tty52
crw--w---- 1 root tty 4, 53 2020-07-16 18:30:24 /dev/tty53
crw--w---- 1 root tty 4, 54 2020-07-16 18:30:24 /dev/tty54
crw--w---- 1 root tty 4, 55 2020-07-16 18:30:24 /dev/tty55
crw--w---- 1 root tty 4, 56 2020-07-16 18:30:24 /dev/tty56
crw--w---- 1 root tty 4, 57 2020-07-16 18:30:24 /dev/tty57
crw--w---- 1 root tty 4, 58 2020-07-16 18:30:24 /dev/tty58
crw--w---- 1 root tty 4, 59 2020-07-16 18:30:24 /dev/tty59
crw--w---- 1 root tty 4, 6 2020-07-16 18:30:24 /dev/tty6
crw--w---- 1 root tty 4, 60 2020-07-16 18:30:24 /dev/tty60
crw--w---- 1 root tty 4, 61 2020-07-16 18:30:24 /dev/tty61
crw--w---- 1 root tty 4, 62 2020-07-16 18:30:24 /dev/tty62
crw--w---- 1 root tty 4, 63 2020-07-16 18:30:24 /dev/tty63
crw--w---- 1 root tty 4, 7 2020-07-16 18:30:24 /dev/tty7
crw--w---- 1 root tty 4, 8 2020-07-16 18:30:24 /dev/tty8
crw--w---- 1 root tty 4, 9 2020-07-16 18:30:24 /dev/tty9
crw--w---- 1 root tty 4, 64 2020-07-16 18:30:32 /dev/ttyS0
crw-rw---- 1 root dialout 4, 65 2020-07-16 18:30:23 /dev/ttyS1
crw-rw---- 1 root dialout 4, 66 2020-07-16 18:30:23 /dev/ttyS2
crw-rw---- 1 root dialout 4, 67 2020-07-16 18:30:23 /dev/ttyS3
ttyS * is root: dialout. Otherwise root: tty. The number seems to be fixed.
The first virtual console was / dev / tty0. / Dev / ttyS0 was for Rs-232C Historically, it was all for connecting terminals. Was unix used in the image of physically connecting 64 pieces?
When I thought something was wrong, my ssh was different
$ tty
/dev/pts/1
There was a device file that changed in number depending on the number of connections.
$ ll /dev/pts/*
crw--w---- 1 usera tty 136, 0 2020-11-04 23:09:36 /dev/pts/0
crw--w---- 1 usera tty 136, 1 2020-11-04 23:09:44 /dev/pts/1
crw--w---- 1 root tty 136, 2 2020-11-04 22:43:36 /dev/pts/2
c--------- 1 root root 5, 2 2020-07-16 18:30:22 /dev/pts/ptmx
keyboard-> (enter kernel)-> terminal driver-> (exit kernel)->
The terminal becomes one file, just a device, a process as a stream, ringing as visible to the file system
The shell is probably just a stream that receives a stream from the terminal (keyboard) and executes it. Returns $ or something only if the stream is connected to the terminal
finished chapter 4
Recommended Posts