《Linux 小知识与收集鹅卵石》
Linux Tidbits and Collecting Pebbles

原始链接: https://unixbhaskar.wordpress.com/2025/03/02/linux-tidbits-and-collecting-pebbles/

这篇帖子记录了作者在Linux和开源生态系统中的个人学习历程,深受UNIX原则的启发。作者分享了一系列笔记——他们积累知识的“原始片段”,旨在激发他人的进一步探索。 主要内容涵盖了多个领域:启动过程中`/dev`的动态创建(受内核配置选项影响)、`initrd`和`initramfs`的区别,以及shell中逻辑工作目录的细微差别。它深入探讨了C编程细节(char与unsigned char数组)、时区配置(UTC作为兼容性包含),以及`grep`和`rsync`等工具的行为。 进一步的内容包括X程序事件处理、虚拟文件系统(VFS)、进程ID、磁盘使用量报告(`ls`与`du`)、信号处理,以及汇编语言与机器代码之间的关系。作者还强调了shell脚本的怪癖(bash `-c`参数处理、别名)以及系统级细节,如POSIX标准和`su`命令期间的信号阻塞。总体信息鼓励动手实践和对底层机制的更深入理解。

黑客新闻 新 | 过去 | 评论 | 提问 | 展示 | 招聘 | 提交 登录 Linux 杂记与收集鹅卵石 (unixbhaskar.wordpress.com) 4 分,作者 Bogdanp,2 小时前 | 隐藏 | 过去 | 收藏 | 讨论 考虑申请YC冬季2026批次!申请截止日期为11月10日 指南 | 常见问题 | 列表 | API | 安全 | 法律 | 申请YC | 联系 搜索:
相关文章

原文

Well, my journey with Linux and Open source becoming quite astonish way of moving forward in life. I have been hugely influenced by the UNIX luminaries work and try to follow the principles they have established for the betterment. Sometimes, in fact, to follow that path requires pushing the limit of my everything(you guess the shortcoming in me, right?). But, I have realized, if I don’t do, I can not thrive as per my liking. So, I had to have the tenacity to get along with it.

Because I have attached with a particular platform for so long, it bound to be something in your kitty to show the world that you have come across. In this post, I will dish out some information I have gathered from various people and places (this is an absolute fraction and rudimentary, but it helps me), so it might hook you and to your journey with the echo system.

These are in no particular order, and I am giving a glance at my note file and writing it out for you. Try to connect these information, you need to put a lot of work to find out, which I intentionally left for you to get accustomed.

  1. In file system, the /dev partition is build in the fly, when kernel boots. And in that place, there resides so many files gather by the kernel. One of them is /dev/ttyS , which is needed for the serialized terminal consoles. This file gets created by the kernel config option CONFIG_SERIAL_8259_RUNTIME_UARTS.Well, you can told the kernel not to create it by passing a command line argument to the bootloader parameter 8250.nr_uarts=n
  2. Also, /dev is a special tmpfs as devtmpfs, that means it is on tmpfs , which doesn’t resides on any physical storage.
  3. There is a stark difference between initrd and initramfs . Which is, a initrd is a real filesystem and that is compressed. While initramfs is a cpio archive which is also compressed. Both of them, while in use, inflated inside RAM to assist kernel to get on with the booting.
  4. Logical working directory is a shell specific thing. This is especially used to reached the current directory via symlnk. Running cd.. removes the last component of the logical working directory. This is tricky and I encourage you to investigate further.
  5. Big gotcha, use judiciously, aliases are process as shell input is read NOT as shell command executed.
  6. C strings are arrays of char, NOT arrays of unsigned char.
  7. unsigned char array …. strcpy requires a char pointer.Unsigned char and char are not the same thing.

8. The primary name of the zone is Etc/UTC. UTC is included in the timezone database for compatibility.

    9. getchar only ever reads one character at a time, putchar only ever writes one character at a time.

10. GNU grep doesn’t use Perl, it uses PCRE.

11. Grep used Gnulib‘s RE library.

12. X program receive events in order.It shouldn’t matter how much time elapses between the events.

13. Rsync only consider the last modification timestamp while checking destination, not last metadata change timestamp.

    14. VFS is abstraction layer for all the filesystem in the Linux kernel.

15. Kernel tasks always are forked off PID 2, kthreadd

16. *ls* shows length of the file in size, whereas *du* shows the actual byte it took to reside there.

17. Signal number only go up to 64.

18. Assembly is really just about making machine code easier to read the write for human.

19. Your CPU is running program, it is reading machine code, which is produced by human crafted assembly.

20. When you use bash -c the first argument after the command is assigned to $0 NOT S1.

      21. Cron changes between UNIX system III and UNIX system V

22. A mouse device reports relative positioning information whereas a touchscreen

or touchpad might report absolute positioning information.

23. POSIX doesn’t care how the system is implemented. It merely specifies a C API.

       24. File creation time usually cannot be changed from userspace.

25 ) When you press Ctrl+C, the terminal line discipline sends SIGINT to all processes in the terminal’s foreground process group that do not have the signal ignored. It is sent to processes where it is blocked, but it won’t do anything to that process unless and until that process unblocks it.

26. When you are raising your privileges to the superuser, su will always add SIGINT and SIGQUIT to its blocked signal mask. With that in place you don’t have to worry about them killing the su process itself.

The only time su keeps SIGINT and SIGQUIT unblocked are when you are dropping to an unprivileged user and using –command= (not –session-command=). That is when su uses the setsid(2) syscall, running the child process in a new session, and so it now has to propagate terminal signals into that session.

联系我们 contact @ memedata.com