Unlink (Unix)

unlinkOperating system| Unix and Unix-like

|

Platform| Cross-platform
Type| Command

In Unix-like operating systems, unlink is a system call and a command line utility to delete files. The program directly interfaces the system call, which removes the file name and (but not on GNU systems) directories like rm and rmdir.[1] If the file name was the last hard link to the file, the file itself is deleted as soon as no program has it open.[2]

It also appears in the PHP, Node.js, R, Perl and Python standard libraries in the form of the unlink() built-in function. Like the Unix utility, it is also used to delete files.[3][4][5][6]

## Examples

To delete a file named foo, one could type:

% unlink foo

In PHP, one could use the following function to do the same:

unlink("foo");

The Perl syntax is identical to the PHP syntax, save for the parentheses:

unlink "foo";

In Node.js it is almost the same as the others:

fs.unlink("foo", callback);

In R (with the S language compatibility):

unlink("foo")
#Comment: using the inside argument 'recursive = TRUE', directories can be deleted

Similarly in Python:

os.unlink("foo")

## See also

* List of Unix commands
* link (Unix)
* ln (Unix)

## References

1. ↑ "GNU Coreutils: unlink invocation". https://www.gnu.org/software/coreutils/manual/html_node/unlink-invocation.html.
2. ↑ "unlink". https://pubs.opengroup.org/onlinepubs/9699919799/functions/unlink.html.
3. ↑ "PHP: unlink - Manual". https://php.net/unlink.
4. ↑ "unlink - perldoc.perl.org". https://perldoc.perl.org/functions/unlink.html.
5. ↑ "File System - Node.js v13.0.1 Documentation". https://nodejs.org/api/fs.html#fs_fs_unlink_path_callback.
6. ↑ "os — Miscellaneous operating system interfaces — Python 3.8.0 documentation". https://docs.python.org/3/library/os.html#os.unlink.

* v
* t
* e

Unix command-line interface programs and shell builtins

File system|

* cat
* chmod
* chown
* chgrp
* cksum
* cmp
* cp
* dd
* du
* df
* file
* fuser
* ln
* ls
* mkdir
* mv
* pax
* pwd
* rm
* rmdir
* split
* tee
* touch
* type
* umask

Processes|

* at
* bg
* crontab
* fg
* kill
* nice
* ps
* time

User environment|

* env
* exit
* logname
* mesg
* talk
* tput
* uname
* who
* write

Text processing|

* awk
* basename
* comm
* csplit
* cut
* diff
* dirname
* ed
* ex
* fold
* head
* iconv
* join
* m4
* more
* nl
* paste
* patch
* printf
* sed
* sort
* strings
* tail
* tr
* uniq
* vi
* wc
* xargs

Shell builtins|

* alias
* cd
* echo
* test
* unset
* wait

Searching|

* find
* grep

Documentation|

* man

Software development|

* ar
* ctags
* lex
* make
* nm
* strip
* yacc

Miscellaneous|

* bc
* cal
* expr
* lp
* od
* sleep
* true and false

* Categories
* Standard Unix programs
* Unix SUS2008 utilities
* List

0.00

(0 votes)

|

Retrieved from "https://handwiki.org/wiki/index.php?title=Software:Unlink_(Unix)&oldid=541197"
*[v]: View this template
*[t]: Discuss this template
*[e]: Edit this template