In Linux, system calls provide the interface between user space and the kernel space. These system calls cover a wide variety of functionality, such as file handling, process management, memory management, and inter-process communication.
Here’s a list of common Linux user-space system calls:
- Process Management:
-
fork()– Create a new process by duplicating the calling process. -
execve()– Execute a program. -
exit()– Terminate a process. -
wait()– Wait for a process to change state (usually for a child process). -
getpid()– Get the process ID of the calling process. -
getppid()– Get the parent process ID. -
kill()– Send a signal to a process. -
setuid()– Set the user ID of the calling process. -
setgid()– Set the group ID of the calling process.
- File Operations:
-
open()– Open a file. -
read()– Read from a file descriptor. -
write()– Write to a file descriptor. -
close()– Close a file descriptor. -
lseek()– Move the file offset. -
stat()– Get information about a file. -
fstat()– Get information about a file descriptor. -
mmap()– Map files or devices into memory. -
munmap()– Unmap memory regions. -
unlink()– Delete a file. -
rename()– Rename a file. -
mkdir()– Create a directory. -
rmdir()– Remove a directory. -
chmod()– Change file permissions. -
chown()– Change file owner and group. -
getcwd()– Get the current working directory. -
symlink()– Create a symbolic link. -
readlink()– Read the value of a symbolic link.
- Memory Management:
-
brk()– Set the end of the data segment. -
sbrk()– Increment or decrement the program’s data space. -
mmap()– Memory mapping a file or device into memory. -
munmap()– Unmap a memory region. -
mprotect()– Set protection on a memory region.
- Signal Handling:
-
signal()– Set a signal handler. -
sigaction()– Examine or change a signal action. -
sigprocmask()– Set or get the signal mask. -
sigpending()– Get pending signals for a process. -
kill()– Send a signal to a process.
- Inter-Process Communication:
-
pipe()– Create an anonymous pipe. -
shmget()– Allocate a shared memory segment. -
shmat()– Attach a shared memory segment to the address space. -
shmdt()– Detach a shared memory segment from the address space. -
msgget()– Create a message queue. -
msgsnd()– Send a message to a message queue. -
msgrcv()– Receive a message from a message queue. -
semget()– Create a semaphore set. -
semop()– Perform semaphore operations. -
semtimedop()– Perform timed semaphore operations.
- Networking:
-
socket()– Create a socket. -
bind()– Bind a socket to an address. -
listen()– Listen for incoming connections on a socket. -
accept()– Accept a connection on a socket. -
connect()– Connect to a socket. -
send()– Send data to a socket. -
recv()– Receive data from a socket. -
sendto()– Send data to a specified address. -
recvfrom()– Receive data from a specified address. -
shutdown()– Shutdown a socket. -
setsockopt()– Set socket options. -
getsockopt()– Get socket options.
- File System Management:
-
mount()– Mount a file system. -
umount()– Unmount a file system. -
getfsstat()– Get file system statistics. -
statfs()– Get file system statistics for a path.
- User and Group Management:
-
getuid()– Get the user ID of the calling process. -
geteuid()– Get the effective user ID of the calling process. -
getgid()– Get the group ID of the calling process. -
getegid()– Get the effective group ID of the calling process. -
setuid()– Set the user ID of the calling process. -
setgid()– Set the group ID of the calling process.
- Time Management:
-
time()– Get the current time. -
gettimeofday()– Get the current time with microsecond precision. -
clock_gettime()– Get the current time with clock ID. -
nanosleep()– Sleep for a specified time.
- Filesystem and Disk Operations:
-
fsync()– Synchronize a file’s in-memory state with storage. -
fdatasync()– Synchronize only data of a file with storage. -
fallocate()– Allocate space for a file. -
sync()– Flush file system buffers.
This list represents some of the most commonly used Linux system calls in user space. There are more calls available, especially for different architectures or specialized use cases, such as extended system calls for networking or real-time operations.