These functions are the most commonly used useful Linux functions

Chapter 1 Primary I/O Functions

  • close function: close the opened file
  • creat function: create a file
  • dup function: Duplicate file descriptors
  • dup2 function: copy the file descriptor to the specified location
  • fcntl function: change the state of the file
  • fsync function: write buffer data back to disk file
  • Lseek function: move the read and write position of the file
  • open function: open a file read function: read the data of the file
  • sync function: write all open files back to disk
  • write function: output content to a file

Chapter 2 File Management Operation Functions

  • access function: determine whether the process has permission to access the file
  • alphasort function: sort directory structure alphabetically
  • chdir function: change the current working directory
  • chmod function: change file permissions
  • chown function: change the owner of a file
  • chroot function: change the root directory of the process
  • closedir function: close the directory file
  • fchdir function: use the file descriptor to change the current working directory
  • fchmod function: change the permissions of an open file
  • fstat function: get the status of an open file
  • truncate function: change the size of an open file
  • ftw function: traverse a directory tree
  • get_current_dir_name function: get the current working directory
  • getcwd function: get the current working directory of the process
  • lchown function: change the owner of a symbolic link file
  • link function: create a hard link
  • lstat function: get the file status of the symbolic link
  • nftw function: traverse a directory tree
  • opendir function: open directory file
  • readdir function: read the contents of a directory file
  • readlink function: read the contents of the symbolic link file itself
  • realpath function: convert a relative directory path to an absolute path
  • remove function: delete a file or directory
  • rename function: change the name or location of a file
  • rewinddir function: rewind directory file
  • seekdir function: file positioning function
  • stat function: get file status
  • symlink function: create a symbolic link
  • telldir function: get the reading position of the directory file
  • truncate function: change file size
  • umask: Set the permission mask to use when creating files
  • unlink function: delete a hard link to a file

Chapter 3 Standard I/O Functions

  • clearerr function: clear the error flag
  • fclose function: close the stream file descriptor
  • fdopen function: convert file descriptor to file pointer
  • feof function: end-of-file judgment function
  • fflush function: flush the flow file read and write cache
  • fgetc function: read a character from a stream file
  • fgetpos function: returns the current read and write position of the stream file
  • fgets function: read a line of data from a stream file
  • fileno function: get the file descriptor of the stream file
  • fopen function: open file
  • fputc function: write characters to stream file
  • fputs function: write string to stream file
  • fread function: read data from a stream file
  • freopen function: open a file
  • fseek function: move the read and write position of the stream file
  • fsetpos function: set the current read and write position of the stream file
  • ftell function: get the read position of the stream file
  • fwrite function: write data to the stream file
  • getc function: read a character from a file
  • getchar function: read a character from standard input
  • gets function: read a line of data from standard input
  • mktemp function: generate the filename of the temporary file
  • putc function: write characters to file
  • putchar function: output characters to standard output
  • puts function: print a string to standard output
  • rewind function: move the read and write position of the stream file to the beginning of the file
  • setbuf function: set the file buffer
  • setbuffer function: set the file buffer
  • setlinebuf function: set the line buffer mode
  • setvbuf function: set custom file buffer
  • tmpfile function: create a temporary binary file
  • ungetc function: write characters back to file

Chapter 4 Formatting Input and Output Functions

  • fprintf function: formatted output to file
  • fscanf function: format to read data from a file
  • printf function: formatted output
  • scanf function: formatted input
  • snprintf function: format character input
  • sprintf function: formatted string printing
  • sscanf function: format string value
  • vfprintf function: variadic output function
  • vfscanf function: formatted input
  • vprintf function: formatted output function
  • vscanf function: formatted input function
  • vsnprintf function: format string copy
  • vsprintf function: format string copy
  • vsscanf function: format character input

Chapter 5 Process Control

  • abort function: process abnormal termination function
  • atexit function: process termination handler
  • execl function: execute file function
  • execle function: the function that executes the file
  • execlp function: find files from the PATH environment variable and execute
  • execv function: execute the file
  • execve function: execute the file
  • execvp function: execute the file
  • exit function: function to end the process running
  • _exit function: function to end the process running
  • fork function: create a new process
  • getgid function: get the actual process group ID
  • getegid function: get the effective process group ID
  • getpid function: get the effective group ID
  • getppid function: get the process ID of the parent process
  • getpriority function: get the process execution priority
  • longjmp function: jump to the stack environment stored by the original setjmp
  • on_exit function: Set the function to be called before the normal end of the program
  • setjmp function: store the current stack environment
  • setgid function: set the process group ID of the process
  • setuid function: set the process group ID
  • setpriority function: set the program process priority
  • siglongjmp function: jump to the stack environment stored in the original sigset jmp
  • sigsetjmp function: store the current stack environment and masked signal set
  • system function: execute shell commands
  • vfork function: create a new process
  • wait function: wait for the child process to interrupt or end
  • waitpid function: wait for the child process to interrupt or end
  • wait3 function: wait for the process to end and output child process statistics

Chapter 6 Interprocess Communication Functions

  • ftok function: get the IPC key value related to the project
  • msgctl function: message queue operation function
  • msgget function: create or open a message queue
  • msgrcv function: read message queue
  • msgsnd function: write a message to the message queue
  • semctl function: semaphore operation function
  • semget function: create or open a semaphore
  • semop function: release or acquire semaphore
  • shmat function: import shared memory
  • shmctl function: shared memory operation function
  • shmdt function: detach shared memory from the program
  • shmget function: create shared memory
  • mkfifo function: create fifo pipeline function
  • pclose function: close the pipe file
  • pipe function: create an anonymous pipe
  • popen function: create a pipeline file

Chapter 7 Signal Functions

  • alarm function: kernel timer function
  • kill function: signal sending function
  • pause function: the process pauses the execution function
  • raise function: send a signal function to the process itself
  • sigaction function: advanced signal processing method setting function
  • sigaddset function: add signal to signal set function
  • sigdelset function: delete the corresponding signal function in the signal set
  • sigemptyset function: clear signal set function
  • sigfillset function: fill signal set function
  • sigismember function: test whether a signal is in the signal set
  • signal function: signal processing method setting function
  • sigpause function: Pause the process until the signal arrives
  • sigpending function: query pending signals
  • sigprocmask function: signal masking function
  • sigsuspend function: suspend until the signal arrives
  • sleep function: let the process sleep for a period of time

Chapter 8 User, Group Functions, and Environment Variable Functions

  • clearenv function: delete the value of all environment variables
  • cuserid function: get username function
  • endgrent function: close the system group file function
  • endpwent function: close the system password function
  • endutent function: close the utmp file
  • fgetgrent function: read group data from file
  • fgetpwent function: read password format data from file
  • getegid function: get the effective gid group identifier
  • getenv function: get the value of the environment variable
  • geteuid function: get the effective uid user identifier
  • getgid function: get the group identifier
  • getgrent function: read group information from the file /etc/group
  • getgrgid function: find group information from the file /etc/group
  • getgrnam function: find group information from the file /etc/group
  • getgroups function: returns the list of groups to which the current user belongs
  • getlogin function: Get the account name of the current user
  • getpw function: get the user information of the specified uid
  • getpwent function: read the data in the /etc/passwd file
  • getpwnam function: get user information by user name
  • getpwuid function: get user information by user ID
  • getuid function: Get the user ID to which the current process belongs
  • getutent function: get login information
  • getutid function: Get the login information of the specified user ID
  • getutline function: find the specified login information
  • initgroups function: initialize group information
  • logwtmp function: add login record information
  • putenv function: change the value of an environment variable
  • pututline function: add login information
  • setegid function: set the effective group ID
  • setenv function: change the value of an environment variable
  • seteuid function: set the effective user ID
  • setfsgid function: set the group ID of the file system of the process
  • setfsuid function: set the user ID of the file system of the process
  • setgid function: set the group ID of the process
  • setgrent function: move the read and write position of the file etc/group to the starting position
  • setgroups function: set the group identifier of the current process
  • setpwent function: move the read and write position of the file etc/passwd to the starting position
  • setregid function: set the real and effective group ID of the current process
  • setreuid function: set the real and effective user ID of the current process
  • setuid function: set the user ID of the process
  • setutent function: move the read and write position of the file utmp to the starting position
  • unsetenv function: clear the value of the environment variable
  • updwtmp function: write login data records to utmp file
  • utmpname function: set the absolute position of the file utmp

Chapter 9 Error Handling and Memory Allocation Functions

  • brk function: change the size of the data segment
  • calloc function: memory allocation function
  • ferror function: file error judgment
  • free function: release dynamically allocated memory function
  • getpagesize function: get the operating system memory page size function
  • malloc function: dynamic memory allocation function
  • mmap function: file mapping function
  • munmap function: release the mapped memory address
  • perror function: error cause output function
  • realloc function: memory interception function
  • sbrk function: increase data space
  • strerror function: error code query

Chapter 10 Logging, Dynamic, and Regular Expression Functions

  • closelog function: close the information record
  • dlclose function: close the dynamic library file
  • dlerror function: dynamic function error handling
  • dlopen function: open dynamic library file
  • dlsym function: find functions in dynamic library files
  • openlog function: open log information
  • regcomp function: compile regular expressions
  • regerror function: compile error judgment function
  • regexec function: perform regular matching
  • regfree function: release regular pattern string resources
  • syslog function: output logging information

Chapter 11 Time Functions

  • asctime function: string time manipulation function
  • clock function: Calculate the running time function
  • ctime function: string time function
  • difftime function: Calculate the time difference function
  • ftime function: get system time
  • gettimeofday function: get the current time of the system
  • gmtime function: calendar time format function
  • localtime function: get the current system time
  • mktime function: system time conversion function
  • settimeofday function: system time setting function
  • strftime function: time formatted output function
  • time function: get the current time of the system
  • tzset function: set the system time zone variable tzname

Chapter 12 Socket Related Functions

  • accept function: processing socket request function
  • bind function: bind the socket descriptor to a socket
  • connect function: connect to the remote host
  • endprotoent function: the read function that ends the network protocol
  • endservent function: close the file /etc/services
  • gethostbyaddr function: get host information by IP
  • gethostbyname function: get host information by host name
  • getprotobyname function: get protocol data by protocol name
  • getprotobynumber function: get protocol data by protocol number
  • getprotoent function: read the network protocol data in the file /etc/rotoent
  • getservbyname function: get network service protocol data
  • getservbyport function: get network service protocol data
  • getservent function: read host network service data
  • getsockopt function: get the status of the specified socket descriptor
  • herror function: error cause output function
  • hstrerror function: error code query
  • htonl function: address byte order conversion
  • htons function: address byte order conversion
  • inet_addr function: network address type conversion
  • inet_aton function: network address type conversion
  • inet_ntoa function: network address type conversion
  • listen function: network socket listening
  • ntohl function: address byte order conversion
  • ntohs function: address byte order conversion
  • recv function: receive message
  • recvfrom function: receive message
  • recvmsg function: read data from multiple buffers
  • send function: send data to the remote host
  • sendto function: send data to the remote host
  • setprotoent function: open the network protocol file
  • setservent function: open the network service file
  • setsockopt function: set the state of the socket descriptor
  • shutdown function: end socket socket
  • socket function: create a network socket

Chapter 13 Character Test Functions

  • isalnum function: determine whether the character is an English letter or a number
  • isalpha function: determine whether the character is an English letter
  • isascii function: determine whether a character is an ASCII character
  • isblank function: determine whether the character is a blank character
  • iscntrl function: determine whether the character is an ASCII control character
  • isdigit function: determine whether the character is an Arabic numeral
  • isgraph function: determine whether a character is a printable character
  • islower function: determine whether the character is a lowercase English letter
  • isprint function: determine whether a character is a printable character
  • isspace function: determine whether the character is a space character
  • ispunct function: determine whether a character is a punctuation mark
  • isupper function: determine whether the character is an uppercase English letter
  • isxdigit function: determine whether a character is a hexadecimal number

Chapter 14 Data Conversion Functions

  • atof function: convert string to floating point number
  • atoi function: convert string to integer
  • atol function: convert string to long integer
  • ecvt function: convert floating point number to string
  • fcvt function: convert floating point number to string
  • gcvt function: convert float to string
  • strtod function: convert string to float
  • strtol function: convert string to long integer
  • strtoul function: convert string to unsigned long integer
  • toascii function: convert integers to legal ASCII characters
  • tolower function: convert uppercase letters to lowercase letters
  • toupper function: convert lowercase letters to uppercase letters

Chapter 15 String Handling Functions

  • bcmp function: compare the contents of two blocks of memory
  • bcopy function: copy the contents of memory
  • bzero function: clear the contents of a block of memory to zero
  • ffs function: find the first true bit in an integer
  • index function: find the first occurrence of a specified character in a string
  • memccpy function: copy the contents of memory
  • memchr function: find a specified character in a specified range of memory
  • memcmp function: compare the contents stored in memory
  • memcpy function: copy the contents of a block of memory to another block
  • memfrob function: recode a memory area
  • memmove function: copy memory contents
  • memset function: fill a value into a memory area
  • rindex function: find the last occurrence of a specified character in a string
  • strcasecmp function: compare strings ignoring case
  • strcat function: concatenate one string to the tail of another string
  • strchr function: find the specified character in a string
  • strcmp function: compare two strings
  • strcoll’s function: compare strings according to the current environment information
  • strcpy function: copy the contents of one string into another string
  • strcspn function: Calculate the length of a substring in a string consisting of characters other than the specified charset
  • strdup function: copy string content
  • strfry function: Randomly reorganize a string
  • strlen function: returns the length of the string
  • strncasecmp function: compare two strings ignoring case
  • strncat function: concatenate the first n characters of one string to the end of another string
  • strncmp function: compare two strings
  • strncpy function: copy string
  • strpbrk function: find the first occurrence of a specified character in a string
  • strrchr function: finds the last occurrence of a specified character in a string
  • strspn function: Calculate the length of a substring composed of characters of the specified character set in a string

Chapter 16 Mathematical Computation Functions

  • abs function: Calculate the absolute value of an integer
  • acos function: Calculate the value of the arc cosine
  • asin function: Calculate the value of the arc sine
  • atan function: Calculate the value of the arctangent
  • atan2 function: Calculate the value of the arctangent
  • ceil function: computes the smallest integer greater than or equal to a given argument
  • cos function: Calculate the value of the cosine
  • cosh function: Calculate the cosine of a hyperbola
  • div function: Calculate the quotient and remainder after dividing two integers
  • exp function: Calculate the exponent of a floating point number
  • fabs function: Calculate the absolute value of a floating point number
  • frexp function: Compute the mantissa and exponent of a floating-point number
  • hypot function: Calculate the length of the hypotenuse of a right triangle
  • labs function: Calculate the absolute value of a long integer
  • ldexp function: Calculate the product of a floating point number and 2 to the exp power
  • ldiv function: Calculate the quotient and remainder after dividing two long integers
  • log function: calculates the logarithmic value to the base e
  • log10 function: Calculates the logarithmic value to base 10
  • modf function: decompose a floating point number into fractional and integer parts
  • pow function: calculate the power value
  • sin function: take the value of the sine
  • sinh function: Calculate the sine of a hyperbola
  • sqrt function: Calculate the square root of a floating point number
  • tan function: Calculate the tangent of an angle
  • tanh function: Calculate the value of the tangent function of a hyperbola

Chapter 17 Random Numbers and Data Encryption Functions

  • crypt function: use the DES algorithm to encode a string
  • drand48 function: generate a positive random floating point number
  • erand48 function: generate a positive random floating point number
  • initstate: Create a random number state array
  • jrand48 function: generate a long integer random number
  • lcong48 function: set the random number seed for 48-bit operations
  • lrand48 function: generate a positive long integer random number
  • mrand48 function: generate a long integer random number
  • nrand48 function: generate a positive long integer random number
  • rand function: generate pseudo-random numbers
  • random function: generate random numbers
  • seed48 function: set the random number seed for 48-bit operations
  • setstate function: create a random number state array
  • srand function: set the random number seed
  • srand48 function: set the random number seed for 48-bit operations
  • srandom function: set the random number seed
  • getpass function: get the user input password string

Chapter 18 Data Structure Functions

  • bsearch function: binary search data in sorted array
  • hcreate function: create a hash table
  • hdestroy function: delete hash table
  • hsearch function: find key data in hash table
  • lfind function: linear search
  • lsearch function: linear search
  • qsort function: Sort an array using quicksort
  • tdelete function: delete data from a binary tree
  • tfind function: search binary tree
  • tsearch function: search a binary tree
  • twalk function: traverse a binary tree

Chapter 19 Other Functions

  • getopt function: analyze command parameters
  • isatty function: determine whether the file descriptor is a terminal
  • pselect function: multiplexing I/O
  • select function: multiple I/O transfer
  • ttyname function: returns the name of the terminal

You may also like...

Leave a Reply

Your email address will not be published.