0% found this document useful (0 votes)
21 views

Basic Commands of Bash

Muhammad Nazir completed various Linux commands on creating, modifying, and merging files. This included creating text files, adding C++ code and data, merging files using cat, setting permissions using chmod, finding strings using grep, checking dates and locations using date and pwd, and creating a directory. Commands were used to display file contents, set execution permissions for groups, remove write permissions, and get the numeric representation of file permissions.

Uploaded by

Muhammad Nazir
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
21 views

Basic Commands of Bash

Muhammad Nazir completed various Linux commands on creating, modifying, and merging files. This included creating text files, adding C++ code and data, merging files using cat, setting permissions using chmod, finding strings using grep, checking dates and locations using date and pwd, and creating a directory. Commands were used to display file contents, set execution permissions for groups, remove write permissions, and get the numeric representation of file permissions.

Uploaded by

Muhammad Nazir
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 11

Muhammad Nazir (2021-CS-8)

Work done on Linux Prompt:


Task1:

Creating "19f-XXXX.txt" File:


I have created a file named "19f-XXXX.txt". This file contains the C++ code of finding factorial.

Used Command: touch 19f-XXXX.txt**

Creating "Muhammad_Nazir.txt" File:


Now I have created another file named "Muhammad_Nazir.txt". This also contains data of more than 10
lines.

Used Command: touch Muhammad_Nazir.txt


Merging Both Files:
After creating "19f-XXXX.txt" and Muhammad_Nazir.txt, I have merged these files.

Used Command: cat 19f-XXXX.txt Muhammad_Nazir.txt >> Merged_file.txt

Redirect Output in Merged File:


When I have merged files, the output is already redirected.

Used Command: cat 19f-XXXX.txt Muhammad_Nazir.txt >> Merged_file.txt


Displaying First Two Lines:
Then I have displayed the first two lines of "19f-XXXX.txt".

Used Command: head -2 19f-XXXX.txt

Displaying last Two Lines:


Then I have displayed the last two lines of "19f-XXXX.txt".

Used Command: tail -2 Muhammad_Nazir.txt


Finding String:
Now I have tried to find some specific string in files.

Used Command(from all files): grep -r "2021-CS-8"

Used Command(from all files): grep -r "2021-CS-8" 19f-XXXX.txt

Giving Execution Permission:


Here I have tried many command to give group execution permission.
Used Command: chmod g+x Muhammad_Nazir.txt

Removing Write Permission:


Now , I have removed the write permission of second file.

Used Command: chmod u-w Muhammad_Nazir.txt

Displaying Current Location:


Now, I have find my current location.
Used Command: pwd

Finding List of All Files on Desktop:


Now, I find the list of all files present on desktop directory.

Used Command: ls

Making Directory:
Then I have created a directory named "2021-CS-8".
Used Command: mkdir 2021-CS-8

Checking Current Date:


After that I have displayed the current time.

Used Command: date

Displaying Message:
After completing my all parts of task1, I have displayed thankyou message.
Used Command: echo Thank you

Task2:

Creating 19f-XXXX_OS-lab_rules.txt File:


First, I have created 19f-XXXX_OS-lab file that contains all the rules from Lab1.

Used Command: touch 19f-XXXX_OS-lab_rules.txt


Creating (-rws r-x r--):
Here I have created the read, right and execution rights. Initially, my file contains rights i.e

(-rwxrwxr-x). Then I have used commands to make given rights.

Used Commands: chmod g-w 19f-XXXX_OS-lab_rules.txt

Used Commands: chmod o-x 19f-XXXX_OS-lab_rules.txt

Creating Numeric Format of Rights:


Then I have created numeric value of rights given us.

Used Command: stat -c "%a" 19f-XXXX_OS-lab_rules.txt


Change File Permission using Derived Number:
Initially, I gave all the rights to created file using chmod commands.

Used Commands: chmod 777 19f-XXXX_OS-lab_rules.txt

Used Commands: chmod 754 19f-XXXX_OS-lab_rules.txt

Part4:
At the end, I have append the output of ls command to created file "19f-XXXX_OS-lab_rules.txt".
Used Command: ls -l 19f-XXXX_OS-lab_rules.txt >> 19f-XXXX_OS-lab_rules.txt

You might also like