Trying normal Linux programming Part 1

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 > Normal Linux programming The royal road to gcc programming that you can learn from how Linux works <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

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 Part 6 https://qiita.com/uturned0/items/b7df48e87ae9170f3698 Part 7 https://qiita.com/uturned0/items/263151cf7c83bff7fac1


It's just a memo

chapter 1

Use arguments

#include <stdio.h>
#include <stdlib.h>

int
main(int argc, char *argv[])
{
  int i;

  printf("argc=%d\n",argc);
  for (i=0;i < argc; i++) {
    printf("argv[%d]=%s \n", i, argv[i]);
}
  exit(0);
}

result

$ gcc -Wall -O2 args.c  && ./a.out a b "c d"
argc=4
argv[0]=./a.out
argv[1]=a
argv[2]=b
argv[3]=c d

option

-Wall Debug information is nice
-O2 compilation seems to be faster.-O3 is the fastest, but it seems not recommended

How to see man

With man printf, the printf of the command (user command) usually appears. image.png

man 3 printf will bring up the library function printf. Same name but different image.png

The linux man could even pull a function in c. man strlen hits strlen (3). It's not a user command, so you can't use it by typing strlen in bash. What is described in c-lang to the last.

linux man sectioning

1 Execution program or shell command
2 System call (function provided by kernel)
3 Library call (function in program library)
4 Special file (usually/Files in dev)
5 File formats and conventions (eg/etc/passwd)
6 games
7 Others (macro packages and conventions)
8 System administration commands (usually used only by root)
9 Kernel routine[Non-standard]

https://laboradian.com/basic-usage-of-man-command-on-linux/

Type man 5 passwd to get a description of the / etc / passwd file instead of the passwd command. Howl ~~~

make man into Japanese

I'm a person who can read English, but I'm not very motivated about this, so I thought I'd do it in Japanese.

sudo yum install man-pages-ja
export LANG=ja_JP.utf8
man 5 passwd

It became Japanese. This seems to be a study. I wonder what it means to be able to read man image.png

chapter 1 End


I'm reading this book

<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 > Normal Linux programming The royal road to gcc programming that you can learn from how Linux works <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

Recommended Posts

Trying normal Linux programming Part 1
Try normal Linux programming Part 7
Try normal Linux programming Part 2
Try normal Linux programming Part 3
Try normal Linux programming Part 4
Try normal Linux programming Part 6
Read Normal Linux Programming (Part 1 Only)
Story of trying competitive programming Part 1
[For memo] Linux Part 2
New Linux commands! !! Part 2
Linux standard textbook part 4
Story of trying competitive programming 2
Making sound by programming Part 2
Linux standard textbook memo part 6
[For memo] Linux Part 1 vi editor
WSL2 ~ Linux on Windows ~ (Part 1: Introduction)