Wednesday 17 August 2011

Renaming files in Unix

Following are the commands used for renaming files in Unix,

1) $mv fileoriginal filerenamed

The above command is used to rename the file with name, 'fileoriginal' to the new name, 'filerenamed'.

2) $mv diroriginal dirrenamed

The above command is used to rename directory.

Creating files in Unix

There are 2 ways to create files in Unix. They are as follows,

1) touch
2) cat

1) touch

Syntax: $touch filecreated

The above command creates an empty file with the name 'filecreated'. This is mainly used when there is a need to create more empty files.

Eg: $touch filecreated1 filecreated2 filecreated3

In the above example, totally 3 empty files will be created in the given names.

2) cat

Syntax: $cat > filecreated

Press Enter, then type lines you want to be in the file 'filecreated'.
Press Ctrl+D for End of Line (EOF).
It saves the file and again it comes into $ mode.

Other usages of cat:

1) $cat filecreated

This command will display the contents of file, 'filecreated'.

2) $cat filecreated1 filecreated2 > filemerged3

The above command will store the contents of 'filecreated1' and 'filecreated2' in the file, 'filemerged3'. The contents of 'filemerged3' is overwritten.

To append the contents to the file, 'filemerged3', use the below command,

$cat filecreated1 filecreated2 >> filemerged3


Unix File System

Unix treats and understands everything as a file. For a beginner, lets consider unix is made of files and directories.

Here is Unix file structure,




















Each folder has its significance here.

unix -> Unix kernel is available here
bin -> Executable files for unix commands are found here. These files can be written in C program or Shell program.
lib -> Has all library functions provided by Unix for programmers.
dev -> Contains files that control various I/O devices like terminals, printers, disk drivers etc..
usr -> It has a directory for each user. Created by sys admin while creating an account.
tmp -> Stored temporary files created by users/Unix. These files are deleted at the time of restart and shutdown.

Friday 29 July 2011

Unix - Features

Multi-User System:

Multiple users can use one system at the same time. Each user will be having different terminals and keyboards, and yes ofcourse, with their own login userid and password to enter. There will be one host machine, whose memory and resources are used by these users. And one user's data is protected from that of other user's.

Multi-tasking:

More than one task can be executed simultaneously. Each task will be given few milliseconds to process. At a time single task will be in the system. But as the switch time is very minimal, it seems like all the tasks are running parallel.

Security:

Unix system is secure in following ways,
1. Each user is authenticated with userid and password.
2. All the files will be having read, write and execute permission. It is of owner's interest to give permission to other users on a particular file.
3. Third one is file encryption, the file will be in unreadable format when someone opens it. Yes, we can decrypt the file to read.

Portability:

The first and most important feature of Unix is it's portability. Most of the code in written in C language which makes unix, a hardware independent OS. Only bare minimal changes required to make unix adapt to the given architecture.

Thursday 28 July 2011

Unix - History

In 1965, Bell Telephone Labs, the General Electric Company and Massachusetts Institute of Technology joined hands to develop an Operating System that could server large community of users and allow them to share data. They produced MultICS, Multiplex Information and Computing Service. But this doesn't end up in an expected outcome.

In 1969, Dennis Richie, Ken Thompson and few others, from AT&T, evolved the first version of multiuser system Unics(UNiplexed Information and Computing Service). Unics was named by Peter Neumann, as a reminder of ill-fated MultICS. It is then renamed as Unix. Initially Unix was developed in machine dependent assembly code, it was not portable.

To make it portable, Ken Thompson created a high-level language called 'B'. But 'B' was not sufficient to make such an OS. Thus, Richie started building a new language called 'C', which is finally used to write the entire Unix.

In 1980s, hundred of thousands of systems from micro to mainframe systems, were using Unix. In 1982, first commercial version of Unix was released by AT&T Labs. A number of vendors including Digital Equipment, Sun, Addamax and others began building trusted versions of UNIX for high security applications, mostly designed for military and law enforcement applications.

In following years many versions of Unix were found. In all the versions, the basic thing is that the OS is kept portable and open-sourced.