What is Unix?
Unix is a operating system. It is a set of programs that acts a interface between computer and the user.Computer--------> Unix OS<----------------- User
The computer programs that allocate the system resources and coordinate all the details of the computer's internals is called the operating system or kernel.
Users communicate with the kernel through a program known as the shell. The shell is a command line interpreter; it translates commands entered by the user and converts them into a language that is understood by the kernel.
History of Unix
1.Unix was originally developed in 1969 by a group of AT&T employees at Bell Labs, including Ken Thompson, Dennis Ritchie, Douglas McIlroy, and Joe Ossanna.
2. Several people can use a UNIX computer at the same time; hence UNIX is called a Multiuser system.
3 A user can also run multiple programs at the same time; hence UNIX is called multitasking.
Unix support multiuser and multitasking environment.
Unix Architecture:
The main concept that unites all versions of UNIX is the following four basics:- Kernel: The kernel is the heart of the operating system. It interacts with hardware and most of the tasks like memory management, tash scheduling and file management.
- Shell: User Communicate via kernel by writing the program known as the Shell.The shell is the utility that processes your requests. When you type in a command at your terminal, the shell interprets the command and calls the program that you want. The shell uses standard syntax for all commands. C Shell, Bourne Shell and Korn Shell are most famous shells which are available with most of the Unix variants.
- Commands and Utilities: There are various command and utilities which you would use in your day to day activities. cp, mv, cat and grep etc. are few examples of commands and utilities. There are over 250 standard commands plus numerous others provided through 3rd party software. All the commands come along with various optional options.
- Files and Directories: All data in UNIX is organized into files. All files are organized into directories. These directories are organized into a tree-like structure called the filesystem.
Login Unix:
When you first connect to a UNIX system, you usually see a prompt such as the following:login:
To login:
Need the username and password. These are case sensitive so be careful while enter it.
Read the information and messages that come up on the screen something as below.
login : amrood amrood's password: Last login: Sun Jun 14 09:32:32 2009 from 62.61.164.73 [amrood]$ |
[amrood]$ cal June 2009 Su Mo Tu We Th Fr Sa 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 [amrood]$
Change Password:
All Unix systems require passwords to help ensure that your files and data remain your own and that the system itself is secure from hackers and crackers. Here are the steps to change your password:- To start, type passwd at command prompt as shown below.
- Enter your old password the one you're currently using.
- Type in your new password. Always keep your password complex enough so that no body can guess it. But make sure, you remember it.
- You would need to verify the password by typing it again.
[amrood]$ passwd Changing password for amrood (current) Unix password:****** New UNIX password:******* Retype new UNIX password:******* passwd: all authentication tokens updated successfully [amrood]$ |
Listing Directories and Files:
All data in UNIX is organized into files. All files are organized into directories. These directories are organized into a tree-like structure called the filesystem.
You can use ls command to list out all the files or directories available in a directory. Following is the example of using ls command with -l option.
[amrood]$ ls -l total 19621 -rwxr-xr-x 1 ranga users 2368 Jul 11 15:57 .profile* drwxrwxr-x 2 amrood amrood 4096 Dec 25 09:59 uml -rw-rw-r-- 1 amrood amrood 5341 Dec 25 08:38 uml.jpg drwxr-xr-x 2 amrood amrood 4096 Feb 15 2006 univ drwxr-xr-x 2 root root 4096 Dec 9 2007 urlspedia -rw-r--r-- 1 root root 276480 Dec 9 2007 urlspedia.tar drwxr-xr-x 8 root root 4096 Nov 25 2007 usr -rwxr-xr-x 1 root root 3192 Nov 25 2007 webthumb.php -rw-rw-r-- 1 amrood amrood 20480 Nov 25 2007 webthumb.tar -rw-rw-r-- 1 amrood amrood 5654 Aug 9 2007 yourfile.mid -rw-rw-r-- 1 amrood amrood 166255 Aug 9 2007 yourfile.swf [amrood]$ |
Because the first character is a hyphen (-), you know that this is a regular file. Several characters appear after this hyphen. The first three characters indicate the permissions for the owner of the file, the next three characters indicate the permissions for the group the file is associated with, and the last three characters indicate the permissions for all other users.
EX: Checkout the first example..
The permission block for this file indicates that the user has read, write, and execute permissions, whereas members of the group users and all other users have only read and execute permissions.
After the permissions block, the owner and the group are listed. For this file, the owner is ranga and the group is users.
Here is the information about all the listed columns:
- First Column: represents file type and permission given on the file. Below is the description of all type of files. (r)- read ,(w)-write and (x)-execute permission.
- Second Column: represents the number of memory blocks taken by the file or directory.
- Third Column: represents owner of the file. This is the Unix user who created this file.
- Fourth Column: represents group of the owner. Every Unux user would have an associated group.
- Fifth Column: represents file size in bytes.
- Sixth Column: represents date and time when this file was created or modified last time.
- Seventh Column: represents file or directory name.
Permissions | Directories | Group | Size | Date | Directory or file |
drwx------ | 2 | users | 4096 | Nov 2 19:51 | mail/ |
drwxr-s--- | 35 | www | 32768 | Jan 20 22:39 | public_html/ |
-rw------- | 1 | users | 3 | Nov 25 02:58 | test.txt |
Who is Logged In?
As discussed already that unix is a multiuser environment so if you want to know who is logged in to the computer at the same time.There are three commands are available to get you this information, based on how much you'd like to learn about the other users: users, who, and w.
[amrood]$ users amrood bablu qadir [amrood]$ who amrood ttyp0 Oct 8 14:10 (limbo) bablu ttyp2 Oct 4 09:08 (calliope) qadir ttyp4 Oct 8 12:09 (dent) [amrood]$ |
To log out:
- Just type logout command at command prompt, and the system will clean up everything and break the connection.
One most important point about unix is: Everything in unix is the Files and directories i.e how to create and remove files, copy and rename them, create links to them etc.
Meta Characters:
Meta characters have special meaning in Unix. For example * and ? are metacharacters. We use * to match 0 or more characters, a question mark ? matches with single character.For Example:
[amrood]$ls ch*.doc |
ch01-1.doc ch010.doc ch02.doc ch03-2.doc ch04-1.doc ch040.doc ch05.doc ch06-2.doc ch01-2.doc ch02-1.doc c |
[amrood]$ls *.doc
Creating Files:
You can use vi editor to create ordinary files on any Unix system. You simply need to give following command:[amrood]$ vi filenameAbove command would open a file with the given filename. You would need to press key i to come into edit mode. Once you are in edit mode you can start writing your content in the file as below:
This is unix file....I created it for the first time..... I'm going to save this content in this file. |
- Press key esc to come out of edit mode.
- Press two keys Shift + ZZ together to come out of the file completely.
[amrood]$ vi filename [amrood]$
Editing Files:
You can edit an existing file using vi editor. We would cover this in detail in a separate tutorial. But in short, you can open existing file as follows:[amrood]$ vi filename |
- l key to move to the right side.
- h key to move to the left side.
- k key to move up side in the file.
- j key to move down side in the file.
Display Content of a File:
You can use cat command to see the content of a file. Following is the simple example to see the content of above created file:[amrood]$ cat filename This is unix file....I created it for the first time..... I'm going to save this content in this file. [amrood]$
Counting Words in a File:
You can use the wc command to get a count of the total number of lines, words, and characters contained in a file. Following is the simple example to see the information about above created file:[amrood]$ wc filename 2 19 103 filename [amrood]$
Here 2-(1st coloumn) represents the total number of lines in the file.
19-(2nd column) represents the total number of words in the file.
103(3rd column)- reprents the total number of bytes in the file.And this is actually
size of the file.
You can give multiple files at a time to get the information about those file. Here is simple syntax:
[amrood]$ wc filename1 filename2 filename3
Copying Files:
To make a copy of a file use the cp command. The basic syntax of the command is:[amrood]$ cp source_file destination_file
Renaming Files:
To change the name of a file use the mv command. Its basic syntax is:[amrood]$ mv old_file new_file
Deleting Files:
To delete an existing file use the rm command. Its basic syntax is:[amrood]$ rm filename |
Following is the example which would completely remove existing file filename:
[amrood]$ rm filename [amrood]$ |
[amrood]$ rm filename1 filename2 filename3 [amrood]$
Here are the list of all the commands that are commonly used in the unix environment.
go and check it out hope it will helpful to you.
Home Directory:
The directory in which you find yourself when you first login is called your home directory.You can go in your home directory anytime using the following command:
[amrood]$cd ~ [amrood]$ |
[amrood]$cd ~username [amrood]$ |
[amrood]$cd - [amrood]$
The directories . (dot) and .. (dot dot)
The filename . (dot) represents the current working directory; and
the filename .. (dot dot) represent the directory one level above the
current working directory, often referred to as the parent directory.File Access Modes:
The permissions of a file are the first line of defense in the security of a Unix system. The basic building blocks of Unix permissions are the read, write, and execute permissions, which are described below. read(r), write(w), and execute(x). Check the command (ls -l ) which explained in the above of this post.Changing Permissions:(chmod)
To change file or directory permissions, you use the chmod (change mode) command. There are two ways to use chmod: symbolic mode and absolute mode.
Using chmod in Symbolic Mode:
The easiest way for a beginner to modify file or directory permissions is to use the symbolic mode. With symbolic permissions you can add, delete, or specify the permission set you want by using the operators in the following table.Chmod operator | Description |
---|---|
+ | Adds the designated permission(s) to a file or directory. |
- | Removes the designated permission(s) from a file or directory. |
= | Sets the designated permission(s). |
Here's an example using testfile. Running ls -1 on testfile shows that the file's permissions are as follows:
Each permission is assigned a value, as the following table shows, and the total of each set of permissions provides a number for that set.
Number | Octal Permission Representation | Ref |
---|---|---|
0 | No permission | --- |
1 | Execute permission | --x |
2 | Write permission | -w- |
3 | Execute and write permission: 1 (execute) + 2 (write) = 3 | -wx |
4 | Read permission | r-- |
5 | Read and execute permission: 4 (read) + 1 (execute) = 5 | r-x |
6 | Read and write permission: 4 (read) + 2 (write) = 6 | rw- |
7 | All permissions: 4 (read) + 2 (write) + 1 (execute) = 7 | rwx |
Numeric Permissions:CHMOD can also to attributed by using Numeric Permissions:
400 read by owner
040 read by group
004 read by anybody (other)
200 write by owner
020 write by group
002 write by anybody
100 execute by owner
010 execute by group
001 execute by anybody
Examples
The above numeric permissions you can visit the site:
http://www.computerhope.com/unix/uchmod.htm
Sending Email:
You use the Unix mail command to send and receive mail. Here is the syntax to send an email:[amrood]$mail [-s subject] [-c cc-addr] [-b bcc-addr] to-addr |
Option | Description |
---|---|
-s | Specify subject on command line. |
-c | Send carbon copies to list of users. List should be a comma-separated list of names. |
-b | Send blind carbon copies to list. List should be a comma-separated list of names. |
[amrood]$mail -s "Test Message" admin@yahoo.com |
Hi, This is a test . Cc: |
[amrood]$mail -s "Report 05/06/07" admin@yahoo.com < demo.txt |
[amrood]$mail no email
These are the basics of the unix there are many more topics present in the unix.
Hope you find some basic concepts from my blog-spot. And that's I want from you.
Believe me I too don't know the Unix and i learn some concepts when I make some research
about it. So my suggestion is to you 'stop thinking start learning'. Good luck.
No comments:
Post a Comment