LinuxCommandLibrary
GitHubF-DroidGoogle Play Store

unlink

Remove a single file via the unlink(2) system call

TLDR

Remove a regular file
$ unlink [file]
copy
Remove a symbolic link (removes the link, not the target)
$ unlink [symlink]
copy
Display version information
$ unlink --version
copy

SYNOPSIS

unlink FILEunlink OPTION

DESCRIPTION

unlink calls the unlink(2) system call to remove the directory entry for a single file. It accepts exactly one operand and has no options for recursion, interactive prompting, or force behavior.When the last link to a file is removed and no process still has it open, the underlying inode and data blocks are freed. For files with multiple hard links, only the named link is removed; data remains accessible through the remaining links. Removing a symbolic link deletes the link itself, not the target.Unlike rm, unlink cannot operate on directories, cannot accept multiple operands, and does not expand shell globs specially. This minimalism makes it predictable for scripts that need to remove exactly one path with no risk of accidentally matching additional files.

PARAMETERS

FILE

Exactly one file path to unlink.
--help
Display a brief help message and exit.
--version
Output version information and exit.

INSTALL

sudo apt install coreutils
copy
sudo dnf install coreutils
copy
sudo pacman -S coreutils
copy
sudo apk add coreutils
copy
sudo zypper install coreutils
copy
brew install coreutils
copy
nix profile install nixpkgs#coreutils
copy

CAVEATS

Only a single operand is accepted; passing two or more arguments is an error. Directories cannot be removed — use rmdir(1) or rm -r for that. Many shells ship unlink as a utility from GNU coreutils; the built-in shell form (e.g. in ksh) may behave slightly differently.

HISTORY

unlink is a long-standing Unix utility that exposes the unlink(2) system call. The GNU coreutils implementation conforms to POSIX.1-2001.

SEE ALSO

rm(1), rmdir(1), ln(1)

Braincup
Open source brain training for math, memory and focus
Braincup mini-games
41 mini-games · Apache-2.0
No ads · No tracking
Play in browser
Download Braincup on the App StoreGet Braincup on Google PlayGet Braincup on F-Droid
276 stars
From the maker of Linux Command Library
Copied to clipboard
Braincup
Open source brain training for math, memory and focus. 41 mini-games, from mental arithmetic to Sudoku, N-Back and Solo Chess.
Apache-2.0 licensed · No ads · No tracking · No account
From the maker of Linux Command Library
Download Braincup on the App StoreGet Braincup on Google PlayGet Braincup on F-Droid