0% found this document useful (0 votes)
6 views9 pages

Os Lab1

This document provides an introduction to Linux OS and its commands, highlighting its significance in various computing environments. It covers basic Linux commands such as 'whoami', 'pwd', 'ls', and 'grep', explaining their functions and usage. The document emphasizes the importance of being familiar with these commands for effective operation within the Linux operating system.
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views9 pages

Os Lab1

This document provides an introduction to Linux OS and its commands, highlighting its significance in various computing environments. It covers basic Linux commands such as 'whoami', 'pwd', 'ls', and 'grep', explaining their functions and usage. The document emphasizes the importance of being familiar with these commands for effective operation within the Linux operating system.
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

OS LAB

CLASS 1

Introduction of Linux OS:

In this lab, you will learn to use various Linux commands to operate the Linux operating
systems. Linux is a family of open-source Unix-like operating systems based on the Linux
kernel, an operating system kernel first released on September 17, 1991, by Linus Torvalds.
Popular Linux distributions include Debian, Fedora Linux, and Ubuntu, the latter of which itself
consists of many different distributions and modifications, including Lubuntu and Xubuntu.
Linux was originally developed for personal computers based on the Intel x86 architecture, but
has since been ported to more platforms than any other operating system. Because of the
dominance of the Linux-based Android on smartphones, Linux, including Android, has the
largest installed base of all general purpose operating systems, as of May 2022 [1]. Linux has a
worldwide market share of 2.68% on desktops, but over 90% of all cloud infrastructure and
hosting services run in this operating system. For this reason alone, it is crucial to be familiar
with popular Linux commands [2].

Linux Commands:

 A Linux command is a program or utility that runs on the command line. A command
line is an interface that accepts lines of text and processes them into instructions for your
computer.
 Any graphical user interface (GUI) is just an abstraction of command-line programs. For
example, when you close a window by clicking on the “X,” there’s a command running
behind that action.
 A flag is a way we can pass options to the command you run. Most Linux commands
have a help page that we can call with the flag -h. Most of the time, flags are optional.
 An argument or parameter is the input we give to a command so it can run properly. In
most cases, the argument is a file path, but it can be anything you type in the terminal.
 You can invoke flags using hyphens (-) and double hyphens (--), while argument
execution depends on the order in which you pass them to the function.

Basic Linux Commands

1. Whoami: This command shows the current logged-in user name. It helps you identify
which user is using the system.
2. Pwd: Print Working Directory shows the current folder path. It tells where you are in the
system.

3. ls: Lists all files and directories in the current location. It is used to view folder contents.

4. ls –r: Lists files in reverse order. Useful when you want opposite sorting.
5. s –al: Shows all files including hidden files. Hidden files start with a dot (.)

6. history: Displays all previously executed commands. Helps to track command usage.

7. Clear: Clears the terminal [Link] does not delete data, only cleans display.

8. Echo: Displays text or writes text into a file. Used for printing messages.
9. touch: Creates a new empty file. If file exists, it updates its timestamp( (access and
modification times).

10. rm: Deletes a file permanently. Use carefully because it cannot be undone.

11. mkdir: Creates a new directory (folder). Used to organize files.

12. rmdir: The rmdir command in Linux is used to delete empty directories.
 Removes directories that do not contain files.
 Helps clean up unused folders.

13. mv: Used to move or rename files. Very useful for file management.
14. cd: Changes the current directory. Used to navigate between folders.

15. cmp: Compares two files and shows differences. If same, no output is shown.
Code:

touch [Link] [Link]


echo Hello World > [Link]
echo Hello India > [Link]
cmp [Link] [Link]

16. cat: Displays content of a file. Also used to create or combine files.

17. cal: Displays calendar of current month. Useful for checking dates.
18. cal –y: Shows full calendar of the year. Displays all months.

19. cal 2021: Displays calendar of a specific year.


You can give any year.
20. passwd: Used to change user password. System will ask for new password.
Write passwd , then enter

21. grep: Searches a word inside a file. Very useful for filtering data.
Code:

touch [Link]
echo "Linux is an operating system used all over the world.
Linux is open source and freely available.
Many students learn Linux for programming and development.
Linux is powerful, secure, and efficient.
It is widely used in servers and cloud computing.
Linux supports multiple users at the same time.
Many companies prefer Linux for its stability.
Learning Linux commands is very important for students.
Linux provides both command line and graphical interface.
Practice of Linux commands improves problem solving skills." > [Link]
grep "Linux" [Link]
22. free: Shows system memory usage (RAM). Displays used and free memory.

23. Uname: Shows system name or OS name. Basic system information.

24. uname –a; Displays full system details. Includes kernel, version, architecture.

25. uname –s: Shows only OS name. Short version of uname.

26. uname –n: Displays network node name (hostname). Used in networking.

27. group: In Linux, a group is a collection of user accounts used to simplify the
management of system permissions
28. comm: Compares two sorted files line by [Link] common and different lines.

Code:

touch [Link] [Link]


echo "Apple" > [Link]
echo "Banana" >> [Link]
echo "Mango" >> [Link]
echo "Orange" >> [Link]
echo "Apple" > [Link]
echo "Grapes" >> [Link]
echo "Mango" >> [Link]
echo "Pineapple" >> [Link]
Sort Both Files

sort [Link] -o [Link]


sort [Link] -o [Link]
cat [Link]

Apple
Banana
Mango
Orange
cat [Link]

Apple
Grapes
Mango
Pineapple
comm [Link] [Link]

🔹 29.
Date: Displays current date and time. Used in system logs.

30. date –d: Shows date based on given input. Example: tomorrow, next Monday.

date -d "tomorrow"
31. wc: Counts lines, words, and characters in file. Useful for text analysis.

$ wc [Link]
Output
5 7 58 [Link]
here,
 5: Number of Lines
 7: Number of Words
 58: Number of4
bytes4444444444444444444444444444445432222222222222222222222

You might also like