Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

1. [100] Your login name: jsmith i.e., home directory/home/jsmith. The home dire

ID: 3881732 • Letter: 1

Question

1. [100] Your login name: jsmith i.e., home directory/home/jsmith. The home directory contains the following sub-directories: code, tests, personal, misc Unless otherwise specified, you are running commands from the home directory. a. Change directory to the tests directory using absolute pathname b. Change directory to the tests directory using relative pathname c. Use echo command to create a file named fileA with text content 'Hello A' in the misc directory d. Create an empty file named fileB in the misc directory e. Copy contents of fileA into fileC f. Move contents of fileB into fileD g. Create a tar archive called misc.tar for the contents of misc directory h. Compress the tar archive to create a misc.tar.gz file Move the misc.tar.gz file to the tests directory j. Uncompress the misc.tar.gz file k. Extract the archived file from previous step I. Change directory to the extracted directory m. List the files in the extracted directory n. Change the directory back to the home directory o. Type in the command to confirm the home directory

Explanation / Answer

As mentioned in your question, I have created jsmith user and specified directories in it.

[root@host-1-81 ~]# useradd jsmith -d /home/jsmith
[root@host-1-81 ~]# passwd jsmith
Changing password for user jsmith.
New password:
BAD PASSWORD: The password is shorter than 8 characters
Retype new password:
passwd: all authentication tokens updated successfully.
[root@host-1-81 ~]# su - jsmith
[jsmith@host-1-81 ~]$ pwd
/home/jsmith
[jsmith@host-1-81 ~]$ mkdir -p code tests personal misc
[jsmith@host-1-81 ~]$ ls -ltr
total 0
drwxrwxr-x. 2 jsmith jsmith 6 Feb 1 04:46 tests
drwxrwxr-x. 2 jsmith jsmith 6 Feb 1 04:46 personal
drwxrwxr-x. 2 jsmith jsmith 6 Feb 1 04:46 misc
drwxrwxr-x. 2 jsmith jsmith 6 Feb 1 04:46 code

----------------------------------------------------------------------------------------------------------------------------------------------------

a)  cd /home/jsmith/tests/

[jsmith@host-1-81 ~]$ cd /home/jsmith/tests/
[jsmith@host-1-81 tests]$ pwd
/home/jsmith/tests

b)  cd ./tests/

[jsmith@host-1-81 ~]$ cd ./tests/

[jsmith@host-1-81 tests]$ pwd
/home/jsmith/tests

c) [jsmith@host-1-81 ~]$ echo "Hello A" >/home/jsmith/misc/fileA

[jsmith@host-1-81 ~]$ cat /home/jsmith/misc/fileA
Hello A

d) [jsmith@host-1-81 misc]$ touch fileB
[jsmith@host-1-81 misc]$ ls fileB
fileB

e) [jsmith@host-1-81 misc]$ cp fileA fileC
[jsmith@host-1-81 misc]$ cat fileC
Hello A

f)  [jsmith@host-1-81 misc]$ cp fileB fileD

g)  [jsmith@host-1-81 ~]$ tar -cvf misc.tar misc
misc/
misc/fileA
misc/fileB
misc/fileC
misc/fileD
[jsmith@host-1-81 ~]$ ls -ltr
total 12
drwxrwxr-x. 2 jsmith jsmith 6 Feb 1 04:46 tests
drwxrwxr-x. 2 jsmith jsmith 6 Feb 1 04:46 personal
drwxrwxr-x. 2 jsmith jsmith 6 Feb 1 04:46 code
drwxrwxr-x. 2 jsmith jsmith 54 Feb 1 04:55 misc
-rw-rw-r--. 1 jsmith jsmith 10240 Feb 1 04:58 misc.tar

h)  [jsmith@host-1-81 ~]$ gzip misc.tar
[jsmith@host-1-81 ~]$ ls -ltr
total 4
drwxrwxr-x. 2 jsmith jsmith 6 Feb 1 04:46 tests
drwxrwxr-x. 2 jsmith jsmith 6 Feb 1 04:46 personal
drwxrwxr-x. 2 jsmith jsmith 6 Feb 1 04:46 code
drwxrwxr-x. 2 jsmith jsmith 54 Feb 1 04:55 misc
-rw-rw-r--. 1 jsmith jsmith 231 Feb 1 04:58 misc.tar.gz

i)  [jsmith@host-1-81 ~]$ mv misc.tar.gz /home/jsmith/tests/
[jsmith@host-1-81 ~]$ ls -ltrh /home/jsmith/tests/
total 4.0K
-rw-rw-r--. 1 jsmith jsmith 231 Feb 1 04:58 misc.tar.gz

j)  [jsmith@host-1-81 ~]$ cd tests/
[jsmith@host-1-81 tests]$ gunzip misc.tar.gz
[jsmith@host-1-81 tests]$ ls -ltr
total 12
-rw-rw-r--. 1 jsmith jsmith 10240 Feb 1 04:58 misc.tar
[jsmith@host-1-81 tests]$

k)  [jsmith@host-1-81 tests]$ tar -xvf misc.tar
misc/
misc/fileA
misc/fileB
misc/fileC
misc/fileD
[jsmith@host-1-81 tests]$ ls -ltr
total 12
drwxrwxr-x. 2 jsmith jsmith 54 Feb 1 04:55 misc
-rw-rw-r--. 1 jsmith jsmith 10240 Feb 1 04:58 misc.tar

l)  [jsmith@host-1-81 tests]$ cd misc/

m)

[jsmith@host-1-81 misc]$ ls -ltr
total 8
-rw-rw-r--. 1 jsmith jsmith 8 Feb 1 04:49 fileA
-rw-rw-r--. 1 jsmith jsmith 0 Feb 1 04:54 fileB
-rw-rw-r--. 1 jsmith jsmith 8 Feb 1 04:55 fileC
-rw-rw-r--. 1 jsmith jsmith 0 Feb 1 04:55 fileD

n)  [jsmith@host-1-81 misc]$ cd ../../

o) [jsmith@host-1-81 ~]$ pwd
/home/jsmith

p)  [jsmith@host-1-81 misc]$ ln fileA fileB

q)  [jsmith@host-1-81 misc]$ ln -s fileC fileE
[jsmith@host-1-81 misc]$ ls -ltr
total 12
-rw-rw-r--. 2 jsmith jsmith 8 Feb 1 04:49 fileB
-rw-rw-r--. 2 jsmith jsmith 8 Feb 1 04:49 fileA
-rw-rw-r--. 1 jsmith jsmith 8 Feb 1 04:55 fileC
-rw-rw-r--. 1 jsmith jsmith 0 Feb 1 04:55 fileD
lrwxrwxrwx. 1 jsmith jsmith 5 Feb 1 05:15 fileE -> fileC

r)  [jsmith@host-1-81 misc]$ ls -ltr
total 12
-rw-rw-r--. 2 jsmith jsmith 8 Feb 1 04:49 fileB
-rw-rw-r--. 2 jsmith jsmith 8 Feb 1 04:49 fileA
-rw-rw-r--. 1 jsmith jsmith 8 Feb 1 04:55 fileC
-rw-rw-r--. 1 jsmith jsmith 0 Feb 1 04:55 fileD
lrwxrwxrwx. 1 jsmith jsmith 5 Feb 1 05:15 fileE -> fileC

s)  [jsmith@host-1-81 misc]$ ls -l fileD
-rw-rw-r--. 1 jsmith jsmith 0 Feb 1 04:55 fileD
[jsmith@host-1-81 misc]$ chmod 666 fileD
[jsmith@host-1-81 misc]$ ls -l fileD
-rw-rw-rw-. 1 jsmith jsmith 0 Feb 1 04:55 fileD

t)  [jsmith@host-1-81 tests]$ chmod -R 744 misc
[jsmith@host-1-81 tests]$ cd misc/
[jsmith@host-1-81 misc]$ ls -ltr
total 12
-rwxr--r--. 2 jsmith jsmith 8 Feb 1 04:49 fileB
-rwxr--r--. 2 jsmith jsmith 8 Feb 1 04:49 fileA
-rwxr--r--. 1 jsmith jsmith 8 Feb 1 04:55 fileC
-rwxr--r--. 1 jsmith jsmith 0 Feb 1 04:55 fileD
lrwxrwxrwx. 1 jsmith jsmith 5 Feb 1 05:15 fileE -> fileC

u)  [jsmith@host-1-81 misc]$ find / -name *zip* 2>/dev/null | grep "/usr/bin/"
/usr/bin/bzip2
/usr/bin/unzip
/usr/bin/zip
/usr/bin/bunzip2
/usr/bin/bzip2recover
/usr/bin/funzip
/usr/bin/unzipsfx
/usr/bin/zipgrep
/usr/bin/zipinfo
/usr/bin/zipcloak
/usr/bin/zipnote
/usr/bin/zipsplit
/usr/bin/mzip
/usr/bin/gunzip
/usr/bin/gzip
/usr/bin/gpg-zip
/usr/bin/zipdetails

v)  [jsmith@host-1-81 misc]$ tar --help

w)  [jsmith@host-1-81 misc]$ diff fileA fileC

x)  [jsmith@host-1-81 misc]$ grep "Hello" fileA
Hello A

y)  [jsmith@host-1-81 misc]$ cat fileA
Hello A