Join WhatsApp Group Join Now!

LINUX BASICS 312001 Experiment No 04 Execute file and Directory manipulation commands Answer

LINUX BASICS 312001 MANUAL
Please wait 0 seconds...
Scroll Down and click on Go to Link for destination
Congrats! Link is Generated

LINUX BASICS 312001 Experiment No. 04 Execute file and Directory manipulation commands Answer 

LINUX BASICS 312001
LINUX BASICS 312001

Practical Significance

Data and programs are stored in files. These are organized in directories. Simply, a directory is just a file that contains other files (or directories). Various operations that can be performed on a file are created, opened, read, written, moved, closed, and renamed.

Program code

1. Create the following Structure

312001

Answer:

Bash
mkdir MSBTE  # Create the main directory
mkdir MSBTE/K_SCHEME MSBTE/I_SCHEME MSBTE/CO2K  # Create three subdirectories under MSBTE
mkdir MSBTE/CO2K/IF2K MSBTE/CO2K/CM21  # Create two subdirectories under CO2K

2. Create 3 files p1 p2 p3

Answer: 

touch p1 p2 p3

Result

We successfully completed practical on Execute file and Directory manipulation commands.

Practical related questions

1. How to shift from Root directory to User (Home) directory?
Answer:
  • Using cd ~:
This is the simplest and most common way. The tilde symbol (~) is a shorthand for your home directory path. So, cd ~ essentially translates to "change directory to home."
  • Using cd without arguments:
You can simply type cd by itself and press enter. This will also achieve the same result as cd ~ because cd with no arguments defaults to your home directory.

2. How to see directories?
Answer:

ls: This basic command lists the names of files and subdirectories in the current directory.
ls -l: This option provides a detailed listing with additional information like permissions, owner, group, size, and last modification time.
ls <directory_name>: This allows you to see the contents of a specific directory. For example, ls Documents would list the contents of your Documents directory.


3.What are different options of mv command?

Answer: 


Exercise:

Write the command for performing the following tasks sequentially
Answer:

a. Display your current directory:

Bash
pwd

b. Create a directory ‘subject’ in the current directory:

Bash
mkdir subject

1. Create a file ‘sample’ in the directory ‘subject’:

Bash
touch subject/sample

c. Create a file ABCD.txt, create a copy with XXX.txt. Rename the original file with AACD.txt. Delete the file XXX.txt.

Bash
touch ABCD.txt
cp ABCD.txt XXX.txt
mv ABCD.txt AACD.txt
rm XXX.txt


d. Display the inodes of any two files at the same time:

Bash

ls -i AACD.txt sample

e. Create two files unit1 and unit2 and perform the following operations

Answer: 

# Create empty files unit1 and unit2
touch unit1 unit2

# Copy contents of unit1 to unit2
cp unit1 unit2

# Display inodes of two files
echo "Inode of unit1: $(stat -c '%i' unit1)"
echo "Inode of unit2: $(stat -c '%i' unit2)"

# Rename unit1 to Lesson1
mv unit1 Lesson1

echo "Operations completed successfully!"
Hi everyone, I'm Suraj Diware, and I'm passionate about helping students succeed in MSBTE programs. This blog is dedicated to providing clear and concise explanations of MSBTE curriculum topics, along with practical tips and resources to sup…

Post a Comment

Cookie Consent
We serve cookies on this site to analyze traffic, remember your preferences, and optimize your experience.
Oops!
It seems there is something wrong with your internet connection. Please connect to the internet and start browsing again.