0% found this document useful (0 votes)
16 views8 pages

CS 505 Linux LAB Experiments

The document outlines various experiments related to Unix/Linux commands and scripting, including basic commands, file creation and statistics, finding common names in files, checking inode numbers, changing file permissions, executing commands in the VI editor, and writing a shell script. Each experiment provides objectives, commands, examples, and explanations for clarity. The document serves as a practical guide for understanding and using Unix/Linux functionalities.

Uploaded by

singhaushi75
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
16 views8 pages

CS 505 Linux LAB Experiments

The document outlines various experiments related to Unix/Linux commands and scripting, including basic commands, file creation and statistics, finding common names in files, checking inode numbers, changing file permissions, executing commands in the VI editor, and writing a shell script. Each experiment provides objectives, commands, examples, and explanations for clarity. The document serves as a practical guide for understanding and using Unix/Linux functionalities.

Uploaded by

singhaushi75
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 8

Experiment 1: Study of Basic and User Status Unix/Linux Commands

Objective: To study basic and user status Unix/Linux commands.

Some basic Unix/Linux commands include:

1. cd - change directory

2. pwd - print working directory

3. ls - list files and directories

4. mkdir - make a directory

5. rm - remove a file or directory

6. cp - copy a file

7. mv - move or rename a file

User status commands include:

1. whoami - print the current user's username

2. id - print the current user's ID and group ID

3. groups - print the groups the current user belongs to


Experiment 2: Creating a File and Displaying its Statistics
Objective: To create a file called wlcc.txt with some lines and display how many lines, words, and character

To create a file called wlcc.txt, use the following command:

nano wlcc.txt

Add some lines to the file, for example:

This is the first line.

This is the second line.

This is the third line.

To display the number of lines, words, and characters in the file, use:

wc wlcc.txt

Output:

3 12 60 wlcc.txt

Explanation:

1. 3 is the number of lines

2. 12 is the number of words

3. 60 is the number of characters


Experiment 3: Finding Common Names in Two Files
Objective: Given two files each of which contains names of students, create a program to display only thos

Assume two files, file1.txt and file2.txt, with names:

file1.txt:

John

Alice

Bob

Charlie

file2.txt:

Alice

Bob

David

Eve

To find common names, use:

comm -12 file1.txt file2.txt

Output:

Alice

Bob

Explanation:

1. comm compares two sorted files.

2. -12 option displays lines common to both files.


Experiment 4: Finding the Inode Number of a File
Objective: Create a program to find out the inode number of any desired file.

To find the inode number of a file, use:

ls -i filename

For example:

ls -i wlcc.txt

Output:

12345 wlcc.txt

Explanation:

12345 is the inode number of the file wlcc.txt


Experiment 5: Changing File Permissions
Objective: Study and use of the command for changing file permissions.

To change file permissions, use:

chmod permissions filename

Example:

chmod 755 wlcc.txt

Explanation:

1. 7: owner has read, write, and execute permissions.

2. 5: group has read and execute permissions.

3. 5: others have read and execute permissions.


Experiment 6: Executing Shell Commands through VI Editor
Objective: Execute shell commands through VI editor.

To execute a shell command in VI editor, use:

:!command

Example:

:!ls

This executes the ls command and displays output in the VI editor.


Experiment 7: Installation, Configuration, and Customization of Unix/Linux
Objective: Installation, configuration, and customization of Unix/Linux.

Steps for installation, configuration, and customization:

1. Install the operating system.

2. Configure network settings.

3. Set up user accounts.

4. Customize the desktop environment.

5. Install additional software packages.


Experiment 8: Writing a Shell Script to Print Arguments in Reverse Order
Objective: Write a shell script that accepts any number of arguments and prints them in reverse order.

Create a file reverse_args.sh with:

#!/bin/bash

args=("$@")

for ((i=${#args[@]}-1; i>=0; i--)); do

echo "${args[i]}"

done

Make it executable:

chmod +x reverse_args.sh

Run the script:

./reverse_args.sh apple banana orange

Output:

orange

banana

apple

Explanation:

1. args=("$@") stores command-line arguments in an array.

2. Loop iterates in reverse order.

3. echo prints each argument.

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy