Simple Unix Commands
COMMAND | DESCRIPTION | USAGE EXAMPLE | NOTES ON EXAMPLE |
---|---|---|---|
man | view the online documentation | man cd | The manual pages for the cd command are displayed at your terminal. |
cat / more / less | list a file on standard output (default standard output is the terminal) | cat .bashrc | The contents of the .bashrc file are displayed. cat displays the whole file at once, whereas more and less display a screen at a time. |
head | list the beginning of a file on standard output | head -50 myfile | The first 50 lines of "myfile" are displayed. |
tail | list the end of a file on standard output | tail -70 myfile | The last 70 lines of "myfile" are displayed. |
cp | copy a file | cp oldfile newfile | A copy of "oldfile" is made, and saved as "newfile". |
mv | move a file | mv oldfile newfile | The file "oldfile" is moved (renamed) to a file called "newfile". |
rm | remove / delete a file | rm tempfile | Remove (delete) the file called temp. |
ls | list the contents of a directory | ls mydir | Lists the contents for the "mydir" directory. If the directory name is omitted, current directory is assumed. |
chmod | change the access permissions of a file | chmod ugo+rwx file | Allow owner, group and others read, write and execute permission for file. |
pwd | print working directory | pwd | Gives the full pathname of the directory in which you are currently working. |
cd | change directory | cd subdir | Change to a "subdir" directory as specified. |
mkdir | make / create a new directory | mkdir subdir | Creates a directory called subdir as a subdirectory of your current directory. |
rmdir | remove / delete a directory | rmdir subdir | Removes subdir, only if it is empty (contains no files). |
vi | invoke the vi (vim) editor | vi newfile | Edit the file newfile. If newfile does not exist, an empty file is opened for editing. |
diff | compare two files and show the differences | diff file1 file 2 | Compares file1 with file2. |
grep | search for a regular expression in a file | grep error file1 | Prints out every line of the file "file1" which contains the string "error". Additionally, you can also use wildcards in the search pattern. |
kill | terminate a process which is owned by you | kill 1234 | Terminate the process with process id 1234 . |