You are on page 1of 4

University Institute of Information Technology

Operating System Concepts


CS-583
Lab 2: Introduction to Linux Commands
CLO1(Explain fundamental components of a computer operating system)

Week 5
Course Teacher: Dr. Kashif Sattar
Video Link:
https://drive.google.com/file/d/1hQWYILeIaErvLCA-mkVcpKuRcCZVr8uh/view?
usp=sharing
Lab 2: Introduction to Linux Commands

Objective:

The Objective of this lab is to familiarize yourself with linux commands.

Tools/Software Requirement
 Linux (Ubuntu)
OR
 Run terminal online (signup for creating user):

https://vfsync.org/vm.html?login=1

Browsing the File Hierarchy:


§ ls Display contents of a directory
§ ls -a Display all (including hidden files & dir)
§ ls -l
Permission No of files Owner Group Size(B) ModifiedD&T Name
-rwxrwxrwx 1 root root 86 Aug 19 09:59 ks.sh
drwxr-xr-x 3 root root 102 Aug 19 10:59 ksabc

Type of User: Owner, Group and Other

§ ls -S Display files order by file size


§ ls -n Display files with UID and GID
§ Many more options……….

Task 1: Practice Linux Commands and take screen shots:


§ cd Change directory
o cd , cd ~, cd .., cd /
§ man ls Manual for ls command (for online compiler it might not work)
§ pwd Print working directory
§ mkdir Create directory
o mkdir UAAR Create the directory in your current directory
§ mkdir ~/UIIT/courses/
Create the ‘courses’ directory in your ~/UIIT directory
 mkdir ~/UIIT/courses/programs
Create the ‘programs’ directory in your ~/UIIT/courses directory
§ rmdir Remove directory
o rm UAAR
§ cp Copy file
o cp file1.txt file2.txt
Copy ‘file1.txt’ in your current directory to ‘file2.txt’ in your current
directory
§ cp ~/file1.txt ~/UIIT/courses/programs/file2.txt
Copy ‘~/file1.txt’ to ‘~/UIIT/courses/programs /file2.txt’
§ rmdir ~/UIIT/courses/programs
Remove the ‘programs’ directory under your ~/UIIT/courses directory
o rm -rf ~/UIIT/courses/programs removing non empty directory

§ mv Move file
o mv file1.txt file2.txt
Move ‘file1.txt’ in your current dir to ‘file2.txt’ in your current dir
o mv ~/file1.txt ~ /UIIT/courses/file2.txt
Move ‘~/file1.txt’ to ‘~/UIIT/courses/file2.txt’

§ rm Remove file
o rm abc.txt
Remove ‘abc.txt’ from your current directory
o rm ~/UIIT/courses/file2.txt
Remove ‘file2’ in the ‘courses’ dir in your ~/UIIT directory
 rm *.o
Remove all .o (i.e., object) files from your current directory

Task 2: Practice Some more useful Linux Commands and take screen shots:
§ touch create file without opening the file
§ vi create/open file for editing
§ Command mode (press esc for that)
§ E.g :wq (for write and quit)
§ Insert mode (press i for that)
§ cat Display contents of a file
§ cat file1 >> file2 copy contents of file1 in file2
§ cmp Compare two files (No message means both files are same)
§ tar -cvf file.tar file1 file2 …..
§ tar -xvf file.tar
§ ifconfig view the configuration of network interfaces
§ ping google.com
§ chmod u=rwx,g=rx,o=r myfile (a=rwx for all)
§ chmod 777 myfile
§ uname information about current system
§ cat /etc/os-release To see the version of linux in detail
§ history display the previous executed commands
§ cal 02 2020 display the calender of feb 2020
§ date display the system date and time

Deliverables:
Upload the document (containing screen shots of your commands execution on
terminal within your user[name must be your name] directory) on google classroom in
Lab2 Assignment.
This lab is graded. Min points: 0 and Max points: 10.
University Institute of Information Technology
Operating System Concepts
CS-583
Lab 2: Introduction to Linux Commands

Lab 2- Solution

Task # 1:
Add your screen shots here
Task # 2:
Add your screen shots here

You might also like