Lab Assignment_1 - Solution
Lab Assignment_1 - Solution
8. Use one command to show the calendar for the previous month, current month, and next
month. To do this step, you will first need to look up the man page of the utility in order to
find the right option. Don’t show the man page in the script output file (look up the man
page before starting script).
Solution.
cal -3
9. Start the calculator and show the result of the division problem: 1 / 3, show the result with 2
digits after the decimal point.
Solution.
bc
scale=2
1/3
quit
Module 2 :
From Teachers, change directory to the home user directory using relative path.
Solution.
pwd
# You will figure out in your terminal: /home/user/ESI-SBA/Teachers
cd ../.. (or : cd ~)
pwd
# You will figure out in your terminal: /home/user
From the home directory, Change directory to the root of the Linux directory.
Solution.
pwd
# You will figure out in your terminal: /home/user/
cd ../.. (or : cd / )
pwd
# You will figure out in your terminal: /
Display the content of both aforementioned two files using more than one
command-line.
Solution.
cat data1.txt data2.txt (more or less can be also employed !!! )
d) Display the contents of the Data directory using the following ls commands and notice the
difference: ls; ls -l; ls -i; ls -al; ls -il; ls -ail
Solution.
Will be figured out within the Lab session.
e) Copy data1.txt to record1.txt
Solution.
cp data1.txt record1.txt
f) Rename data2.txt to record2.txt
Solution.
rename data2.txt record2.txt
g) Delete data1.txt
Solution.
rm data1.txt
h) Move data3.txt to the Teachers directory
Solution.
mv data3.txt /home/user/ESI-SBA/Teachers (or : mv data3.txt ../../ESI-SBA/Teachers)
i) Move .info2 to ESI-SBA directory and rename the file .Rec2. Do this using a single command.
Solution.
mv .info2 ../../ESI-SBA/Rec2
j) Copy .info1 to Service directory.
Solution.
cp .info1 ..
k) Delete the empty directory Staff.
Solution.
rmdir ../Staff
l) Delete the non-empty directory Data.
Solution.
rm -r .
m) Recursively list directory tree.
Solution.
cd ~
ls -R
n) Delete the ESI-SBA and Service directories to end this Lab.
Solution.
rm –r ESI-SBA Service