Skip to Content
For Enterprise
For Government
For Higher Ed
For Individuals
For Marketing
For Enterprise
For Government
For Higher Ed
For Individuals
For Marketing
Explore Skills
Cloud Computing
Microsoft Azure
Amazon Web Services (AWS)
Google Cloud
Cloud Migration
Cloud Deployment
Cloud Platforms
Data Engineering
Data Warehouse
SQL
Apache Spark
Microsoft SQL Server
MySQL
Kafka
Data Lake
Streaming & Messaging
NoSQL Databases
Relational Databases
Data Science
Pandas
R
MATLAB
SAS
D3
Power BI
Tableau
Statistics
Exploratory Data Analysis
Data Visualization
AI & ML
Generative AI
Machine Learning
Artificial Intelligence (AI)
Deep Learning
Reinforcement Learning
Natural Language Processing
TensorFlow
Scikit-Learn
Hyperparameter Tuning
MLOps
Programming Languages
Java
JavaScript
Spring
Python
Go
C#
C++
C
Swift
Rust
Functional Programming
Software Architecture
Object-Oriented
Distributed Systems
Domain-Driven Design
Architectural Patterns
IT/Ops
Kubernetes
Docker
GitHub
Terraform
Continuous Delivery
Continuous Integration
Database Administration
Computer Networking
Operating Systems
IT Certifications
Security
Network Security
Application Security
Incident Response
Zero Trust Model
Disaster Recovery
Penetration Testing / Ethical Hacking
Governance
Malware
Security Architecture
Security Engineering
Security Certifications
Design
Web Design
Graphic Design
Interaction Design
Film & Video
User Experience (UX)
Design Process
Design Tools
Business
Agile
Project Management
Product Management
Marketing
Human Resources
Finance
Team Management
Business Strategy
Digital Transformation
Organizational Leadership
Soft Skills
Professional Communication
Emotional Intelligence
Presentation Skills
Innovation
Critical Thinking
Public Speaking
Collaboration
Personal Productivity
Confidence / Motivation
Features
All features
Verifiable skills
AI Academy
Courses
Certifications
Interactive learning
Live events
Superstreams
Answers
Insights reporting
Radar Blog
Buy Courses
Plans
Sign In
Try Now
O'Reilly Platform
book
LINUX系統程式設計 第二版
by
Robert Love
December 2013
Intermediate to advanced
496 pages
8h 57m
Chinese
GoTop Information, Inc.
Content preview from
LINUX系統程式設計 第二版
32
|
第二章
幸好,一般不需要在乎檔案的擁有群組。
新檔案的使用權限
前面所列示的兩種
open()
系統呼叫格式都是正確的。除非你是在建立檔案,否則
mode
引數會被忽略;如果指定
O_CREAT
旗標,則需要使用
mode
引數。如果你在使用
O_CREAT
的時候忘了提供
mode
引數,會導致不明確的結果,往往令人相當不悅—所以不要忘了!
當一個檔案被建立時,
mode
引數可用來為新建立的檔案設定使用權限。以這個特別的方
式開啟檔案時,並不會檢查
mode
引數所設定的使用權限,所以你可以進行與使用權限抵
觸的操作,例如開啟檔案以便進行寫入操作時,卻替檔案設定唯讀的使用權限。
mode
引數就是人們熟悉的
Unix
使用權限位元設定值,例如
0644
這個八進位值(擁有
用戶可以進行讀寫操作,其他任何人只能進行讀取操作)。從技術上來說,
POSIX
允
許實際的設定值因實作而異,這讓不同的
Unix
系統得以安排自己所期望的權限位元。
然而。每個
Unix
系統都會以相同的方式來實作權限位元。因此,雖然技術上來說權限
位元不具可移植性,指定
0644
或
0700
將會在你可能會遇到的任何系統上得到同樣的
效果。
為了彌補
mode
引數中位元擺放位置的不可移植性,
POSIX
引進了如下可用二元
OR
邏
輯運算組合在一起的常數,以便供
mode
引數使用:
S_IRWXU
擁有用戶具有讀取、寫入和執行的權限。
S_IRUSR
擁有用戶具有讀取的權限。
S_IWUSR
擁有用戶具有寫入的權限。
S_IXUSR
擁有用戶具有執行的權限。
S_IRWXG
擁有群組具有讀取、寫入和執行的權限。 ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial
You might also like
優雅的SciPy|Python科學研究的美學
Juan Nunez-Iglesias, Stéfan van der Walt, Harriet Dashnow
成為卓越程式設計師的38項必修法則
Pete Goodliffe
深入理解運算原理|從簡單的機器到無所不能的程式
Tom Stuart
C++语言导学(原书第2版)
本贾尼 斯特劳斯特鲁普
Publisher Resources
ISBN: 9789862769812