----------------------------------------------------------------
----------------------
BASIC UNIX COMMANDS
----------------------------------------------------------------
----------------------
1. Command : mkdir
Description : used to create a new directory.
Syntax : mkdir [directory_name]
Example : mkdir set1 - This would create a new directory called set1.
2. Command : cd
Description : used to change into a new directory.
Syntax : cd [directory name]
Example : cd set1
3. Command : rmdir
Description : Used to Delete a directory. Before deleting the directory it must be
empty
Syntax : rmdir [Directory name]
Example : rmdir set1 - removes the directory set1
4. Command : pwd
Description : Short for print working directory the pwd command displays the
name of the current working directory.
Syntax : pwd
Example : pwd - Typing pwd at the prompt would Result in something similar
to:
/home/computerhope/public_html
5. Command : ls
Description : Lists the contents of a directory.
Syntax : ls
[Link] : man
Description:
The man command which is short for manual provides in depth information
about the requested command or allows users to search for commands related to
a particular keyword.
Syntax : man [-] [-k keywords] topic
7. Command : mv
Description : Renames a file or moves it from one directory to another directory
Syntax : mv oldname newname
Example :
mv [Link] newdirectory/
- moves the file [Link] to the directory newdirectory
8. Command : rm
Description : Deletes a file without confirmation (by default).
Syntax : rm [-f] [-i] [-R] [-r] [filenames | directory]
Example : rm [Link]
Remove the file [Link] without prompting the user.
rm -r directory
Remove a directory, even if files exist in that directory.
9. Command : ls -l
Description : it shows permissions and other information of files and directories
Syntax : ls -l $ls--- listing of files
Example : ls -l
10. Command : vi
Description : Text editor for unix
Syntax : vi filename
Example :
vi [Link]
Opens a text file named [Link]
To get into insert/input mode press i
To get out of insert/input mode press esc
:wq for save and quit
:q! for do not save and quit
11. Command : python [Link]
Description : Used to execute python program
Syntax : python [Link]
Example : python [Link]
12. Command : clear
Description : Used to clear the screen
Syntax : clear
Example : clear
Viva Questions:
1. What is the use of “mkdir” command.
2. Write UNIX command for copying contents of one file into another file.
3. Write UNIX command for clearing the screen.
4. Write UNIX command to print the current working directory.
5. How to list the contents of a directory in UNIX?
6. Explain about different modes supported by vi editor.
7. Write the command to open a file in vi editor.
8. Write the command to exit vi editor without saving contents of the file.
9. Write the command to exit vi editor after saving the contents of the file.
10. Which key is used for switching from insert mode to normal mode.
12. Write the command to compile a python source file “[Link]”.