惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Jina AI
Jina AI
T
The Blog of Author Tim Ferriss
G
Google Developers Blog
P
Privacy & Cybersecurity Law Blog
SecWiki News
SecWiki News
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
Hacker News: Ask HN
Hacker News: Ask HN
Engineering at Meta
Engineering at Meta
Hugging Face - Blog
Hugging Face - Blog
PCI Perspectives
PCI Perspectives
www.infosecurity-magazine.com
www.infosecurity-magazine.com
T
The Exploit Database - CXSecurity.com
博客园_首页
Latest news
Latest news
T
Threat Research - Cisco Blogs
N
News and Events Feed by Topic
TaoSecurity Blog
TaoSecurity Blog
罗磊的独立博客
月光博客
月光博客
C
Cisco Blogs
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
V
V2EX
Last Week in AI
Last Week in AI
Cloudbric
Cloudbric
MyScale Blog
MyScale Blog
Spread Privacy
Spread Privacy
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
P
Proofpoint News Feed
G
GRAHAM CLULEY
N
News and Events Feed by Topic
MongoDB | Blog
MongoDB | Blog
N
Netflix TechBlog - Medium
M
MIT News - Artificial intelligence
I
InfoQ
Microsoft Security Blog
Microsoft Security Blog
人人都是产品经理
人人都是产品经理
K
Kaspersky official blog
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
量子位
I
Intezer
Microsoft Azure Blog
Microsoft Azure Blog
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
A
About on SuperTechFans
D
DataBreaches.Net
宝玉的分享
宝玉的分享
S
Security @ Cisco Blogs
Help Net Security
Help Net Security
Hacker News - Newest:
Hacker News - Newest: "LLM"

seize the dev

Will Software Engineering Survive? Why is the Gmail app 700 MB? Bits of Open-Source in 2025 Parsing JSON in Forty Lines of Awk A Tricky Floating-Point Calculation Improving Date Formatting Performance in Node.js Installing FreeBSD on Oracle Cloud A Simple Setup for C and C++ How to Break Software
Unix is not Linux
Mohamed Akram · 2022-08-21 · via seize the dev

Too often on the internet, tutorials and guides are written of POSIX and Unix tools that implicitly assume a Linux installation, and more specifically a GNU-based one. This has many implications when it comes to everything from the behavior of the shell, its utilities, and even the C standard library. While the dominance of Linux might mean that one can ignore this distinction, it is still useful to be aware of it. I’ve outlined some of the more prominent discrepancies below.

Bash is not the standard shell

The default shell that is present on all Unix systems is sh, not bash. The language used in the portable sh shell is described in the POSIX standard. However, on many Linux systems sh is linked to bash - this makes bash operate in a more compatible way with the standard, but still allows certain bash features that may not work on other systems. When in doubt, refer to the standard.

Long options are not Unix

Many utilities accept both a long option, eg. grep --count with a double hyphen, in addition to a short option, eg. grep -c. The former is a GNU invention, and they generally do not exist on other systems, such as BSDs. In fact, the standard getopts utility, and corresponding getopt C function only support the short style.

Make isn’t GNU make

The version of make specified by POSIX is much more limited than the GNU version. This one is harder to deal with as the specification is lacking in many aspects, particularly any kind of logical or conditional operators. You can workaround this by moving some logic to a configure script that generates another Makefile that is then included by the main one. Further, the BSD makes have a completely different syntax than the GNU one for things like conditionals. Luckily, if your focus is on macOS and Linux only, you can get away with depending on GNU features as macOS’s make is based on the GNU one.

The C compiler is not GCC

This is related to the previous point, as it often comes up in Makefiles. When referring to the C compiler in that context, it is better to use the implicit $(CC) variable, and when compiling C++ code, to use the $(CXX) variable. Most BSD systems have now switched to Clang as the default compiler and do not provide a gcc binary. When referring to the C and C++ compilers outside of Makefiles, the cc and c++ commands are reliable and work across systems.

GNU is not Linux

This is slightly different, but even GNU interfaces are not necessarily the ones present on a Linux system. The Alpine Linux distribution for example, popular as a base in Docker containers due to its light weight, forgoes the GNU C Library for musl, and uses BusyBox instead of the GNU utilities. Therefore, one would be well advised to try to stick to portable interfaces even if targeting solely Linux systems.

Unix is not UNIX

Finally, even Unix is not UNIX. The latter is a trademark that requires certification by The Open Group. Certified operating systems, the most well-known of which is macOS, are guaranteed to follow the UNIX specification. That said, most Unix-like operating systems, including the BSDs, as well as the GNU tools make a strong effort to stick to the standard as much as possible.