Basic knowledge of advanced programming in Unix (3)

Source: Internet
Author: User

After reading the third chapter of advanced programming in the Unix environment, I also typed the code myself. I also explained some IO functions, including read/write/fseek/fcntl; here is mainly a C function, which is easier to understand. The fcntl function is well explained. It can obtain and change the attributes of the opened file (read-only, write-only, etc. Note the difference between the function and STAT ), the following describes some commands and concepts used for learning:

The LS command indicates that the List displays the name of the file in the current directory. Note that the parameter is not added to show the names of all files and directories except hidden files.

1) ls-A displays all files in the current directory, including hidden files.

2) ls-l displays the file and its details.

$ LS-l
Total 56
-Rwxrw-RW-1 zcx 1840 20:19 alloc. h
-Rwxrwxr-x 1 zcx 8078 21:48 A. Out
-Rwxrw-RW-1 zcx 4754 16:37 apue. h
-Rwxrw-RW-1 zcx 2021 May 24 2005 Error. c
-RW-r -- 1 zcx 16394 August 18 21:48 file. Hole
Drwxrwxr-x 2 zcx 4096 August 17 21:50 firstchapter
-RW-r -- 1 zcx 391 August 18 21:48 holefile3.2.c
-RW-r -- 1 zcx 139 August 17 21:56 lseek3.1.c
Drwxrwxr-x 2 zcx 4096 August 18 11:15 secondchapter
Drwxrwxr-x 2 zcx 4096 August 18 21:41 thirdchapter
-RW-r -- 1 zcx 271 August 1 09:44 ws_fork.c

What are the details of the displayed files?

Total 56 indicates that the total file size in the current directory is 56 K (the size of each directory is calculated as 4 K)

Drwxr-XR-X contains three types of characters: "-" indicates a common file, "D" indicates a directory, "L" indicates a connection file, and "B" indicates a device file.

Each of the following nine characters is a group of three, representing the file owner, the user group where the file owner is located, and the permissions of other users on the file. The three characters in each group indicate the read, write, and execute permissions respectively. If no permission exists, use. The execution permission has two optional characters: "X" indicates executable, and "S" indicates a set of interface files.

The following number 2 indicates the number of directory files under the "AA" Directory (This number = number of Hidden Directories + number of common Directories ). Go to the "AA" directory and run the LS-Al command. (To see the hidden file, add the-a parameter ).

Total 112
Drwxrwxr-x 5 zcx 4096 August 18 21:48.
Drwxrwxr-x 4 zcx 4096 August 3 10:18 ..
-Rwxrw-RW-1 zcx 1840 20:19 alloc. h
-Rwxrwxr-x 1 zcx 8078 21:48 A. Out
-Rwxrw-RW-1 zcx 4754 16:37 apue. h
-Rwxrw-RW-1 zcx 2021 May 24 2005 Error. c
-RW-r -- 1 zcx 16394 August 18 21:48 file. Hole
Drwxrwxr-x 2 zcx 4096 August 17 21:50 firstchapter
-RW-r -- 1 zcx 391 August 18 21:48 holefile3.2.c
-RW-r -- 1 zcx 12288 21:45. holefile3.2.c. swn
-RW ------- 1 zcx 12288 August 18 11:31. holefile3.2.c. SWO
-RW ------- 1 zcx 12288 August 18 11:31. holefile3.2.c. SWP
-RW ------- 1 zcx 12288 August 18 21:45. Ho. SWP
-RW-r -- 1 zcx 139 August 17 21:56 lseek3.1.c
Drwxrwxr-x 2 zcx 4096 August 18 11:15 secondchapter
Drwxrwxr-x 2 zcx 4096 August 18 21:41 thirdchapter
-RW-r -- 1 zcx 271 August 1 09:44 ws_fork.c
Zcx is distributed as the user name and group user name, followed by the file or directory size, followed by the last modification time.

Linux redirection

I saw it. /. out 2 2> temp. the Foo command found the redirection problem on the Internet, which meant to redirect the standard error message to temp. foo (0 file descriptor represents the standard input, 1 represents the standard output, and 2 represents the standard error message ).

Here I recommend a web site, the author of the more detailed, I don't want to know: http://www.cnblogs.com/wawlian/archive/2012/12/16/2820351.html

Basic knowledge of advanced programming in Unix (3)

Contact Us

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

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.