The SHELL problem encountered today-general Linux technology-Linux programming and kernel information. The following is a detailed description. In linux, how to use a script to obtain the permissions of a file is to convert the permissions in the form of-rwx -- x to 711. Remember to use chmod 711 for recovery.
At the beginning, I used ls-l to get the data, and then printed the first column with awk. I was going to use the lookup method, later, I couldn't figure out how to analyze every character in-rwx -- x in SHELL, so I gave up;
In the/usr/bin directory, locate the ls-l * acl * command: getfacl. You can get the acl of the file, contains the permissions of the owner, group, and other users on the file, but s and S cannot be obtained;
I want to write a small program in C and call the stat () function to obtain the attributes of the file so as to obtain all the permission attributes. I didn't expect man stat to find that linux itself has a stat command, I took a closer look and met my requirements.
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.
A Free Trial That Lets You Build Big!
Start building with 50+ products and up to 12 months usage for Elastic Compute Service