2019年12月29日 星期日

Manage file permissions on Unix-like systems

Source https://kb.iu.edu/d/abdb

On this page:

Overview

Unix-like operating systems, such as Linux, running on shared high-performance computers use settings called permissions to determine who can access and modify the files and directories stored in their file systems. Each file and directory in a file system is assigned "owner" and "group" attributes.
Most commonly, by default, the user who creates a file or directory is set as owner of that file or directory. When needed (for example, when a member of your research team leaves), the system's root administrator can change the user attribute for files and directories.
The group designation can be used to grant teammates and/or collaborators shared access to an owner's files and directories, and provides a convenient way to grant access to multiple users.

View file permissions

To view the permissions for all files in a directory, use the ls command with the -la options. Add other options as desired; for help, see List the files in a directory in Unix.
For example, if you enter:
ls -lah
You should see output similar to the following:
-rw-r--r-- 1 user1 group1 62 Jan 15 16:10 myfile.txt
drwxr-xr-x 2 user1 group1 2048 Jan 15 17:10 Example
In the output example above, the first character in each line indicates whether the listed object is a file or a directory. Directories are indicated by a (d); the absence of a d at the beginning of the first line indicates that myfile.txt is a regular file.
The letters rwx represent different permission levels:
PermissionFilesDirectories
rcan read the filecan ls the directory
wcan write the file
can modify the directory's contents
xcan execute the filecan cd to the directory
Note the multiple instances of r, w, and x. These are grouped into three sets that represent different levels of ownership:
  • Owner or user permissions: After the directory (d) slot, the first set of three characters indicate permission settings for the owner (also known as the user).
    In the example -rw-r--r--, the owner permissions are rw-, indicating that the owner can read and write to the file but can't execute it as a program.
    In the example drwxr-xr-x, the owner permissions are rwx, indicating that the owner can view, modify, and enter the directory.
  • Group permissions: The second rwx set indicates the group permissions. In the fourth column of the example above, group1 is the group name.
    In the example -rw-r--r--, group members can only read the file.
    In the example drwxr-xr-x, group members can view as well as enter the directory.
  • Other permissions: The final rwx set is for "other" (sometimes referred to as "world"). This is anyone outside the group. In both examples above, these are set to the same permissions as the group.

Change file permissions

To change file and directory permissions, use the command chmod (change mode). The owner of a file can change the permissions for user (u), group (g), or others (o) by adding (+) or subtracting (-) the read, write, and execute permissions.
There are two basic ways of using chmod to change file permissions: The symbolic method and the absolute form.

Symbolic method

The first and probably easiest way is the relative (or symbolic) method, which lets you specify permissions with single letter abbreviations. A chmod command using this method consists of at least three parts from the following lists:
Access classOperatorAccess Type
u (user)+ (add access)r (read)
g (group)- (remove access)w (write)
o (other)= (set exact access)x (execute)
a (all: u, g, and o)
For example, to add permission for everyone to read a file in the current directory named myfile, at the Unix prompt, enter:
chmod a+r myfile
The a stands for "all", the + for "add", and the r for "read".
Note:
This assumes that everyone already has access to the directory where myfile is located and its parent directories; that is, you must set the directory permissions separately.
If you omit the access class, it's assumed to be all, so you could also enter the previous example as:
 chmod +r myfile
You can also specify multiple classes and types with a single command. For example, to remove read and write permission for group and other users (leaving only yourself with read and write permission) on a file named myfile, you would enter:
 chmod go-rw myfile
You can also specify that different permissions be added and removed in the same command. For example, to remove write permission and add execute for all users on myfile, you would enter:
 chmod a-w+x myfile
In each of these examples, the access types that aren't specified are unchanged. The previous command, for example, doesn't change any existing settings specifying whether users besides yourself may have read (r) access to myfile. You could also use the exact form to explicitly state that group and other users' access is set only to read with the = operator:
chmod go=r myfile
The chmod command also operates on directories. For example, to remove write permission for other users on a subdirectory named mydir, you would enter:
chmod o-w mydir
To do the same for the current directory, you would enter:
chmod o-w 
To change permissions recursively in all subdirectories below the specified directory, add the -R option; for example, to grant execution permissions for other users to a directory (mydir) and all the subdirectories it contains, you would enter:
chmod -R o+x mydir
Be careful when setting the permissions of directories, particularly your home directory; you don't want to lock yourself out by removing your own access. Also, you must have execute permission on a directory to switch (cd) to it.

Absolute form

The other way to use the chmod command is the absolute form, in which you specify a set of three numbers that together determine all the access classes and types. Rather than being able to change only particular attributes, you must specify the entire state of the file's permissions.
The three numbers are specified in the order: user (or owner), group, and other. Each number is the sum of values that specify read, write, and execute access:
PermissionNumber
Read (r)4
Write (w)2
Execute (x)1
Add the numbers of the permissions you want to give; for example:
  • For file myfile, to grant read, write, and execute permissions to yourself (4+2+1=7), read and execute permissions to users in your group (4+0+1=5), and only execute permission to others (0+0+1=1), you would use:
    chmod 751 myfile
  • To grant read, write, and execute permissions on the current directory to yourself only, you would use:
    chmod 700 
You can think of the three digit sequence as the sum of attributes you select from the following table:
Read by owner400
Write by owner200
Execute by owner100
Read by group040
Write by group020
Execute by group010
Read by others004
Write by others002
Execute by others001
Sum all the accesses you wish to permit. For example, to give write and execute privileges to the owner of myfile (200+100=300), and give read privileges to all (400+040+004=444), you would enter:
 chmod 744 myfile
Some other examples are:
777anyone can do anything (read, write, or execute)
755you can do anything; others can only read and execute
711you can do anything; others can only execute
644you can read and write; others can only read

Common issues when sharing data with other users

Important:
Be sure you understand your responsibilities when processing, storing, and sharing data containing protected health information (PHI). For more, see Your legal responsibilities for protecting data containing protected health information (PHI) when using UITS Research Technologies systems and services.
To share a file or directory that you own with someone, you can grant read and execute privileges for that user. However, you must also set the same privileges on any parent directories above the item you're sharing; if you don't, the user can't look and change into (cd) all the parent directories above your file or directory.
If you think of a file system as a physical place, then permissions work like keys that let you access different directories:
  • The read (r) permission lets users look (ls) into directories.
  • The execute (x) permission lets users move (cd) into directories.
  • The write (w) permission lets users add and remove files.
For example, say you want to give someone access to /N/u/username/Carbonate/scripts. Imagine the path as a physical space:
  • /N is the gated community where you live.
  • /u is the unit.
  • /username is your apartment.
  • /Carbonate is a room in your apartment.
  • /scripts is a closet in your room.
If someone wanted to run your scripts, you would need to give that person access to every part of /N/u/username/Carbonate/scripts. You might try to do it this way:
chmod +rx /N/u/username/Carbonate/scripts
However, a user can't read or access a subdirectory unless the user also has x permissions to the parent directories. In other words, the above command gives out a key to your closet, but not to your room or apartment.
To resolve this, give x permissions to the parent directories you control:
chmod +x /N/u/username/
chmod +x /N/u/username/Carbonate
This will let others move (cd) to the scripts directory. Because the parent directories don't have r permissions, users will only be able to look (ls) within the scripts directory, keeping the rest of your file system private.

Get help

For more about chmod, consult the manual page. At the Unix prompt, enter:
 man chmod
At Indiana University, for personal or departmental Linux or Unix systems support, see Get help for Linux or Unix at IU.
This is document abdb in the Knowledge Base.
Last modified on 2019-08-23 15:27:34.

Contact us

For help or to comment, email the UITS Support Center.

2019年12月17日 星期二

C: Run a System Command and Get Output?

Source https://stackoverflow.com/questions/646241/c-run-a-system-command-and-get-output

Use the "popen" function.
Here's an example of running the command "ls /etc" and outputing to the console.
#include 
#include 


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

  FILE *fp;
  char path[1035];

  /* Open the command for reading. */
  fp = popen("/bin/ls /etc/", "r");
  if (fp == NULL) {
    printf("Failed to run command\n" );
    exit(1);
  }

  /* Read the output a line at a time - output it. */
  while (fgets(path, sizeof(path), fp) != NULL) {
    printf("%s", path);
  }

  /* close */
  pclose(fp);

  return 0;
}

2019年12月12日 星期四

Abbreviation and terminology

AAGC        Audio automatic gain control – for better call intelligibility, especially under noisy conditions
AC          Access channel. Access Control.  Alternative Current.
ACAS        Applicable configuration attribute selections
ACB         Application control block
ACC         Apparent charge capacity (QTI)
ACIR        Adjacent channel interference ratio
ACK         Acknowledgement
ACL         Asynchronous connection-less
ACLR        Adjacent Channel Leakage power Ratio or ACPR
ACPR
ACM         Abstract Control model
ACP         Analog call processing
ACPMC       Analog call processing main control
ACPMCVC     Analog call processing main-control voice channel
ACPRX       Analog call processing receive subtask
ACS         Adjacent channel selectivity
ADC         Analog-to-digital converter
ADP         Automotive Development Platform
ADS         Average Days Supply (存貨週轉天數)
AEHO        Access entry handoff
AFLT        Advanced forward link triangulation
AGC         Automatic gain control
AHO         Access handoff
AI          Acquisition indicator
AICL        Automatic Input Current Limiting
AOB         All Our Business.
APN         Access Point Name, the name of a gateway between a GPRS, 3G or 4G mobile network and another computer network, frequently the public Internet.
APR         Async. Packet Router (QCT)
APSD        Auto Power Source Detection (QTI)
ASIL        Automotive Safety Integrity Level, 由ISO 26262《道路車輛功能安全》定義的風險分類架構。
                        針對各危害,考慮在車輛運作時的嚴重性、暴露程度以及可控制性,進行風險分析後而建立。
                        ASIL D是產品最高的安全完整性,而ASIL A是最低的安全完整性。
Askey       An automotive electronic player founded by ASUS.
Automotive RT Android

BA          Bandwidth Adaption
BAM         Bus Access Manager (QCT)
BIMC        Bus integrated memory controller
BLOB        Binary Large OBject
BLSP        BAM Low-Speed Peripheral
BMS         Battery Monitoring System
BPI         Business Process Improvement
Brix        
BSR         (uplink) Buffer Rtatus Report
BWP         BandWidth Part

CASS        Code Authorization Signing Services (QTI)
CC          Carrier Component.
CE          Crypto engine.
CCB         Change Control Board (A-SPICE)
CDC         Calibrated Delay Circuit ((DDR)
            Communication Device Class (USB)
CDP         Core Development Platform
CDT         Configuration Data Table
CLI         Command Line Interface
C/No        Carrier-to-Noise density ratio (dB-Hz).  Directly dependent on the input signal power.  Higher value indicates higher input signal power.  Key factor for GPS satellite signal quality.
COB         Close Of Business.
CoPQ        Cost of Poor Quality
CPE         Common Platform Enumeration
            Customer Premises Equipment
CQI         Channel Quality Information
CRM         Customer Relationship Management
CSFB        Circuit Switch FallBack (communication)
CVS         QCT Core Voice Service
CVP         QCT Core Voice Processor
cynic       憤世嫉俗的人 (see finicky)
cynically   玩世不恭
cynicism    玩世不恭;犬儒主義

DAL         Device Abstraction Layer
DC          Dual Carrier.  Dual Connectivity.
DCC         (ARM) Debug Communication Channel
DCVS        Dynamic clock and voltage scaling
DDI         DDR Debug Image
DFP         Downstream Facing Port, a USB (Type-C) port 
            on a host or a hub to which devices are connected.
DHCP        Dynamic Host Configuration Protocol
DHD         Dongle Host Driver (Broadcomm)
DM-VERITY   Device-Mapper-Verity
DMZ         Demilitarized Zone. 又名Perimeter network,即「邊界網路」、周邊網路[2]或「對外網路」,為一種網路架構的布置方案,常用的架設方案是在不信任的外部網路和可信任的企業網路絡外,建立一個面向外部網路的物理或邏輯子網路,該子網路能設置用於對外部網路的伺服器主機。
DRM         Digital rights management
DRP         (USB Type-C) Dual Role Port, a USB Type-C port that can
            operate as a DFP or UFP.

EAP         Extensible Authentication Protocol (EAP) is an authentication framework frequently used in network and internet connections. EAP-
EAP-SIM
ECC         Error Correction Code. Elliptic curve cryptography
ECDH        Elliptic curve Diffie-Hillman
ECDSA       Elliptic curve digital signature algorithm
EDX         Energy Dispersive X-ray analysis 能量色散X射線分析 (可用於化學成份分析)
eFlow       Electronic Workflow
ELF         Executable and Linking Format
eMBMS       Evolved Multimedia Broadcast Multicast Service
eNodeB      E-UTRAN Node B, also known as Evolved Node B (abbreviated as eNodeB or eNB), is the element in E-UTRA of LTE that is the evolution of the element Node B in UTRA of UMTS. It is the hardware that is connected to the mobile phone network that communicates directly wirelessly with mobile handsets (UEs), like a base transceiver station (BTS) in GSM networks.
            Traditionally, a Node B has minimum functionality, and is controlled by a Radio Network Controller (RNC). However, with an eNB, there is no separate controller element. This simplifies the architecture and allows lower response times.
ERM         Eccentric Rotating Mass actuator (偏心旋轉塊馬達), 1st gen actuator for 力度回饋(haptics). See also haptics, LRA, piezo
ERP         Enterprise Resource Planning
EV          Electric Vehicle (automative)
EVM         Error Vector Magnitude. RF ? index. Smaller is better.

F2FS        Flash-Friendly File System
FA          Failure Analysis
FACH        Forward Access CHannel
FDD         Freq-Division-Duplex (paired spectrum)
TDD         Time-Division-Duplex (unpaired spectrum)
FEC         Forward Error Correction.
FFA         Form factor accurate (test phone)
FF-memless  Force Feedback memory less
finicky     Too picky. (see cynic)
FLUID       Forward Looking User Interface Device (QCT)
FOTA        Firmware Over The Air.
FS1         EFS Parttion1, = momdemst1 = m9kefs1
FS2         EFS Parttion2, = momdemst2 = m9kefs2
FSG         EFS Parttion Golden Copy,  = m9kefs3
FSC         EFS Parttion 5 BAK cookie, = m9kefsc
FTM         Factory Test Mode

Genvict     the leading solution provider and system integrator for intelligent transportation and the Internet of Vehicles (IoV) and a leader in the China ETC industry.
GIBA        GPRS IMS Bundled Authentication
GMSL        Gigabit Multimedia Serial Link (a.k.a SERDES for Video)
GWL         GWL (3gpp rats) means GSM (2G), WCDMA(3G) and LTE (4G) rats
GSTK        Generic SIM Application Toolkit

HDR         HDR (3gpp2) means Hybrid dual receiver which is DATA only NW.
HEV         Hybrid EV (automative)
HMAC        Hashed message authentication code
HSIC        High-Speed Inter-Chip interface. USB2.0 for chips on the same PCBA. D+/D- are replaced by Data and Strobe(DDR).
HVAC        Heat, Vantilating(送風), Air Conditioning
HVDCP       High Voltage Dedicated Charging Port (QTI)

IADC        Current measurement ADC (QCT)
ICB
IE          Information Element (3GPP)
IPA         IP Accelerator (QCT)
IPSec       Internet Protocol Security
IR          Incident Response (security), Incident Report (security), InfraRed
IrDA        
InfraRed Data Association
ISO14496    MPEG4
ISO16949    汽車業品質管理系統.
            Aimed at the development of a quality management system that provides for continual improvement, 
            emphasizing defect prevention and the reduction of variation and waste in the supply chain.
            Prepared by the International Automotive Task Force (IATF).

JDM         Joint Design Manufacturer

L2TP        Layer 2 Tunneling Protocol
LE          Linux-Enabled (QCT). Lab Entry (certification)
LK          Little Kernel-based Android boot loader
LiQUID      Large Qualcomm User Interface Device.
LOWI        Location WiFi Interface (QTI)
LPG         Light Pulse Generation
LPWA
LPWAN       Lower Power Wide Area Network
LRA         Linear Resonant Actuator. 2nd gen actuator for 力度回饋(haptics). See also haptics, ERM, piezo

MAC         Media Access Control (PHY)
            Mandatory Access Control (Security)
MBIM        Mobile Broadband Interface Model.(QCT)

MCC         Mobile Country Code.
MD          Mechanical Design/Department
ME          Mechanical Engineer.
MIL         Malfunction Indicator Lamp (automotive)
MIBIB       Multi-Image Boot Infomation Block.
MMH            
MNO         Mobile Network Operator
MT          Call-in (ata)
MS          Mobile Station
MSL         Mean Sea Level (WG-84)
MO          Call-out (atd)
MobileAP    Mobile Access Point
MTBF        Fit = 10^9 hours
            1 fit ~ MTBF=114155(year) ~ 8.76ppm ~0.000876 failure at 1st year.
MTP         Modem Test Platform
MVS         QCT Multimode Vocoder Service interfaces with the protocol and voice subsystem in the ADSP.

NA          Neighbor Advertisement
NAD         Network Attached Device
NAS         Network Attached Storage; Non-Access Stratum.
NAT         Network Address Translation
NG eCALL    在基於IP的LTE系統中,NG eCall自然地將不使用調變音訊訊號進行資料傳輸。
                  但它仍將使用語音傳輸,因為eCall不僅只傳輸資料,還可建立與事故車輛的語音連結。
NRE         None-Recurring Expense

OBS         Obsolete material
ODM         Original Design Manufacturer
ODU         Outdoor Device Unit
OHB         Operational HandBook
OMA-DM      Open Mobile Alliance - Device Management (MobilePhobe APP update architecture)
OPM         Operation Product Manager.
OTA         Over The Air
OtD         Order-to-Delivery (peter)
OTDOA       Observed Time Difference Of Arrival, a positioning feature introduced in rel9 E-UTRA (LTE radio).
            It's a multilateration method in which the User Equipment (UE) measures the time difference between some specific signals from several enodeBs and reports these time differences to a specific device in the network (the ESMLC). 
            The ESMLC based on these time differences and knowledge of the enodeBs locations calculates the UEs' position.
            ?: can be supported but not able to be verified.

PD          Process Domain (80-NP527-50)
PDAPI       Position Determination API (PDAPI, QTI 80-VG193-1 C)
PDCA        Plan Do(Take action) Check Act (formulate improvement actions)
PE          Process Engineering
PEB         Physical Erase Block (QCT, UBI)
PHEV        Plugin HEV (automative)
PHR         Power Headroom Report
PICS        Protocol Implementation Conformance Statement (3GPP)
            Product Information Comformance Sheet (Feature support list) (wireless communication)
            
PIL         Peripheral Image Loader
PIN         Personal identification number (SIM)
PIXIT       Protocol Implementation eXtra Information fot Testing settings. (3GPP)
PL          Product Line
PLM         rocuct Lifecycle Management
PLMN        Public Land Mobile Network
POR         PowerOnReset, Plan of Record (QTI)
PPE         Precision Positioning Engine (QTI)
PPTP        Point-to-Point Tunneling Protocol
PRL         Preferred Roaming List.
PUK         Personal unblocking key, used in SIM cards to reset a personal identification number (PIN)
PUCCH       Physical Uplink   Control CHannel. Short but statically  allocated channel.
PUSCH       Physical Uplink   Shared  CHannel. Long  but dynamically allocated channel.
PDCCH       Physical Downlink Control CHannel. Short but statically  allocated channel.
PDSCH       Physical Downlink Shared  CHannel. Long  but dynamically allocated channel.
DCI         Downlink Control Information
UCI         Uplink Control Information
CSI-RS      Channel State I - Reference Signal
SON-ANR     Self-Organizing Networks Automatic Neighbor Relation 
SRS         Sounding Reference Signal

QAM         QCT Application Module
QCMAP       QCMobileAP
QCN         Feature support detail parameters.
QDSS        QCT Diagnostic
QDST        QCT Digital Signing Tool
QFIL        QCT Flash Image Loader.
QFPROM      QCT Fuse-Programmable ROM.
QMI         QCT MSM Interface
QTM         QCT Telematics Module
QTI         Qualcomm Tethering Interface


R&R         Roles & Responsibility
RA          Router Advertisement
RASIC       Responsible Approve Support Inform Consult https://www.nexightgroup.com/defining-roles-and-responsibilities-on-a-project-rasic/
RDM         Runtime Device Mapper (QTI)
RFQ         Request For Quotation
RIL         Radio Interface Layer
RLF         Radio Link Failure
RoyalTek    鼎天 New player of automotive electronics (2019)
RRC         Radio Resource Control
rSAP        Remote SIM Access Profile (SAP on a non-UIM bus, such as USB or BT)
RS          Router Solicitation
RSRP        Reference Signal Received Power
RSRQ        Reference Signal Received Quality (RSRQ = resourcce_block_count*RSRP/RSSI)
RSSI        Reference Signal Strength Indicator
RVCT        (ARM) RealView Compilation Tools
RVDS        (ARM) RealView Development Suite (RVCT --> RVDS --> DevStudio-5)

SAP         Sensor (accelerameter/gyro) Asisted Positioning.
            SIM Access Profile (3GPP, protocol to access SIM) SCM         Secure Channel Manager
Security is a process, not a product.
SFE         Shortcut Forward Engine (QCT, low-cost IPA)
SFCS        Shop Floor Control System
SIM         Subscriber Identity Module.
SIO         Serial Input/Output
SKU         Stock Keeping Unit
SMACK       Simplified Mandatory Access Control Kernel
SMP         Service Management Platform
SMP2P       Shared Memory Point to Point protocol (QCT)
SPS         Semi Persistent Scheduling
SRRC        State Radio Regulatory Commission of the People's Republic of China
            Square-Root Raised Cosine signals
STAR        所謂STAR原則,即Situation(情景)、Task(任務)、Action(行動)和Result(結果)
strenuous   費勁的
STK         SIM Tool Kit (中華電信工具箱?)

TAT         Test At Temperature. TAT is only tested for safe launch when a project 
                                starts to entering mass production line (C5). (WNC)
TCU         Truck Control Unit (?)
TE          Terminal Equipment, Test Equipment 
TEE         Trusted Exection Environment. (TrustZone is one)
TIS         Total Isotropic Sensitivity
TLMM        Top-Level Mode Mux (QCT, pin controller)
TPIU        Trace Port Interface Unit (ARM,CoreSight)
TRP         Total Radiated Power
TS16949     ADM2005
TTF         Time To Fix (GNSS)
TTFF        Time To First Fix (GNSS)
UEFI        Unified Extensible Firmware Interface
UFP         Upstream Facing Port, a USB (Type-C) port
            on a device or a hub that connects to 
            a host or DFP of a hub.
UIM         User Identity Module
UPnP        Universal Plug and Play
URLLC       Ultra Reliable and Low-Latency Communication (5G)
USIM        UMTS SIM.

VADC        Voltage measurement ADC (QCT)
VBMS        Voltage mode Battery Monitoring System (QTI)
VirtualSIM  No physical SIM.  Replaced by MODEM NV.

Waymo       一家研發自動駕駛汽車的公司,為Alphabet公司旗下的子公司。

2019年12月11日 星期三

Mount remote folder in Ubuntu

https://coderwall.com/p/zras0a/mount-remote-ssh-directory-in-ubuntu
    $ sudo apt-get install sshfs
    $ mkdir /your-cool-path/dir-name
    $ sshfs user@host:/path/to/foo ~/your-cool-path/dir-name