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:
Command | Syntax | Description | Example |
---|---|---|---|
ls | ls [options] [file or directory] | List the contents of a directory | ls – List contents of current directory <br> ls /tmp – List contents of /tmp directory |
cd | cd [directory] | Change the current working directory | cd /tmp – Change to /tmp directory |
cp | cp [options] source destination | Copy files or directories | cp file1 file2 – Copy file1 to file2 <br> cp -r dir1 dir2 – Copy dir1 and its contents to dir2 |
mv | mv [options] source destination | Move or rename files or directories | mv file1 file2 – Rename file1 to file2 <br> mv dir1 dir2 – Move dir1 to dir2 |
rm | rm [options] file(s) | Remove files or directories | rm file1 – Remove file1 <br> rm -r dir1 – Remove dir1 and its contents |
touch | touch [options] file(s) | Create a new empty file or update the modification time of an existing file | touch file1 – Create a new file1 or update its modification time |
mkdir | mkdir [options] directory(ies) | Create a new directory | mkdir dir1 – Create a new directory named dir1 |
more on file Commands:
Command | Syntax | Description | Example |
---|---|---|---|
cat | cat [options] file(s) | Concatenate and display files | cat file1 – Display the contents of file1 |
> | command > file | Redirect the output of a command to a file | ls > file1 – Redirect the output of the ls command to file1 |
more | more [options] file | Display the contents of a file one screen at a time | more file1 – Display the contents of file1 one screen at a time |
head | head [options] file(s) | Display the first N lines of a file | head -n 5 file1 – Display the first 5 lines of file1 |
tail | tail [options] file(s) | Display the last N lines of a file | tail -n 5 file1 – Display the last 5 lines of file1 |
rm | rm [options] file(s) | Remove files | rm file1 – Remove file1 |
rm -r | rm -r [options] directory(ies) | Remove directories and their contents | rm -r dir1 – Remove directory dir1 and its contents |
rm -rf | rm -rf [options] directory(ies) | Remove directories and their contents, including any files that are write-protected | rm -rf dir1 – Remove directory dir1 and its contents, including write-protected files |