UNIX Programming

Unix is an operating system which means the suites of programs that makes the computer works. It handles all the activities from multiple users at same time. It was first developed in the 1960s at AT&T Bell Labs by Ken Thompson and Dennis Ritchie. Unix OS also have a graphical user interface (GUI) likes Microsoft Windows that helps user in easy to use environment. Some operations aren’t covered in GUI so the knowledge of UNIX is required.

What is Unix?

Unix is an operating system which consists of a set of programs that build interaction between the computer and the user. The system software that handles software resources, computer’s internals, and provides common services for computer programs is called the operation system or kernel. Users interacts with the kernel through a window known as the shell. It a command line interpreter. It translates the user’s commands into a language that is understood by the kernel. Multiple user can use a Unix computer at same time, so called a multiuser system.

There are various Unix variants that are available in the market. Here are the Some of Unix variants such as Solaris Unix, AIX, HP Unix, CentOS and BSD. Linux is most in demand of Unix which is freely available.

UNIX operating system

UNIX operating system is made up of three parts; the kernel, the shell and the programs.
  1. Kernel: The kernel is the hub of operating system. It is like the heart of OS that interacts with the computer hardware and handles most of the tasks such as task scheduling, memory management, file management etc.
  2. Shell: The shell is a medium through which users interacts with the kernel. It processes all your requests. When user login to the systems, login program checks username and password, and then shell interprets the command and execute the command as you want. The commands are themselves programs: when they terminate, the shell gives the user another prompt (% on our systems). The shell uses standard syntax for all commands. C Shell, Bourne Shell and Korn Shell are the most famous shells which are available with most of the Unix variants.
  3. Programs: There are various commands that are utilities in your day to day activities. Such as rm, mkdir, cp, mv, vi, cat and grep, etc. are few examples of commands and utilities.

One example that the shell and the kernel work together, suppose a user types rm fileName (which is command of removing the file fileName). The shell searches for the location for the file containing the program rm, and then requests the kernel, through system calls, to execute the program rm on fileName. When the process rm fileName has finished running, the shell then returns the UNIX prompt % to the user, indicating that it is waiting for further commands.

Basic Unix Commands

Listing files(ls):

If you want to see the list of files on your UNIX or Linux system, use the “ls” command.It shows the files /directories in your current directory.

[email protected]:~$ ls
Desktop    Downloads     Music       Videos     Documents     Pictures      examples.txt
[email protected]:~$ 

You can use “ls -R” to shows all the files not only in directories but also subdirectories

Listing Hidden Files:

Hidden items in UNIX/Linux begin with – “.” Symbol at the start, of the file or directory. Any Directory/file starting with a '.' will not be seen unless you request for it. To view hidden files, use the command.

[email protected]:~$ ls -a
                   
Creating & Viewing Files:

The 'cat' command is used to display text files. It can also be used for copying, combining and creating new text files.

To create a new file, use the command

[email protected]:~$ cat > fileName
[email protected]:~$ this is new file add content here 
//Press 'ctrl + d' to return to command prompt.
[email protected]:~$ cat fileName
                   

The syntax to combine 2 files is -

[email protected]:~$ cat file1 file2 > combinedfilename
Deleting Files:

The 'rm' command removes files from the system without confirmation. To remove a file use syntax -

[email protected]:~$ rm fileName

Other Important Commands

The 'history' command:

History command shows all the list of commands that you have used before to current terminal session. This can help you refer to the old commands you have entered and re-used them in your operations again.

[email protected]:~$ history
The 'man' command:

Man stands for manual which is a reference guide for a Linux operating system commands. It is similar to HELP file found in different software. The terminal would open the manual page for that command.

To get help on any command that you do not understand, you can type

[email protected]:~$ man                        
The 'clear' command:

This command clears all the mess up on the terminal and gives you a clean window to work on, just like when you launch the terminal.

[email protected]:~$ clear
Plagiarism Checker

FLAT 40% OFF !!! Order Now

FLAT 40% OFF !!!

Lets take Best opinion from our Expert Tutors Today! Order Now