Unix File Commands

What is Unix ?

Unix is a multi-user, multitasking operating system (OS) that provides a command-line interface for users to interact with the computer.

It was first developed in the late 1960s and early 1970s at Bell Labs by a group of computer scientists and engineers, including Ken Thompson and Dennis Ritchie.

Below is the consolidated table for unix file command:

Here is a table with a list of common Unix file management commands and their syntax and examples:

lsls [options] [file or directory]List the contents of a directoryls – List contents of current directory <br> ls /tmp – List contents of /tmp directory
cdcd [directory]Change the current working directorycd /tmp – Change to /tmp directory
cpcp [options] source destinationCopy files or directoriescp file1 file2 – Copy file1 to file2 <br> cp -r dir1 dir2 – Copy dir1 and its contents to dir2
mvmv [options] source destinationMove or rename files or directoriesmv file1 file2 – Rename file1 to file2 <br> mv dir1 dir2 – Move dir1 to dir2
rmrm [options] file(s)Remove files or directoriesrm file1 – Remove file1 <br> rm -r dir1 – Remove dir1 and its contents
touchtouch [options] file(s)Create a new empty file or update the modification time of an existing filetouch file1 – Create a new file1 or update its modification time
mkdirmkdir [options] directory(ies)Create a new directorymkdir dir1 – Create a new directory named dir1

more on file Commands:

catcat [options] file(s)Concatenate and display filescat file1 – Display the contents of file1
>command > fileRedirect the output of a command to a filels > file1 – Redirect the output of the ls command to file1
moremore [options] fileDisplay the contents of a file one screen at a timemore file1 – Display the contents of file1 one screen at a time
headhead [options] file(s)Display the first N lines of a filehead -n 5 file1 – Display the first 5 lines of file1
tailtail [options] file(s)Display the last N lines of a filetail -n 5 file1 – Display the last 5 lines of file1
rmrm [options] file(s)Remove filesrm file1 – Remove file1
rm -rrm -r [options] directory(ies)Remove directories and their contentsrm -r dir1 – Remove directory dir1 and its contents
rm -rfrm -rf [options] directory(ies)Remove directories and their contents, including any files that are write-protectedrm -rf dir1 – Remove directory dir1 and its contents, including write-protected files

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top