1. SUBMITTED BY: M. UBAID ASHRAF
REG. NUMBER: 20-CP-09
SUBMITTED TO: SIR ADNAN MUSTAFA
SECTION: ALPHA
SEMESTER: 4th
ASSIGNMENT NO. 1
UNIVERSITY OF ENGINEERING & TECHNOLOGY,
TAXILA
2. 1: Display your current directory.
2: Change to the /etc directory.
3: Go to the parent directory of the current directory.
4: Go to the root directory.
5: List the contents of root directory.
6: List a long listing of the root directory.
4. 8: Stay where you are and list the contents of /bin and /sbin.
5.
6. 9: Stay where you are, and list the contents of ~
10:List all the files (including hiddenfiles) inyour home directory.
11:List the files in/boot in a human readable format.
7. 12: Create a directory testdir in your home directory.
13: Change to the /etc directory, stay here and create a directory newdir inyour
home directory.
14: Display the absolute path of your home directory.
15: Create a new subdirectory called COP3353-temp in your home directory.
8. 16: Create a new subdirectory called assign1 in COP3353-temp
a. Create a new subdirectory called assign2 in COP3353-temp.
b. Display the contents of the directory COP3353-temp
c. Delete the directory assign2
9. d. Display the contents of COP3353-temp
e. Change your current working directory to COP3353-temp.
f. Create a newfile calledMyFile.txtusing the touchcommand and insert
two lines into the file.
a) Thefirstlineshould bea sentencethat tells meyourfavoritemovie.
b) The second line should be a sentence that tells me your favorite
food.
After creating the file using touch command, I use gedit command
to insert two lines into the file and display the content of file using
cat command.
17:Write a shell script tocalculate asimple interest.
Code for calculating simple interest:
echo " Enter the principle value: "
read p
echo " Enter the rate of interest:"
read r
10. echo " Enter the time period:"
read t
i=`expr $p * $t * $r / 100`
echo " The simple interest is "
echo $i
18: What is the purpose of following commands? Discuss in detail.
Kill:
kill command in Linux (located in /bin/kill), is a built-in command which is
used to terminate processes manually. kill command sends a signal to a
process which terminates the process.
Grep:
The grepcommand whichstandsfor “global regularexpressionprint,”processestextline
by line andprintsanylineswhichmatchaspecifiedpattern.The grepcommandisusedto
search text or searches the given file for lines containing a match to the given strings or
words.
Tail:
Linux tail command is used to display the last ten lines of one or more
files. Its main purpose is to read the error message. By default, it
displaysthe lastten lines of a file. Additionally, it is used to monitor the
file changes in real-time.
Head:
The head command is a command-line utility for outputting the first
part of files given to it via standard input. It writes results to standard
output. By default, head returns the first ten lines of each file that it is
given.
Chmod:
The Linuxcommand chmod allows you to controlexactly who is able to
read, edit, or run yourfiles. Chmod is an abbreviation forchangemode;
if you ever need to say it out loud, justpronounceit exactly as it looks:
ch'-mod.
Touch:
It is used to create a file without any content. The file created using
touch command is empty. This command can be used when the user
doesn’t have data to store at the time of file creation.
History:
11. The history command in Linux allows us to view the history of the
commands that we run in the terminal. You can set the maximum
number of entries BASH should storeas history in your . bashrc file. For
most Linux users, using the command line is a daily activity.
Pr:
In Linux pr command is used to prepare a file for printing by adding
suitable footers,headers,and the formatted text. pr commandactually
adds 5 lines of margin both at the top and bottom of the page.
Sudo:
Sudo stands for SuperUser DO and is used to access restricted files and
operations. By default, Linux restricts access to certain parts of the
system preventing sensitive files from being compromised.
Lp:
In Linux, we use lp command to print the files of any mode i.e.
landscape or portrait, multiple copies or single copies and so on.
Apt-get:
apt-get is a command-line tool which helps in handling packages in
Linux. Its main task is to retrieve the information and packages from
the authenticated sources for installation, upgrade and removal of
packages along with their dependencies.
Tar:
The Linux 'tar' stands for tape archive, is used to create Archive and
extract the Archive files. tar command in Linux is one of the important
command which provides archiving functionality in Linux.
Sed:
SED command in linux is for substitution or for find and replace. By
using SED you can edit files even withoutopening them, which is much
quicker way to find and replace something in file, than first opening
that file in VI Editor and then changing it. SED is a powerfultext stream
editor.
Sort:
The sortcommand is used in Linux to print the output of a file in given
order. This command processes on your data (thecontent of the file or
output of any command) and reorders it in the specified way, which
helps us to read the data efficiently.
12. Gzip:
Gzip (GNUzip)is a freeand open sourcealgorithmforfile compression.
The software is overseen by the GNU project. In this context,
compression is the deliberate reduction in sizeof data to savestorage
space or increase the data transfer rate.