Unix Lab Exeperimen1

  • October 2019
  • PDF

This document was uploaded by user and they confirmed that they have the permission to share it. If you are author or own the copyright of this book, please report to us by using this DMCA report form. Report DMCA


Overview

Download & View Unix Lab Exeperimen1 as PDF for free.

More details

  • Words: 1,666
  • Pages: 20
UNIX LAB EXEPERIMENT SOME BASIC UNIX COMMNDS UNDER THE GUIDANCE OF MR. RAJNEESH JAIN

INTRODUCE BYSATISH CHANDRA MCA IInd sem R.N. 0703614094

1

passwd:TO CHANGE YOUR PASSWORD. $Passwd<enter> (Current) unix password:********<enter> new unix password: *******<enter> retype new unix password:*******<enter>

2

who am i:-To know about your login. $who am i<enter> mca093 pts\5 (user name) (terminal)

feb 16

11:37

(172.16.2.109)

(current date) (current time) .

3 who or w: Know the users $w<enter> 11:50:48 up

user

tty

mca052 mca055 mca056 mca012 mca113

2:10

5 users

from

pts/1 172.16.101 pts/2 172.16.102 pts/3 172.16.104 pts/4 172.16.103 pts/5 172.16.109

load

average: 0.04, 0.01, 0.00

login

idce

jcpu

11:20 11:20 11:20 11:24 11:37

0:00s 1:20 3:55 1:00s 0:00s

0.14s 0:11s 0:17s 0.16s 0:00s

pcpu 0.03s 0:02s 0.02s 0.00s 0:00s

what vim vim vim sh 0:00s

leap pg 277d-c cgff sp5 w

4

man Online help about commands $man (command name)<enter> suppose we want to know about “cat” . $man cat <enter> show all information about cat.

5

tty To know your terminal $tty<enter> /div/term/2.

6 lock Lock your terminal we have to away from our terminal for a while ,but don`t want to logout. $lock<enter> password:****** re-enter password:****** terminal locked by mca093 0 minutes ago *The $ prompt disappear, system will remain lock in this condition for 30 minutes*

7 stty Set Terminal characteristics Terminal is divice with which a user communicates with system. Stty use enormous number of keywords. -a option display the curret setting. $stty –a<enter> speed 43820 boud; row=25; columns=80; ypixels=0; xpixels=0; intr=del; quit=^\;erase=^h;kill=^u;

8

clear To clear the screen $clear<enter> *the screen clears and the cursor is positioned at the top left corner of the screen*

9 tput Use to clear argument Use to highlight text $ tput clear<enter> $tput cup 10 10<enter> *use cup argument to position the cursor to row no. 10 and column 10*

10 uname Tells the machine in a network $ uname -n unix

11

date Display the system date $date<enter> sat feb 16 11:30:45 ist 2008

we can also use in different wayes $date + %m<enter> 02 or month name $date +%n<enter> feb //also combine them in one// $date+”%n(%m)” <enter> feb(02) $date`+DATE:%d-%m-%y%n TIME:%H:%M:%S`<enter> DATE:16-02-08 TIME:11:37:45

12 cal To see calender $cal<enter> display current month calender $cal 2008 display whole year calender $ cal 05 2007 display may 2007 calender

13 bc The calculator $bc<enter> calculate whatever you want. *to quit use ctrl-d *

14

expr $expr 100+50<enter> 150 $expr 3\*2 (the \ just take away this special meaning of *) 6 //why the \ preceding the `*` in the second expression//

15

facter Facterise the no. & print its prim facters $facter<ent> 30 2 3 5 q<ent> $ *type in positive number less than 2^46(7.2e13)*

16 units It converts quantities in one scale to other scale $units you have:inch you want:cm

17 ps1 To change prompt sign $ps1=”unix”<ent> unix (our new prompt is “unix”) //by default our promt is “$”

18 type To know the location of a command file $type ls ls is /bin/ls

19 pwd To know present working directory $pwd /home/mca093/satish:>$

20 mkdir To make a directory $mkdir satish<ent> $ (one directory is created by satish) $mkdir manish<ent> $

21

ls Listing files and directories $ls<ent> satish manish file1 file2 file3 file4

taj

//directory show in colored form $ls –a (shows all files including all hidden files) $ls –l (listing files in long format) $ls –i (shows inode number) $ls –d (forces listing of a directory)

22 cd To change directory home/mca093/:>$cd satish home/mca093/satish:>$ //now your current directory name is satish

23 cat To creat &display files Concatenation of files $cat > file1 - hi I am pursuing M.C.A IInd sem . - I am introducuing unix commands. $ cat file1 hi I am pursuing M.C..A IInd sem. I am introducing unix commands. $

//(creating file)

//(display all contents of file)

$ cat > file2 - unix operating system provides :- open source code - cooperative tools and utility - multiuser and multitasking - excellent networking environment - portability. $cat > file3 -ram -mohan $cat >> file3 -sohan

// (display file in append mode)

$cat > taj -symbol of love. -include with seven wonders of world. $cat > file4 - tiger - lion - zebra $cat file1 file4 > taj $cat taj -hi I am pursuing M.C.A. IInd sem. -I am introducing unix commands. -tiger -lion -zebra $cat file1 file4 >> file3 $cat file3 -ram -mohan -sohan -hi I am…………… -I am intro. …………… -tiger -lion -zebra$

here (in concatenation if third file is not exit then Created.if exit then contents of Ist and IInd Overwrite to object f ile)

(concatenation with appending contents)

24 touch Changing the time stamps $touch option expression filename //file not exit then creat it creat empty files not read or write mode

25 rmdir To remove directories $rmdir manish(directory name)

26 cp Copying files $cp file1 file2 // if we copy file present in other dir then give path

27 rm Deleting files $rm file3 file4

28

mv To rename files $ taj file5

29 df To find uot the free disk space $df

30 du To find out your own consumption $du 76

31 chmod To change file permission Category

operation

permission

u-user

+ - assign permission

r-read

g-group

- -remove permission

w-write (-2)

0-others

= -assign permission

x-execute (-1)

(-4)

a-all $chmod u+x file1

(user can only execute file1)

$chmod a+x file2 $chmod ugo+w file3 $chmod o-rwx file4

(others can read,write,execute file4)

$chmod ugo=r file1

(assign only read permission and remove all other permission)

$chmod 777 file2

(all permission for ugo)

32 umask Default file permission Default permission For files For directories

rw-rw-rw- (octal 666) rwx rwx rwx (octal 777)

This default is transformed by substracting the user mask from it remove one or more permission. $umask 022 substracting this value from default permission 666-022=644 (permission for regular file) 777-022=755 (permission for directory) (The umask setting can be changed only by administrater)

33 chown and chgroup Changing file ownership $chown sachin file1 $chgrp sachin file2

34 ln A file to have more then one name and yet maintain single copy in disk $ln file4 file8 (file4 have other file name file8)

35 more Paging output $more file1 --more—(35%) {press q to exite} INTERNAL COMMANDS OF MORE More Spacebar

action one page forward

Enter

one line forward

b

one page back

15b

15 page back

20f

20 page forward

=

display current line number

q

quit

h

help It also work for multiple files

$more file1 file2 fole3

36

wc Line word & character counting $wc file1 5 30 192

file1

$wc –l file1 5 file1

(show no. of lines)

$wc –w file1 30 file1

(number of words)

$wc –c file1 192

(no. of characters)

we also use with command $ls | wc –l $who | wc –l

37

pr Paginating files Prepares a file for printinge $pr file1 Feb 16

11:38

$pr –l 30 file2 $pr +15 file2

2008

group1

page1

(page set to 30 lines) (start printing from page 10)

Pr option OPTION

DISCRIPTION

-ln

set lenth of page to n line

-wn

sets width of page to n characters

-n

numbers lines in output

-on

offsets output by n spaces

-d

double space output

-k

produce output in k colomns

+k

starts printing from page k

-t

elements header,footers&margin totally

-h stg

sets header for every page to string stg

38 cmp Comparing two files $cmp file1 file2 Cmp $

(when mismatch) (matched)

39 diff Converting one file to other To display file difference $diff file1 file2

40 Comm What is common $comma file1 file2

41 head Displaying the beginning of a file $head -5 file1

(display contents first 5 lines)

42 tail Displaying the end of a file $tail -3 file1

(display contents last five)

43 cut Cutting a file vertically $cut –c1-8 file1 $cut –d : -f 2,5 file1

(cutting by column) (cutting fields)

44 paste To past files Cut can be pasted back with this $bc
bc:- display output

45

sort Ordering file Short recorders a line in ASCII collating sequence starting from begning of the line. $sort file3 (sort the contents of file and display sorted output) $sort file1 file2 file3 (sort contents of several files) $sort –otaj file1 file2 (sorted output on the screen can stor other file) $sort –u –o taj file1 file2 (lines should occure only once in the output) $sort –m file2 file3 (merges sorted files) $sort –n file3 (sort numerically) $sort -3 file2 (stop sort after 3rd field) $sort +3 file3 (start sort after skipping 3rd field)

46 greap Search a regular expression and print it $greap lion file3 lion

(find then print)

$greap rat file3 $

(not found)

GREAP OPTION

OPTION

DESCRIPTION

-c -l -n -v -i -w

display count of no. of occurrence display list of filenames only display line no. along with lines don`t display lines matching exp.o ignore case when matching match complete word

47 banner To print message in large letters $banner satish

49 lp To send the user`s print job to print queue $lp file1 file2 reqest id is lp-24(2files) $lp –w file3 file4 request id is lp-44 (2 files) (send message when file is printed)

50 dd To converts and copies a file allowing plenty of choices $dd if=input file(report) of=outputfile(document) conve=ucase

51 ps To show processes status $ps PID 4126

TTY pts/5

TIME 00:00:00

CMD sh

4244

pts/5

00:00:00

ps

pts/5 pts/5

00:00:00 00:00:00

sh ps

$ps 4126 4255

// each time a process is initiated , the kernel assigns to it a unique PID. //sh process is called the parent. //ps process spawned by the shell are the children. OPTION TO ps Option -f -e -u user -a -l -t term

significance full listing showing PPID of each process all processes including user and system .. process for user only processes of oll user execluding process not associated with terminal long listing showing memory related information processes running on terminal

Related Documents

Unix Lab Exeperimen1
October 2019 6
Unix Lab Manual
May 2020 5
Unix Lab Manual
May 2020 5
Unix
November 2019 40
Unix
May 2020 36
Unix
June 2020 24