Вы находитесь на странице: 1из 23

National University of Computer & Emerging Sciences

Department of Computer Science


CL 205 Operating Systems Lab
Lab # 2
Terminal Commands
Name: Shahroze Kamran Sahotra
Roll No: 17F-8035
Section: D

Instructions:
1. Make a word document with the convention “SECTION_ROLLNO _LAB-NO”. and paste
all of your work done at the LINUX prompt.
2. You have to submit a Word File including the command name, description of the command
and the screen shot of your output when you are done with your work.
3. Plagiarism is strictly prohibited, negative marks would be given to students who cheat.

Objectives:
 Linux Commands
 Practice Problems

Tasks:
Problem 1: Enter the following commands on LINUX prompt, and try to interpret the output. Give
description of each command in at least one line.
 echo hello world
(It Print the statement as it is)


 Passwd
 (Changes the password and will not accept
previous password as new password)


 Date
 (Prints current Date, Day and Time)


 Hostname
 (Prints the name of user)


 Arch
 (Shows the processor’s name)


 uname –a
 (Shows the version of your OS)

 Uptime
 (Shows for how much time user is using OS)

 who am i
 (Shows the name of user)
 Who
 (Shows the name of user with date and time)


 Id
 (Shows Ubuntu ID)

 Last
 (Shows the users status(Restart or Shutdown or
Crashed ) and which time)

 W
 ()

 top (you may need to press q to quit)


 (Tells list of processes or threads)

 echo $SHELL
 (Location of Shell)


 man ls (you may need to press q to quit)
 (List Directory Contents
 Info about the files)


 man who (you may need to press q to quit)
 (It shows who is currently logged in)

 Clear
 (It clears the Terminal’s screen)

 cal 2000
 (Shows the calendar of year 2000)

 cal 9 1759
 (Shows the September of year 1759)


 echo 5+4 | bc –l
 (Prints the sum of 5+4)


 yes please (you may need to press Ctrl-c to quit)
 (Infinitely print the content written with Yes)


 time sleep 5
 (Shows the output after 5 seconds)



 History
 (Shows the commands history written on terminals)



 sudo apt-get install nasm


Problem 2: Try the following Command sequence and describe them in a single line.
 Cd
 (Take to Specific directories)


 Pwd
 (Tells location of current directoy)


 ls –al
 (Shows all directories)

 cd .
 (If you want to work in home directory)


 pwd (where did that get you?)
 (Shows current directory)


 cd ..
 (Takes you back)


 Pwd
 (Shows current directory)


 ls –al
 (Shows history of working user)


 cd ..


 Pwd


 ls –al

 cd ..

 pwd (what happens now)


 cd /etc

 ls -al | more



 cat passwd

 cd –


 Pwd


Problem 3: Answer the following Questions.
 Continue to explore the filesystem tree using cd, ls, pwd and cat. Look in /bin, /usr/bin,
/sbin, /tmp and /boot. What do you see?
 Explore /dev. Can you identify what devices are available? Which are character-oriented and which are
block-oriented? Can you identify your tty (terminal) device (typing who am i might help); who is the
owner of your tty (use ls -l)?
 Explore /proc. Display the contents of the files interrupts, devices, cpuinfo, meminfo
and uptime using cat. Can you see why we say /proc is a pseudo- filesystem which allows access to
kernel data structures?

 Interrupts

 Devices:


 CPU INFO

 MEM INFO


 UPTIME:


 Change to the home directory of another user directly, using cd ~username.


 Change back into your home directory.

 Make subdirectories called work and play.


 Delete the subdirectory called work.


 Copy the file /etc/passwd into your home directory.

 Move it into the subdirectory play.h
 Change into subdirectory play and create a symbolic link called terminal that points to your tty device.
What happens if you try to make a hard link to the tty device?
 What is the difference between listing the contents of directory play with ls -l and ls -L?

 Create a file called hello.txt that contains the words "hello world". Can you use "cp" using
"terminal" as the source file to achieve the same effect?

 Copy hello.txt to terminal. What happens?


 Imagine you were working on a system and someone accidentally deleted the ls command (/bin/ls).
How could you get a list of the files in the current directory? Try it.

 How would you create and then delete a file called "$ SHELL"? Try it.


 How would you create and then delete a file that begins with the symbol #? Try it.

 How would you create and then delete a file that begins with the symbol -? Try it.
 Still in your home directory, copy the entire directory play to a directory called work, preserving the
symbolic link.
 Delete the work directory and its contents with one command. Accept no complaints or queries.
 Change into a directory that does not belong to you and try to delete all the files (avoid / proc or /dev,
just in case!)
 Experiment with the options on the ls command. What do the d, i, R and F options do?

You are done with your exercise, Submit on GOOGLE CLASSROOM at given time.

Вам также может понравиться