Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

PLease do all steps, this is UNIX. THIS IS PART A FOR REFERENCE. You only need to do part B below is the picture of

PLease do all steps, this is UNIX.

THIS IS PART A FOR REFERENCE. You only need to do part B below is the picture of part A for better referance.

image text in transcribed

Part A (Sobell) using command(s) to create directories and files.

First, create a directory named cs3377 (if you do not have created it yet), and change directory to cs3377.

Task#1. Create a directory named a1part1. Use ls -l command to show the directory information of a1part1.

Then cd to this directory (a1part1).

Copy and paste the run-output of your work here (You may copy and paste mobaXterm console output for this task only)

Task#2. Create all the files and directories as shown and explained below.

image text in transcribed

Copy and paste the run-output of your work here (You may copy and paste mobaXterm console output for this task only)

Task#3. After creating each file and directory, let the content of each file be the output of "ls -l" command of the directory in which the file is created (for example, ls -l > file1.txt).

Copy and paste the run-output of your work here (You may copy and paste mobaXterm console output for this task only)

Task#4. You will change the file attribute of each file as follows.

all the files (and subdirectories and files if any) in dir1 with rw- --- ---

all the files (and subdirectories and files if any) in dir2 with rwx rw- r-x

Copy and paste the run-output of your work here (You may copy and paste mobaXterm console log for this task only)

Task#5. Read Sobell on ls command (pages 861-868).

And try ls commands shown below with a few options. Show your result of each command.

Your current working directory is a1part1. Note that you should use dash ("-") for command option(s) here.

ls l

ls lR

ls lRi

ls lR --si

ls lR --sort=time

ls lR --sort=size

Copy and paste the run-output of your work here (You may copy and paste mobaXterm console output for this task only)

Task#6. You ade currently in the directory: a1part1. List all the files and subdirectories. Save its output to a1task6.txt:

ls R

ls R > a1task6.txt

cat a1task6.txt

Copy and paste the run-output of your work here (You may copy and paste mobaXterm console output for this task only)

Task #7. Write a bash shell script in cs3377 directory.

First (1), create a shell script (myScript1.sh) in cs3377 directory by: touch myScript1.sh

Second (2), change its file attribute to be executable: chmod a+x myScript1.sh

Third (3), edit this file with vi or vim

Fourth (4), insert the first line of the file to be: #!/bin/sh

Fifth (4), collect all the commands from Task#2 to Task#6, and insert each command to be one line in this file.

Make sure that you are in the right directory to execute each command as specified in each task.

For example, for task#6, you should have: cd a1task6 (before running ls R)

The script file will contain:

#!/bin/sh

mkdir a1part1

cd a1part1

mkdir dir1

cd dir1

touch file1.txt

Copy and paste your shell script here

Task#8. You are in cs3377 directory. First, remove (delete) a1part1 directory and all the files and its subdirectories recursively (with rm command). Show (ls R) that all the files and its subdirectories are deleted. List the directory information and also save the output to task8.txt.

rm r a1part1

ls R a1part1

ls R a1part1 > a1task8.txt

Copy and paste the output of Task#8 here

Task #8. Write a bash shell script (myScript2.sh) in cs3377 directory, to do what you did in Task#7 (to delete a1part1 directory and all files and subdirectories of a1part1 in cs3377).

Copy and paste your shell script (myShell2.sh) here

Task#9. run the myShell.sh file to recreate all the files and directories that you have done in Task#2 to Task#6.

List all the files and subdirectories and save its output to a file:

ls R

ls R > a1task9.txt

Copy and paste the output of Task#9.

______________________________________________________________________________________________

Part B- (C/C++ Programming) using system function call to execute a shell command.

You will do here what you did in Part1, using C/C++ program and system( ) call.

You may check the sample programs (for hint) listed below.

In cs3377 directory, create a subdirectory (a1part2) and cd to a1part2.

Task #1.

Write a C/C++ program (a1part2task1.c, and its executable named a1part2task1) to create a few directories and files as you have done in Part1. Your executable is named "a1part2task1".

You may use system("command" ) function call to run "command". For detail, check APUE 8.13 (pages 264-269). To change directory, you may use chdir( ) function call along with getcwd( ) function call. For detail, check APUE 4.23 (pages 135-137, and a sample program in Figure 4.24). Also you may use the sample code as a base for your work (available at the end of this document).

Copy and paste your program listing (a1part2task1.c) here

Copy and paste the log of how to compile this program

Copy and paste the run of your program here (./a1part2task1)

Task #2. Write c/c++ program (a1part2task2.c and its executable named a1part2task2).

Note. This may sound a bit odd first but it will make sense after all (or later).

The program (a1part2task2) will (a) compile a1part2task1.c program (which you have written in Part2 Task#1, to make its executable a1part3task1) and (b) then it will run the program (a1part1task1). You may use system("command") in your program. For example, to create a file (file1.txt), you call in your program: system("touch file1.txt");

Copy and paste your program listing (a1part2task2.c program) here

Listing of how to compile this program and its log

Listing of the program run (a1part2task2) here

Listing of Makefile to compile these programs

Submit two files (to be attached for your upload): (1) this word document with your answer and (2) a zip file (including each program (source), its executable, and its log of the run, and Makefile).

Part3 - Use of Find command and Regular Expression.

** Do this part in cs1.utdallas.edu

Create a subdirectory(a1part3) in cs3377 directory

Using the find utility, perform the following tasks (where the directory is "/usr/include").

Try first "ls R /usr/include | wc"

ls -R | wc

24379 23090 362358

This tells that there are 24379 entries in /usr/include.

Task#1. List all files in the directory and all subdirectories that have been modified within the last 30 days. How many are they? List the number (count) of the files listed as well. First, you may run this command with a pipe to wc command to get an estimate for the number of the files.

(Note. You may be a bit overwhelmed by the sheer size of /etc directory. To avoid those files without your access, you may get first the list of the files to find first those files that you can access to work with.)

command(s) in pipe, including find command, to do this task

the result of command(s) run the list of the files and then the count

Task#2. List all files you have read access in the directory and all subdirectories that are larger than 1 kilobyte.

How many are they? List the number (count) of the files listed as well. You may run the same command pipe to wc command to list the number of the files.

command(s) in pipe, including find command, to do this task

the result of command(s) run the list of the files and then the count

Task#3. List the inode numbers of all files in the directory whose filenames end in .c.

command(s) in pipe, including find command, to do this task

the result of command(s) run the list of the files and then the count

bin mkdir alpartl cd alpartl mkdir dirl mkdir dir2 touch file1.txt rm file1.txt touch file3.txt cd dir1 touch file1.txt mkdir dir11 cd dirl1 touch file11.txt cd dir2 touch file2.txt 1n-s ./file2.txt . ./linkl s -1 file1.txt cat file1.txt cd dir1 s -1 f1le.txt cat file.txt find . -type f -printoI xargs 0 chmod 765 cd dir1 1s-1R 1s -1R--sort-time 1s -R > altask6.txt cat altask6.txt bin mkdir alpartl cd alpartl mkdir dirl mkdir dir2 touch file1.txt rm file1.txt touch file3.txt cd dir1 touch file1.txt mkdir dir11 cd dirl1 touch file11.txt cd dir2 touch file2.txt 1n-s ./file2.txt . ./linkl s -1 file1.txt cat file1.txt cd dir1 s -1 f1le.txt cat file.txt find . -type f -printoI xargs 0 chmod 765 cd dir1 1s-1R 1s -1R--sort-time 1s -R > altask6.txt cat altask6.txt

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Machine Learning And Knowledge Discovery In Databases European Conference Ecml Pkdd 2022 Grenoble France September 19 23 2022 Proceedings Part 4 Lnai 13716

Authors: Massih-Reza Amini ,Stephane Canu ,Asja Fischer ,Tias Guns ,Petra Kralj Novak ,Grigorios Tsoumakas

1st Edition

3031264118, 978-3031264115

More Books

Students also viewed these Databases questions

Question

What are the best practices for managing a large software project?

Answered: 1 week ago

Question

How does clustering in unsupervised learning help in data analysis?

Answered: 1 week ago