OS LAB -2...OS LAB -4 Engr. Nauman 1 For Help man [command] 2 3 Press TAB 4 5 Issues in last LAB...

37
OS LAB -4 Engr. Nauman 1

Transcript of OS LAB -2...OS LAB -4 Engr. Nauman 1 For Help man [command] 2 3 Press TAB 4 5 Issues in last LAB...

Page 1: OS LAB -2...OS LAB -4 Engr. Nauman 1 For Help man [command] 2 3 Press TAB 4 5 Issues in last LAB •Who to set system Date Time •date -s "2 OCT 2011 18:00:00" OR date --set="2 OCT

OS LAB -4

Engr. Nauman

1

Page 2: OS LAB -2...OS LAB -4 Engr. Nauman 1 For Help man [command] 2 3 Press TAB 4 5 Issues in last LAB •Who to set system Date Time •date -s "2 OCT 2011 18:00:00" OR date --set="2 OCT

For Help man [command]

2

Page 3: OS LAB -2...OS LAB -4 Engr. Nauman 1 For Help man [command] 2 3 Press TAB 4 5 Issues in last LAB •Who to set system Date Time •date -s "2 OCT 2011 18:00:00" OR date --set="2 OCT

3

Page 4: OS LAB -2...OS LAB -4 Engr. Nauman 1 For Help man [command] 2 3 Press TAB 4 5 Issues in last LAB •Who to set system Date Time •date -s "2 OCT 2011 18:00:00" OR date --set="2 OCT

Press TAB

4

Page 5: OS LAB -2...OS LAB -4 Engr. Nauman 1 For Help man [command] 2 3 Press TAB 4 5 Issues in last LAB •Who to set system Date Time •date -s "2 OCT 2011 18:00:00" OR date --set="2 OCT

5

Page 6: OS LAB -2...OS LAB -4 Engr. Nauman 1 For Help man [command] 2 3 Press TAB 4 5 Issues in last LAB •Who to set system Date Time •date -s "2 OCT 2011 18:00:00" OR date --set="2 OCT

Issues in last LAB

• Who to set system Date Time

• date -s "2 OCT 2011 18:00:00"ORdate --set="2 OCT 2011 18:00:00"

6

Page 7: OS LAB -2...OS LAB -4 Engr. Nauman 1 For Help man [command] 2 3 Press TAB 4 5 Issues in last LAB •Who to set system Date Time •date -s "2 OCT 2011 18:00:00" OR date --set="2 OCT

Use “ ” for folders having spaces in the name

7

Page 8: OS LAB -2...OS LAB -4 Engr. Nauman 1 For Help man [command] 2 3 Press TAB 4 5 Issues in last LAB •Who to set system Date Time •date -s "2 OCT 2011 18:00:00" OR date --set="2 OCT

Copy in the parent folder ../(in this case parent folder is Desktop)

8

Page 9: OS LAB -2...OS LAB -4 Engr. Nauman 1 For Help man [command] 2 3 Press TAB 4 5 Issues in last LAB •Who to set system Date Time •date -s "2 OCT 2011 18:00:00" OR date --set="2 OCT

Copy using relative path

9

Page 10: OS LAB -2...OS LAB -4 Engr. Nauman 1 For Help man [command] 2 3 Press TAB 4 5 Issues in last LAB •Who to set system Date Time •date -s "2 OCT 2011 18:00:00" OR date --set="2 OCT

Copy in the Current Directory ./

10

Page 11: OS LAB -2...OS LAB -4 Engr. Nauman 1 For Help man [command] 2 3 Press TAB 4 5 Issues in last LAB •Who to set system Date Time •date -s "2 OCT 2011 18:00:00" OR date --set="2 OCT

DOS Vs Linux DOS

Command

LINUX Command Action

DIR ls -l List directory contents

TREE tree List directory

recursively

CD cd Change directory

MKDIR mkdir Make a new directory

RMDIR rmdir Remove a directory

CHDIR pwd Display directory

location

DEL rm Remove a file

11

Page 12: OS LAB -2...OS LAB -4 Engr. Nauman 1 For Help man [command] 2 3 Press TAB 4 5 Issues in last LAB •Who to set system Date Time •date -s "2 OCT 2011 18:00:00" OR date --set="2 OCT

mkdir

12

Page 13: OS LAB -2...OS LAB -4 Engr. Nauman 1 For Help man [command] 2 3 Press TAB 4 5 Issues in last LAB •Who to set system Date Time •date -s "2 OCT 2011 18:00:00" OR date --set="2 OCT

rmdir

13

Page 14: OS LAB -2...OS LAB -4 Engr. Nauman 1 For Help man [command] 2 3 Press TAB 4 5 Issues in last LAB •Who to set system Date Time •date -s "2 OCT 2011 18:00:00" OR date --set="2 OCT

Create a Text File with catcat >filename.txtCtrl+D to save file

for display file cat filename.txt

14

Page 15: OS LAB -2...OS LAB -4 Engr. Nauman 1 For Help man [command] 2 3 Press TAB 4 5 Issues in last LAB •Who to set system Date Time •date -s "2 OCT 2011 18:00:00" OR date --set="2 OCT

DOS Command LINUX

Command

Action

RMDIR /S (NT)

DELTREE (Win

95...)

rm -rRemove all directories and files below

given directory

COPY cp Copy a file

XCOPY cp -r Copy all file of directory recursively

RENAME or

MOVEmv Rename/move a file

TYPE cat Dump contents of a file to users screen

MORE more Pipe output a single page at a time

HELP or

COMMAND /?

man Online manuals

DOS Vs Linux

15

Page 16: OS LAB -2...OS LAB -4 Engr. Nauman 1 For Help man [command] 2 3 Press TAB 4 5 Issues in last LAB •Who to set system Date Time •date -s "2 OCT 2011 18:00:00" OR date --set="2 OCT

The command would begin displaying the file myfile.txt at line two

16

Page 17: OS LAB -2...OS LAB -4 Engr. Nauman 1 For Help man [command] 2 3 Press TAB 4 5 Issues in last LAB •Who to set system Date Time •date -s "2 OCT 2011 18:00:00" OR date --set="2 OCT

DOS

Command

LINUX

CommandAction

CLS clear Clear screen

EXIT exit Exit a shell

FIND find Look for a word in files given in command line

FC diff Compare two files and show differences. Also see

mgdiff and tkdiff.

SET set and env Show environment variables

ECHO text echo text Echo text to screen

DOS Vs Linux

17

Page 18: OS LAB -2...OS LAB -4 Engr. Nauman 1 For Help man [command] 2 3 Press TAB 4 5 Issues in last LAB •Who to set system Date Time •date -s "2 OCT 2011 18:00:00" OR date --set="2 OCT

Environment variables

• are a set of dynamic named values that can affect the way running processes will behave on a computer.

• They can be said in some sense to create the operating environment in which a process runs. For example, an environment variable with a standard name can store the location that a particular computer system uses to store temporary files

18

Page 19: OS LAB -2...OS LAB -4 Engr. Nauman 1 For Help man [command] 2 3 Press TAB 4 5 Issues in last LAB •Who to set system Date Time •date -s "2 OCT 2011 18:00:00" OR date --set="2 OCT

find

• find -name 'mypage.htm'

• In the above command the system would search for any file named mypage.htm in the current directory and any subdirectory.

• find / -name 'mypage.htm'

• In the above example the system would search for any file named mypage.htm on the root and all subdirectories from the root.

• find -name 'file*'

• In the above example the system would search for any file beginning with file in the current directory and any subdirectory.

• find -name '*' -size +1000k

• In the above example the system would search for any file that is larger then 1000k.

19

Page 20: OS LAB -2...OS LAB -4 Engr. Nauman 1 For Help man [command] 2 3 Press TAB 4 5 Issues in last LAB •Who to set system Date Time •date -s "2 OCT 2011 18:00:00" OR date --set="2 OCT

20

Page 21: OS LAB -2...OS LAB -4 Engr. Nauman 1 For Help man [command] 2 3 Press TAB 4 5 Issues in last LAB •Who to set system Date Time •date -s "2 OCT 2011 18:00:00" OR date --set="2 OCT

Search in a file

21

Page 22: OS LAB -2...OS LAB -4 Engr. Nauman 1 For Help man [command] 2 3 Press TAB 4 5 Issues in last LAB •Who to set system Date Time •date -s "2 OCT 2011 18:00:00" OR date --set="2 OCT

DOS

Command

LINIUX Command Action

SET

variable export variable name

Set environment variables

PATH echo $PATH Display search path for

executables

DATE or

TIME

date Show date. (also set date -

DOS only)

SORT sort Sort data

alphabetically/numerically

EDIT

filename.txt vim

Edit a file. The Linux editor

which looks most like DOS

edit is probably Pico.

\ / Directory path delimiter

.\ ./ Current directory

..\ ../ Parent directory

DOS Vs Linux

22

Page 23: OS LAB -2...OS LAB -4 Engr. Nauman 1 For Help man [command] 2 3 Press TAB 4 5 Issues in last LAB •Who to set system Date Time •date -s "2 OCT 2011 18:00:00" OR date --set="2 OCT

sort

23

Page 24: OS LAB -2...OS LAB -4 Engr. Nauman 1 For Help man [command] 2 3 Press TAB 4 5 Issues in last LAB •Who to set system Date Time •date -s "2 OCT 2011 18:00:00" OR date --set="2 OCT

Other commands

• Rename folder

• Rename file

• Delete folder having files in it

• Free

• History

24

Page 25: OS LAB -2...OS LAB -4 Engr. Nauman 1 For Help man [command] 2 3 Press TAB 4 5 Issues in last LAB •Who to set system Date Time •date -s "2 OCT 2011 18:00:00" OR date --set="2 OCT

25

Page 26: OS LAB -2...OS LAB -4 Engr. Nauman 1 For Help man [command] 2 3 Press TAB 4 5 Issues in last LAB •Who to set system Date Time •date -s "2 OCT 2011 18:00:00" OR date --set="2 OCT

uname –m

• x86_64 when it is an kernel 64 bits

• i686 for 32 bits kernel

26

Page 27: OS LAB -2...OS LAB -4 Engr. Nauman 1 For Help man [command] 2 3 Press TAB 4 5 Issues in last LAB •Who to set system Date Time •date -s "2 OCT 2011 18:00:00" OR date --set="2 OCT

which

27

Page 28: OS LAB -2...OS LAB -4 Engr. Nauman 1 For Help man [command] 2 3 Press TAB 4 5 Issues in last LAB •Who to set system Date Time •date -s "2 OCT 2011 18:00:00" OR date --set="2 OCT

who

28

Page 29: OS LAB -2...OS LAB -4 Engr. Nauman 1 For Help man [command] 2 3 Press TAB 4 5 Issues in last LAB •Who to set system Date Time •date -s "2 OCT 2011 18:00:00" OR date --set="2 OCT

mount/unmount

• su root

• ls /dev

• fdisk –l

• Making a mount point

• mkdir /mnt/windows/

• mkdir /media/windows/ (ubuntu)

• mount /dev/sda1 /media/windows/

• umount /media/windows/29

Page 30: OS LAB -2...OS LAB -4 Engr. Nauman 1 For Help man [command] 2 3 Press TAB 4 5 Issues in last LAB •Who to set system Date Time •date -s "2 OCT 2011 18:00:00" OR date --set="2 OCT

mount

30

Page 31: OS LAB -2...OS LAB -4 Engr. Nauman 1 For Help man [command] 2 3 Press TAB 4 5 Issues in last LAB •Who to set system Date Time •date -s "2 OCT 2011 18:00:00" OR date --set="2 OCT

umount

31

Page 32: OS LAB -2...OS LAB -4 Engr. Nauman 1 For Help man [command] 2 3 Press TAB 4 5 Issues in last LAB •Who to set system Date Time •date -s "2 OCT 2011 18:00:00" OR date --set="2 OCT

Process / kill

• gedit

• gedit &

• For running processes

• ps

• Kill PID

32

Page 33: OS LAB -2...OS LAB -4 Engr. Nauman 1 For Help man [command] 2 3 Press TAB 4 5 Issues in last LAB •Who to set system Date Time •date -s "2 OCT 2011 18:00:00" OR date --set="2 OCT

33

Page 34: OS LAB -2...OS LAB -4 Engr. Nauman 1 For Help man [command] 2 3 Press TAB 4 5 Issues in last LAB •Who to set system Date Time •date -s "2 OCT 2011 18:00:00" OR date --set="2 OCT

Programming C complier

• touch helloworld.c

• gedit helloworld.c &

• Write simple hello world c code

• gcc helloworld.c -o HELLO

• ./ HELLO

34

Page 35: OS LAB -2...OS LAB -4 Engr. Nauman 1 For Help man [command] 2 3 Press TAB 4 5 Issues in last LAB •Who to set system Date Time •date -s "2 OCT 2011 18:00:00" OR date --set="2 OCT

35

Page 36: OS LAB -2...OS LAB -4 Engr. Nauman 1 For Help man [command] 2 3 Press TAB 4 5 Issues in last LAB •Who to set system Date Time •date -s "2 OCT 2011 18:00:00" OR date --set="2 OCT

Assignment - 1

36

Page 37: OS LAB -2...OS LAB -4 Engr. Nauman 1 For Help man [command] 2 3 Press TAB 4 5 Issues in last LAB •Who to set system Date Time •date -s "2 OCT 2011 18:00:00" OR date --set="2 OCT

Quiz in Next LAB

37