Total Pageviews

Sunday, April 7, 2013


UNIX Commands


Some of the important unix commands.

$PWD (Present Working Directory)/Print Working direcotry.

$Clear - (Clears the Screen)

$Exit (Exit from session or logout).

$WHO - Gives the status of the users connected to host.

$WHO am I - This command will shows working user and status in network.

$cat - Used to create a file

$cate>filename - file name should be unique. Enter data.

$cat filename (to see the contents of the file)

$touch - it is also used to create a file. We can create more than one file at a time.
eg

$touch f1,f2,f3 creates f1,f2 and f3 files.

$Ctrl+d- to save the file.

$Cat f1 f2 > f3 
The above command merges contains of the two files f1 and f2 and places them in a new file i.e f3. If the new file is not existing it will create the new file. If the f3 file exists it will removes old contents and places the new contents in that place.

$Cat f1,f2 >> f3
The above command merges f1,f2 into f3. If new file contains any data then it will add the data of f1,f2 files at the end of the f3 file data.

$date - shows the current date and time.

$banner cmc - It will print the large letters
eg CMC

$echo hi hi hi hi hi
it prints hi hi hi hi hi (what ever we give after echo that will be printed on the screen)

$Cal - Cal gives the calender.

$Cal 2 2007 - It displays 2007 February calender.

$CP (Copy)- Copying a particular file from one directory to another directory.

eg $cp f1 f2 - copying f1 into f2 in a present directory.

$cp 

$mv - to rename a file
$mv f1 f2
file name f1 changed to f2

$mv dir1 dire2 
to rename a directory

$expr 10+2
results from above command is 12

$mkdir 
to create a directory.

$cd.. 
back to one directory

$rm remove the file or directory

$rm -i - removes files interactively.
eg $rm -i f1 - before removing system asks removing Y/N.

$ls list of all the files and all the directories present in current directory.
$ls -l Provides long list of the files and directories present in the pwd.

File Access Permissions in Unix

User Group Others
rwx rwx rwx
421 421 421

chmod (change mode)
- for removing
+ for adding
= it replaces the old permissions with the new permission.

Two types of methods for file access permission.
symbolic method and absolute method

symbolic method

$chmod u+x filename 
$chmod u+x f1
the above command adds permission for f1 file for user.

$chmod g=w filename
$chmod g=w f1
The group is replaced by write

Absolute Method

$chmod 777 filename
All the permissions given to specified filename.

No comments:

Post a Comment