16 Basic Unix Commands You Need To Know As A Programmer

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.

man

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.

Syntax

man [command]

Example

[loginuser ~]$ man cp

Displays the purpose, synopsis and description of cp command

ls

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.

Syntax

ls

Example

[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.

Syntax

vim [options] [file..]

Example

[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.

pwd

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.

Syntax

pwd

Example

[loginuser ~]$ pwd

mkdir

This command creates new directories on the path you execute it.

Syntax

mkdir

Example

[loginuser ~]$ mkdir dir1

This will create directory named dir1 in existing path

cd

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.

Syntax

cd [path]

Example

[loginuser ~]$ cd /home/test

This will change the directory to /home/test

cp

This command copies files and directories from source path to destination path.

Syntax

cp [source directory/file] [destination directory/file]

Example

[loginuser ~]$ cp file1.txt file2.txt

This will create new file file2.txt and copy the data in it from file1.txt

mv

This command is handy when we need to move or rename certain file or directory.

Syntax

mv [source directory/file] [destination directory/file]

Example

[loginuser ~]$ mv file1.txt /home/test/file2.txt

This will move file file1.txt to path /home/test as file2.txt

date

This command prints current date and time along with time zone.

Example

[loginuser ~]$ date

echo $PRINTER

This command determines the default printer.

Example

[loginuser ~]$ echo $PRINTER

echo $ORACLE_HOME

To determine the path of directory where the Oracle database is installed, this command is used.

Example

[loginuser ~]$ echo $ORACLE_HOME

chmod

This command change access permissions of files.

Syntax

chmod [MODE] [filename]

Example

[loginuser ~]$ chmod 777 abc.txt

Mostly the files are required to be changed to 755 or 777 mode for Oracle programmers.

cat

This command concatenates file and prints on the standard output. It also helps in creation of new files.

Syntax

cat [OPTION] [FILE]

Example

[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.

grep

The grep is the command utility to search for the pattern of text that is specified on the command line.

Syntax

grep [OPTION] PATTERN [FILE]

Example

[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.

hostname

This command displays host name of the current system.

Example

[loginuser ~]$ hostname

clear

This command clears the terminal screen.

Example

[loginuser ~]$ clear

Hope you like this article and find it useful. We highly appreciate comments and feedback.

You can also Subscribe here to stay updated on latest posts of Oraclemine.com.

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 hioraclemine@gmail.com. Again I appreciate your visit. Hope to see you again and again!

Leave a Reply

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.