1. Create few nested and branched directories in your home directory. Populate t
ID: 3739737 • Letter: 1
Question
1. Create few nested and branched directories in your home directory. Populate them with some files. Copy some files around, move to rename files or to move files between directories. 2. Change permissions to some of the files to add 'x', 'w'to you only, to the group, and to the all. Do Is -I to verify changes. What you see? a. Do a web search and find out how to change permissions recursively 4. Delete non-empty directory with rmdir command. What you see? What should you do to delete directory? elete all other directories you created with rm-rf command. Do Is -I from your home directory to verify You can do this here, in the lab, or if you prefer, at your home. How to submit: Copy your relev saw, how mail address as a body of the message not the attachement. ant history entries. Add comments of what you did and what was the result (what you you verified the commands). Save everything in the text file (no word!) and email to my e-Explanation / Answer
(1) create a directories and copy,rename,move some files between directories
//First I create directories with name chegg
hardu@ankit:~$ mkdir chegg
//going inside into directory chegg
hardu@ankit:~$ cd chegg/
//In side chegg directory I create 3 different directory
hardu@ankit:~/chegg$ mkdir directory1
hardu@ankit:~/chegg$ mkdir directory2
hardu@ankit:~/chegg$ mkdir directory3
//we can see 3 directory under chegg
hardu@ankit:~/chegg$ ls
directory1 directory2 directory3
//Going inside directory1
hardu@ankit:~/chegg$ cd directory1/
hardu@ankit:~/chegg/directory1$
//we're create different files
hardu@ankit:~/chegg/directory1$ vi file1
hardu@ankit:~/chegg/directory1$ vi file2
hardu@ankit:~/chegg/directory1$ vi file3
hardu@ankit:~/chegg/directory1$ vi file4
hardu@ankit:~/chegg/directory1$ vi file5
hardu@ankit:~/chegg/directory1$ vi file6
hardu@ankit:~/chegg/directory1$ ls
file1 file2 file3 file4 file5 file6
//I write something inside
hardu@ankit:~/chegg/directory1$ vi file6
//Now, we'll create copy using cp command
hardu@ankit:~/chegg/directory1$ cp file6 file7
//Here we can see file6 and file7 both are same.
hardu@ankit:~/chegg/directory1$ cat file6
HI chegg user
I hope you got answer !!
Regards,
chegg expert
hardu@ankit:~/chegg/directory1$ cat file7
HI chegg user
I hope you got answer !!
Regards,
chegg expert
//Now, we'll change the name of file using mv command
hardu@ankit:~/chegg/directory1$ mv file4 file11
hardu@ankit:~/chegg/directory1$ mv file5 file22
hardu@ankit:~/chegg/directory1$ mv file6 file33
hardu@ankit:~/chegg/directory1$ ls
file1 file11 file2 file22 file3 file33 file7
//Now, we'll moving files with different directory
hardu@ankit:~/chegg/directory1$ mv file2 file22 ../directory2
hardu@ankit:~/chegg/directory1$ mv file3 file33 ../directory3
//Inside directory1 three files
hardu@ankit:~/chegg/directory1$ ls
file1 file11 file7
hardu@ankit:~/chegg/directory1$ cd ../directory2
//Inside directory2 two files
hardu@ankit:~/chegg/directory2$ ls
file2 file22
hardu@ankit:~/chegg/directory2$ cd ../directory3
////Inside directory3 two files
hardu@ankit:~/chegg/directory3$ ls
file3 file33
=============================================================================================
(2) Change permission with user,group and all
//Inside directory1 three files we can see with
//(-rw-rw-r--)means user read/write/excute, group read/write/excute, All users read/write/excute
hardu@ankit:~/chegg/directory1$ ls -l
total 4
-rw-rw-r-- 1 hardu hardu 0 Mar 29 23:59 file1
-rw-rw-r-- 1 hardu hardu 0 Mar 30 00:00 file11
-rw-rw-r-- 1 hardu hardu 62 Mar 30 00:02 file7
//here I'm give the file1 permission only user can excute
hardu@ankit:~/chegg/directory1$ chmod u+x file1
//here I'm give the file11 permission only group can excute
hardu@ankit:~/chegg/directory1$ chmod g+x file11
//here I'm give the file7 permission all user can excute
hardu@ankit:~/chegg/directory1$ chmod o+x file7
//we can see below
hardu@ankit:~/chegg/directory1$ ls -l
total 4
-rwxrw-r-- 1 hardu hardu 0 Mar 29 23:59 file1
-rw-rwxr-- 1 hardu hardu 0 Mar 30 00:00 file11
-rw-rw-r-x 1 hardu hardu 62 Mar 30 00:02 file7
//here I'm give the file1 permission only user can write
hardu@ankit:~/chegg/directory1$ chmod u+w file1
//here I'm give the file11 permission only group can write
hardu@ankit:~/chegg/directory1$ chmod g+w file11
//here I'm give the file7 permission all user can write
hardu@ankit:~/chegg/directory1$ chmod o+w file7
//we can see below, but all files all user readale
hardu@ankit:~/chegg/directory1$ ls -l
total 4
-rwxr--r-- 1 hardu hardu 0 Mar 29 23:59 file1
-r--rwxr-- 1 hardu hardu 0 Mar 30 00:00 file11
-r--r--rw- 1 hardu hardu 62 Mar 30 00:02 file7
=============================================================================================
(3) chmod mode recursively
//we can change file permissions we have to use the chmod command.
//-R option change files and directories recursively.
//chown command can be used to change user and group permission.
=============================================================================================
(4) Delete non-empty directory, what with rmdir command, what happend...
//here, directory3 inside two files
hardu@ankit:~/chegg/directory3$ ls
file3 file33
//Now, we'll check we can able to delete or not so, we're going outside the directory3
hardu@ankit:~/chegg/directory3$ cd ..
//we're giving rmdir command
hardu@ankit:~/chegg$ rmdir directory3
rmdir: failed to remove `directory3': Directory not empty
//here we can't delete the non-empty directory because some files or directory present in this directory3 so, we have delete first inside directory3 files after then we can delete directory3
hardu@ankit:~/chegg$ cd directory3
//Inside directory3 two files
hardu@ankit:~/chegg/directory3$ ls
file3 file33
//delete both files
hardu@ankit:~/chegg/directory3$ rm file3 file33
hardu@ankit:~/chegg/directory3$ ls
hardu@ankit:~/chegg/directory3$ cd ../directory3
hardu@ankit:~/chegg/directory3$ cd ..
//Now, we can delete non-empty directory3
hardu@ankit:~/chegg$ rmdir directory3
=============================================================================================
(5) Delete directories using rm -rf command
//Now, inside chegg two directories
hardu@ankit:~/chegg$ ls
directory1 directory2
hardu@ankit:~/chegg$ cd directory1
//inside directory1 three files
hardu@ankit:~/chegg/directory1$ ls
file1 file11 file7
hardu@ankit:~/chegg/directory1$ cd ../directory2
//inside directory2 four files
hardu@ankit:~/chegg/directory2$ ls
file2 file22 file3 file33
hardu@ankit:~/chegg/directory2$ cd ../
//Now, we can remove directories and their contents recursively
hardu@ankit:~/chegg$ rm -rf directory1
hardu@ankit:~/chegg$ ls
directory2
hardu@ankit:~/chegg$ rm -rf directory2
// we can check using ls command no anyone directories
hardu@ankit:~/chegg$ ls
hardu@ankit:~/chegg$
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.