You are on page 1of 8

University of Bahrain

College of Information Technology

Department of Computer Science

ITCS322 – Operating Systems

Assignment 1

Submitted by:

Halima Mohamed 20133684

Date of Submission: March 27, 2017

Semester II – Academic Year 2016/17


 Write the Linux commands and show their output for the following.
Note::
This assignment has done with the Ubuntu version 14.04 (New version)

1. List all the files in your current working directory including the hidden files in the long list
format.

ls -al

2. Make a new directory d1 in your home directory and copy all the txt files into that
directory.

Mkdir d1 //Create d1 directory


find /home/ubuntu -name "*.txt" -type f -exec cp {} /home/ubuntu/d1 \; //Search .txt files then
copy them into d1 directory
Figure 1: content of d1

3. Display IP address of your computer.

Ifconfig
Therefore, IP address is 192.168.47.65

4. Display all the processes running on your computer (yours as well as processes run by all
other users currently working on the computer).

ps a // 𝑎 → 𝑖𝑛𝑐𝑙𝑢𝑑𝑒 𝑎𝑙𝑙 𝑤𝑖𝑡ℎ 𝑡𝑡𝑦 𝑎𝑛𝑑 𝑜𝑡ℎ𝑒𝑟 𝑢𝑠𝑒𝑟𝑠.


5. Write a command that displays only the files greater than 1000 bytes.

find . -type f -size +1000c

6. List all txt files in the current working directory.

ls *txt

7. Display what date is on this Saturday.

date -dlast-Saturday +%Y%m%d


8. Grant read-write-execute to owner, read-execute to group member and execute to all
others on file file1.txt. (You may need to create file1.txt if it does not exist).

cat > file1.txt //create file.txt


empty // write in the file
cat file1.txt //read the file and it will appear the content of this .txt file
chmod 751 file1.txt //specify the requirements in octal “111101001”

9. Display types of each file in your current directory.

for file in /home/ubuntu/*; do file "$file"; done


//file "$file" : run file on each of the items found in my current directory /home/ubuntu/*
 The format of the Output like file: type
10. Display first 10 lines of a file (any file) in the current working directory.

cat justDisplay.txt // display the content “”just to make sure it contain more than 10 lines””
first
second
third
4th
5th
6th
7th
8th
9th
10th
11th
head -10 justDisplay.txt // This instruction will output the first 10 lines
11. Save calendar of Jan-2009 in mycal.txt.

cat > mycal.txt //create mycal.txt


cal 1 2009 > mycal.txt //write inside it
cat mycal.txt //To see the content of the file
cat mycal.txt

12. Display the short host name and the IP address of the host [two commands are required here].

hostname // Display the short host name


hostname -I // Display IP address of the host

13. Display the path of the current working directory.

Pwd

14. List the contents in the / directory [in one-step].

ls -ld /
15. Write a command to append system date and time to the file mycal.txt, and then display
the file contents [two commands are required here].

echo `date` >> mycal.txt


cat mycal.txt

You might also like