Developers somtimes may not need to be an expert in UNIX. But you should be aware of some basic UNIX commands to simplify the work in day to day operations. These commands can be utilized in number of ways but I have described here those that are commonly used by Oracle programmers.
This is a kind of help command of UNIX. The man command displays the syntax of the command passed as an argument with it. In other words, if you are unaware of the syntax of a command man is your weapon.
[loginuser ~]$ man cp Displays the purpose, synopsis and description of cp command
This command lists directory contents of the directory from where it is executed. The ls command lists information about files of the current directory, sorting them alphabetically by default unless mentioned separately.
[loginuser ~]$ ls Displays list of directories and files present in the current path
vi / vim
This command is a plain text editor for the programmers available on all UNIX and LINUX systems. Now the UNIX versions contain both vi as well as vim commands. The vim command is upward compatible to vi command. The main purpose of vi and vim is to edit programs or files written by the programmers.
There are lot of enhancements in vim above vi: multi-level undo, multi windows and buffers, syntax highlighting, command line editing, filename completion, on-line help, visual selection, etc.
vim [options] [file..]
[loginuser ~]$ vim abc.txt Opens the file abc.txt to edit for the programmers
Exit from vim/vi command
Escape +:q! is the command to exit from the file you are editing without saving the changes.
Escape +:wq! is the command to save the changes and exit from the file you are editing.
This command prints the name of the current/working directory. The pwd command is very handy when you want to know at which path you wish to execute other commands.
[loginuser ~]$ pwd
This command creates new directories on the path you execute it.
[loginuser ~]$ mkdir dir1 This will create directory named dir1 in existing path
This command is used to change directories. Suppose you want to jump on to other directory from the existing one write the directory path after cd command.
[loginuser ~]$ cd /home/test This will change the directory to /home/test
This command copies files and directories from source path to destination path.
cp [source directory/file] [destination directory/file]
[loginuser ~]$ cp file1.txt file2.txt This will create new file file2.txt and copy the data in it from file1.txt
This command is handy when we need to move or rename certain file or directory.
mv [source directory/file] [destination directory/file]
[loginuser ~]$ mv file1.txt /home/test/file2.txt This will move file file1.txt to path /home/test as file2.txt
This command prints current date and time along with time zone.
[loginuser ~]$ date
This command determines the default printer.
[loginuser ~]$ echo $PRINTER
To determine the path of directory where the Oracle database is installed, this command is used.
[loginuser ~]$ echo $ORACLE_HOME
This command change access permissions of files.
chmod [MODE] [filename]
[loginuser ~]$ chmod 777 abc.txt
Mostly the files are required to be changed to 755 or 777 mode for Oracle programmers.
This command concatenates file and prints on the standard output. It also helps in creation of new files.
cat [OPTION] [FILE]
[loginuser ~]$ cat>xyz.txt This command will create file xyz.txt in the existing directory
If the file already exists then cat command will overwrite whatever is there in it by the new text you write.
[loginuser ~]$ cat>abc.txt
Exit cat command
To exit from cat command press Ctrl + C.
The grep is the command utility to search for the pattern of text that is specified on the command line.
grep [OPTION] PATTERN [FILE]
[loginuser ~]$ grep “test” apple.txt This command will search and displays line containing “test” string pattern in it [loginuser ~]$ grep “test” apple* This command will search and display lines containing string pattern “test” along with the file name [loginuser ~]$ grep –r test /home/test This command will search and display paths and filenames containing the word “test” in it
The usages of grep command are many more but I have shown only three that are used particularly by Oracle developers.
This command displays host name of the current system.
[loginuser ~]$ hostname
This command clears the terminal screen.
[loginuser ~]$ clear
Hope you like this article and find it useful. We highly appreciate comments and feedback.
Hi I am Paras.
Thanks for stopping by at OracleMine.com. Speaking about my brief introduction, I work for a multinational organisation in Oracle related technologies. Being an avid blogger, I would like to inform you about my productivity and motivational blog XpressPlanet.com. Speaking of OracleMine.com, I will try my best to share knowledge on technologies in as simple and understandable manner as possible. You can also contribute your knowledge on OracleMine by writing to us at email@example.com. Again I appreciate your visit. Hope to see you again and again!