SlideShare a Scribd company logo
Shota Ito
About the linux system
ABOUT THE LINUX SYSTEM
Promise
▸ Today I can not reach the kernel itself…
▸ Talking about today is very difficult :(

And I do not know too many things.

It is normal not to understand.
▸ An old programmer may understand from the experience of
writing C.
▸ The theme is too large so it is about the summary.
▸ If there are people who are interested please listen individually :)
ABOUT THE LINUX SYSTEM
What is Linux ?
Linux is a name which broadly denotes a family of free and open-
source software operating system distributions built around the Linux
kernel.
Wikipedia
Kernel
Device
Device driver
Thread
scheduler File system Network stack Virtual memory
System call
User Layer
Kernel Layer
System library
Database
Application
ABOUT THE LINUX SYSTEM
What is system library
Kernel
Device
Device driver
Thread
scheduler File system Network stack Virtual memory
System call
User Layer
Kernel Layer
System library
Database
Application
ABOUT THE LINUX SYSTEM
What is system library ?
▸ Famous library is glibc(GNU C Library)
▸ Forexample, php and java is using glibc
▸ and more openldap-devel.x86_64, openssl-
devel.x86_64, zlib-devel.x86_64…etc
ABOUT THE LINUX SYSTEM
Example: php code

(https://github.com/php/php-src)
ABOUT THE LINUX SYSTEM
mysqli.c
ABOUT THE LINUX SYSTEM
zend_alloc.h
ABOUT THE LINUX SYSTEM
zend_alloc.h
ABOUT THE LINUX SYSTEM
What is system call
Kernel
Device
Device driver
Thread
scheduler File system Network stack Virtual memory
System call
User Layer
Kernel Layer
System library
Database
Application
ABOUT THE LINUX SYSTEM
What is system call ?
▸ System call is the interface between the application and
the kernel.
▸ Why need system call?
▸ The authority is too large for direct hardware control.
▸ ex)get the memory! open the socket because i want to
correspond! fork the process!…etc
ABOUT THE LINUX SYSTEM
What system calls are there ?
▸ read/write: Using a file descriptor, read the byte and place it
in buffer.
▸ malloc:Call it when get memory
▸ clone(fork):Call it when fork the process
▸ getsockname:Call it when get socket name
▸ accept,accept4 : Call it when accept connection
ABOUT THE LINUX SYSTEM
Watch system call for apache httpd
▸ Get all call

# strace $(for pid in `pgrep httpd`;do echo -n "-p $pid ";done)
▸ Get getsockname,accept,accept4

# strace $(for pid in `pgrep httpd`;do echo -n "-p $pid ";done) -e
trace=getsockname,accept,accept4
▸ for using grep

strace $(for pid in `pgrep httpd`;do echo -n "-p $pid ";done)
2>&1 | grep ‘192.168.120.129'
▸ What happens if I disconnect the connection with iptables ?
ABOUT THE LINUX SYSTEM
TIPS: How pipe works
▸ What do you often use “|” ?
ABOUT THE LINUX SYSTEM
TIPS: Check the pipe works
▸ ex:$ cat hoge.txt | grep ito
▸ Chase ”cat | grep ito” at the system call level
▸ strace -p `pgrep cat`
▸ strace -p `pgrep grep`
▸ lsof -p `pgrep cat`
▸ lsof -p `pgrep grep`
ABOUT THE LINUX SYSTEM
ABOUT THE LINUX SYSTEM
TIPS: Explanation
CAT
PROCESS
GREP
PROCESS
The ring buffer provided by the kernel
/DEV/PTS/0
PROCESS
pipe:[412981]
①Read file descriptor 0(entity:/dev/pts/0)

read(0, “hoge¥n”, 65536)
②Write file descriptor1(entiry:pipe:[412981])

write(1, “hoge¥n”, 5)
③Read file descriptor0(entity:pipe:[412981])

read(0, “hoge¥n”, 32768)
about write call
about read call
about ring buffer
about file descriptor
ABOUT THE LINUX SYSTEM
Talk of the kernel so finish : )
ABOUT THE LINUX SYSTEM
How does this knowledge help?
ABOUT THE LINUX SYSTEM
Pre-release performance troubleshooting (true story…
WEB APP
▸ I do not really understand something, but it's late! Investigate!
DBLB
HOW MUCH IS THE RESPONSE
RETURNED? WHAT'S THE ERROR?
NO PROBLEM
APPLICATION RESPONSE & ERROR SEEMS TO BE
PROBLEMATIC?
RESPONSE IS NOT ON !!
IS NOT DB HEAVY ?
NO PROBLEM
ABOUT THE LINUX SYSTEM
APP
▸ Taking the system call graph of the application, it took about
40% to read the encryption processing library.
▸ Tell application developers to solve them by reviewing the
encryption algorithm.
WHILE ACQUIRING THE SYSTEM CALL, CHECK THE
CONTENTS WITH LOAD.
参考:CPU Flame Graphs
Pre-release performance troubleshooting (true story…
ABOUT THE LINUX SYSTEM
Understand what is going on
参考:Linux Performance Tools
ABOUT THE LINUX SYSTEM
Performance tuning
▸ Since it is communicating with socket, it is better to
increase the file descriptor
▸ Will you leave the cache management of the database to
OS or application?
▸ High CPU utilization!
▸ User land? Kernel land? Context switch?
ABOUT THE LINUX SYSTEM
Reference
ABOUT THE LINUX SYSTEM
Reference
▸ Linux Networking Architecture
▸ gdb Debugging Full Example (Tutorial): ncurses
ABOUT THE LINUX SYSTEM
Q&A
▸ Which layer captures packets captured from tcpdump?
▸ Get data from the device driver.
引用:Linux Network Internals

More Related Content

ODP
Testing Wi-Fi with OSS Tools
PPTX
BackTrack 4 R2 - SFISSA Presentation
PPTX
Dock ir incident response in a containerized, immutable, continually deploy...
PDF
XFLTReat: a new dimension in tunnelling
PDF
Modern Reconnaissance Phase on APT - protection layer
PPTX
Find the Hacker
PPTX
How to Secure Containers
PPTX
Linux networking
Testing Wi-Fi with OSS Tools
BackTrack 4 R2 - SFISSA Presentation
Dock ir incident response in a containerized, immutable, continually deploy...
XFLTReat: a new dimension in tunnelling
Modern Reconnaissance Phase on APT - protection layer
Find the Hacker
How to Secure Containers
Linux networking

What's hot (20)

PDF
Behavioural activity monitoring on CoreOS with Sysdig Falco
PPTX
Metasploit for Web Workshop
PDF
Intro to Python programming and iPython
PDF
UNIX Basics and Cluster Computing
PDF
"A rootkits writer’s guide to defense" - Michal Purzynski
ODP
Stealthy, Hypervisor-based Malware Analysis
PDF
"Into the Fog The Return of ICEFOG APT" - Chi en (Ashley) Shen
PPTX
The Art of Exploiting Unconventional Use-after-free Bugs in Android Kernel by...
PDF
Kali tools list with short description
PDF
DefCon 2012 - Rooting SOHO Routers
PPTX
Vulnerability, exploit to metasploit
PPT
Linux Virus
PDF
[English] BackBox Linux and Metasploit: A practical demonstration of the Shel...
PDF
Rihards Olups - Encrypting Daemon Traffic With Zabbix 3.0
PDF
WTF my container just spawned a shell!
PPTX
Designing Tracing Tools
PDF
BlueHat v17 || Disrupting the Mirai Botnet
PPTX
BackTrack5 - Linux
PDF
LibreSSL, one year later
Behavioural activity monitoring on CoreOS with Sysdig Falco
Metasploit for Web Workshop
Intro to Python programming and iPython
UNIX Basics and Cluster Computing
"A rootkits writer’s guide to defense" - Michal Purzynski
Stealthy, Hypervisor-based Malware Analysis
"Into the Fog The Return of ICEFOG APT" - Chi en (Ashley) Shen
The Art of Exploiting Unconventional Use-after-free Bugs in Android Kernel by...
Kali tools list with short description
DefCon 2012 - Rooting SOHO Routers
Vulnerability, exploit to metasploit
Linux Virus
[English] BackBox Linux and Metasploit: A practical demonstration of the Shel...
Rihards Olups - Encrypting Daemon Traffic With Zabbix 3.0
WTF my container just spawned a shell!
Designing Tracing Tools
BlueHat v17 || Disrupting the Mirai Botnet
BackTrack5 - Linux
LibreSSL, one year later
Ad

Similar to About linux-english (20)

PDF
17 Linux Basics #burningkeyboards
PDF
LXC Containers and AUFs
PDF
Linux Server Deep Dives (DrupalCon Amsterdam)
PPTX
Introduction-to-Linux.pptx
PPTX
Introduction khgjkhygkjiyhgikjyhgikygkii
PPTX
Introduction to-linux
PPTX
Introduction-to-Linux.pptx
PDF
Containers with systemd-nspawn
DOC
PDF
Linux Performance Analysis: New Tools and Old Secrets
PDF
Filip palian mateuszkocielski. simplest ownage human observed… routers
PDF
Simplest-Ownage-Human-Observed… - Routers
PPTX
Linux container, namespaces & CGroup.
TXT
Interview questions
PPT
PDF
Talk 160920 @ Cat System Workshop
PPTX
Introduction to-linux
PPT
Threats, Vulnerabilities & Security measures in Linux
PDF
Cgroups, namespaces, and beyond: what are containers made from? (DockerCon Eu...
PPTX
Cgroups, namespaces and beyond: what are containers made from?
17 Linux Basics #burningkeyboards
LXC Containers and AUFs
Linux Server Deep Dives (DrupalCon Amsterdam)
Introduction-to-Linux.pptx
Introduction khgjkhygkjiyhgikjyhgikygkii
Introduction to-linux
Introduction-to-Linux.pptx
Containers with systemd-nspawn
Linux Performance Analysis: New Tools and Old Secrets
Filip palian mateuszkocielski. simplest ownage human observed… routers
Simplest-Ownage-Human-Observed… - Routers
Linux container, namespaces & CGroup.
Interview questions
Talk 160920 @ Cat System Workshop
Introduction to-linux
Threats, Vulnerabilities & Security measures in Linux
Cgroups, namespaces, and beyond: what are containers made from? (DockerCon Eu...
Cgroups, namespaces and beyond: what are containers made from?
Ad

Recently uploaded (20)

PPTX
IOT PPTs Week 10 Lecture Material.pptx of NPTEL Smart Cities contd
PPTX
Lesson 3_Tessellation.pptx finite Mathematics
PPTX
Sustainable Sites - Green Building Construction
PDF
Arduino robotics embedded978-1-4302-3184-4.pdf
PPTX
Strings in CPP - Strings in C++ are sequences of characters used to store and...
PPTX
CYBER-CRIMES AND SECURITY A guide to understanding
PDF
Model Code of Practice - Construction Work - 21102022 .pdf
PPTX
Lecture Notes Electrical Wiring System Components
PPTX
UNIT-1 - COAL BASED THERMAL POWER PLANTS
PDF
PRIZ Academy - 9 Windows Thinking Where to Invest Today to Win Tomorrow.pdf
PPTX
Recipes for Real Time Voice AI WebRTC, SLMs and Open Source Software.pptx
PDF
July 2025 - Top 10 Read Articles in International Journal of Software Enginee...
PPTX
Internship_Presentation_Final engineering.pptx
PPTX
Road Safety tips for School Kids by a k maurya.pptx
PPTX
MET 305 MODULE 1 KTU 2019 SCHEME 25.pptx
PPTX
CH1 Production IntroductoryConcepts.pptx
PPTX
bas. eng. economics group 4 presentation 1.pptx
PPTX
Practice Questions on recent development part 1.pptx
PPTX
Infosys Presentation by1.Riyan Bagwan 2.Samadhan Naiknavare 3.Gaurav Shinde 4...
PDF
Mohammad Mahdi Farshadian CV - Prospective PhD Student 2026
IOT PPTs Week 10 Lecture Material.pptx of NPTEL Smart Cities contd
Lesson 3_Tessellation.pptx finite Mathematics
Sustainable Sites - Green Building Construction
Arduino robotics embedded978-1-4302-3184-4.pdf
Strings in CPP - Strings in C++ are sequences of characters used to store and...
CYBER-CRIMES AND SECURITY A guide to understanding
Model Code of Practice - Construction Work - 21102022 .pdf
Lecture Notes Electrical Wiring System Components
UNIT-1 - COAL BASED THERMAL POWER PLANTS
PRIZ Academy - 9 Windows Thinking Where to Invest Today to Win Tomorrow.pdf
Recipes for Real Time Voice AI WebRTC, SLMs and Open Source Software.pptx
July 2025 - Top 10 Read Articles in International Journal of Software Enginee...
Internship_Presentation_Final engineering.pptx
Road Safety tips for School Kids by a k maurya.pptx
MET 305 MODULE 1 KTU 2019 SCHEME 25.pptx
CH1 Production IntroductoryConcepts.pptx
bas. eng. economics group 4 presentation 1.pptx
Practice Questions on recent development part 1.pptx
Infosys Presentation by1.Riyan Bagwan 2.Samadhan Naiknavare 3.Gaurav Shinde 4...
Mohammad Mahdi Farshadian CV - Prospective PhD Student 2026

About linux-english

  • 1. Shota Ito About the linux system
  • 2. ABOUT THE LINUX SYSTEM Promise ▸ Today I can not reach the kernel itself… ▸ Talking about today is very difficult :(
 And I do not know too many things.
 It is normal not to understand. ▸ An old programmer may understand from the experience of writing C. ▸ The theme is too large so it is about the summary. ▸ If there are people who are interested please listen individually :)
  • 3. ABOUT THE LINUX SYSTEM What is Linux ?
  • 4. Linux is a name which broadly denotes a family of free and open- source software operating system distributions built around the Linux kernel. Wikipedia
  • 5. Kernel Device Device driver Thread scheduler File system Network stack Virtual memory System call User Layer Kernel Layer System library Database Application
  • 6. ABOUT THE LINUX SYSTEM What is system library
  • 7. Kernel Device Device driver Thread scheduler File system Network stack Virtual memory System call User Layer Kernel Layer System library Database Application
  • 8. ABOUT THE LINUX SYSTEM What is system library ? ▸ Famous library is glibc(GNU C Library) ▸ Forexample, php and java is using glibc ▸ and more openldap-devel.x86_64, openssl- devel.x86_64, zlib-devel.x86_64…etc
  • 9. ABOUT THE LINUX SYSTEM Example: php code
 (https://github.com/php/php-src)
  • 10. ABOUT THE LINUX SYSTEM mysqli.c
  • 11. ABOUT THE LINUX SYSTEM zend_alloc.h
  • 12. ABOUT THE LINUX SYSTEM zend_alloc.h
  • 13. ABOUT THE LINUX SYSTEM What is system call
  • 14. Kernel Device Device driver Thread scheduler File system Network stack Virtual memory System call User Layer Kernel Layer System library Database Application
  • 15. ABOUT THE LINUX SYSTEM What is system call ? ▸ System call is the interface between the application and the kernel. ▸ Why need system call? ▸ The authority is too large for direct hardware control. ▸ ex)get the memory! open the socket because i want to correspond! fork the process!…etc
  • 16. ABOUT THE LINUX SYSTEM What system calls are there ? ▸ read/write: Using a file descriptor, read the byte and place it in buffer. ▸ malloc:Call it when get memory ▸ clone(fork):Call it when fork the process ▸ getsockname:Call it when get socket name ▸ accept,accept4 : Call it when accept connection
  • 17. ABOUT THE LINUX SYSTEM Watch system call for apache httpd ▸ Get all call
 # strace $(for pid in `pgrep httpd`;do echo -n "-p $pid ";done) ▸ Get getsockname,accept,accept4
 # strace $(for pid in `pgrep httpd`;do echo -n "-p $pid ";done) -e trace=getsockname,accept,accept4 ▸ for using grep
 strace $(for pid in `pgrep httpd`;do echo -n "-p $pid ";done) 2>&1 | grep ‘192.168.120.129' ▸ What happens if I disconnect the connection with iptables ?
  • 18. ABOUT THE LINUX SYSTEM TIPS: How pipe works ▸ What do you often use “|” ?
  • 19. ABOUT THE LINUX SYSTEM TIPS: Check the pipe works ▸ ex:$ cat hoge.txt | grep ito ▸ Chase ”cat | grep ito” at the system call level ▸ strace -p `pgrep cat` ▸ strace -p `pgrep grep` ▸ lsof -p `pgrep cat` ▸ lsof -p `pgrep grep`
  • 20. ABOUT THE LINUX SYSTEM
  • 21. ABOUT THE LINUX SYSTEM TIPS: Explanation CAT PROCESS GREP PROCESS The ring buffer provided by the kernel /DEV/PTS/0 PROCESS pipe:[412981] ①Read file descriptor 0(entity:/dev/pts/0)
 read(0, “hoge¥n”, 65536) ②Write file descriptor1(entiry:pipe:[412981])
 write(1, “hoge¥n”, 5) ③Read file descriptor0(entity:pipe:[412981])
 read(0, “hoge¥n”, 32768) about write call about read call about ring buffer about file descriptor
  • 22. ABOUT THE LINUX SYSTEM Talk of the kernel so finish : )
  • 23. ABOUT THE LINUX SYSTEM How does this knowledge help?
  • 24. ABOUT THE LINUX SYSTEM Pre-release performance troubleshooting (true story… WEB APP ▸ I do not really understand something, but it's late! Investigate! DBLB HOW MUCH IS THE RESPONSE RETURNED? WHAT'S THE ERROR? NO PROBLEM APPLICATION RESPONSE & ERROR SEEMS TO BE PROBLEMATIC? RESPONSE IS NOT ON !! IS NOT DB HEAVY ? NO PROBLEM
  • 25. ABOUT THE LINUX SYSTEM APP ▸ Taking the system call graph of the application, it took about 40% to read the encryption processing library. ▸ Tell application developers to solve them by reviewing the encryption algorithm. WHILE ACQUIRING THE SYSTEM CALL, CHECK THE CONTENTS WITH LOAD. 参考:CPU Flame Graphs Pre-release performance troubleshooting (true story…
  • 26. ABOUT THE LINUX SYSTEM Understand what is going on 参考:Linux Performance Tools
  • 27. ABOUT THE LINUX SYSTEM Performance tuning ▸ Since it is communicating with socket, it is better to increase the file descriptor ▸ Will you leave the cache management of the database to OS or application? ▸ High CPU utilization! ▸ User land? Kernel land? Context switch?
  • 28. ABOUT THE LINUX SYSTEM Reference
  • 29. ABOUT THE LINUX SYSTEM Reference ▸ Linux Networking Architecture ▸ gdb Debugging Full Example (Tutorial): ncurses
  • 30. ABOUT THE LINUX SYSTEM Q&A ▸ Which layer captures packets captured from tcpdump? ▸ Get data from the device driver. 引用:Linux Network Internals