Need some Help with my Linux Operation Systems please 1Navig
Need some Help with my Linux Operation Systems please
1.Navigate to your home directory (~). From here which commands would you use to create a directory called tarballs that contains a non-compressed tarball called pamd.tar that contains the contents of the /etc/pam.d?
2.Which commands would you use to create a new file called file1 in your home (~) directory and then add this file to the previously created pamd.tar tarball?
Which command can you use to ensure the file1 file is in the pamd.tar tarball?
3.Navigate back to your home directory(~) and delete file1. Now get a listing of the files in that directory. Make note of the files and directories that are there so you can compare them later.
Which command(s) would you use to extract the contents of the tarballs/pamd.tar tarball to your home directory?
Were any new files or directories created in your home directory (~) by this command, and if so, what are they?
If new files and/or directories were created in your home directory, which command could you use to list all the new files and/or directories/subdirectories that were created?
4.Navigate to the /home directory. From here what command would you use to create a compressed archive in your home (~) directory named tarball.bz2 that contains all the files from the ~/etc/pam.d directory and utilizes the bzip2 compression algorithm?
5.Navigate to your home directory. From here what command would you use to create a compressed file named touchfiles that can be read by Windows OS computers that contains all the files from the etc/pam.d directory?
Solution
1. # cd ~ [Go To home]
# tar cvf pamd.tar /etc/pam.d/ [create uncompressed tar at home]
2. touch file1 [create new empty file \"file1\" at home location]
# tar -rvf pamd.tar file1 [add file1 to tar]
# tar -tvf pamd.tar [list contents of tar to check file is added or not]
3. # cd ~
# rm -rf file1 [command to remove file]
# tar -tvf pamd.tar [list contents of tar to check file is added or not]
# tar -xvf pamd.tar [command to extract tar ball]
File content :
# ls -al
etc pamd.tar file1
# ls -al [command to list all files]
or you can use tree utility to list all subdirectories:
# tree
|-- etc
| `-- pam.d
| |-- accountsservice
| |-- chfn
| |-- chpasswd
| |-- chsh
| |-- common-account
| |-- common-auth
| |-- common-password
| |-- common-session
| |-- common-session-noninteractive
| |-- cron
| |-- cups-daemon
| |-- gnome-screensaver
| |-- lightdm
| |-- lightdm-autologin
| |-- lightdm-greeter
| |-- login
| |-- newusers
| |-- other
| |-- passwd
| |-- polkit-1
| |-- ppp
| |-- samba
| |-- sshd
| |-- su
| |-- sudo
| `-- unity
|-- pamd.tar
`-- file1
4. # tar cvfj tarball.bz2 /etc/pam.d/ [create bz2 archive by using \'j\' option in tar]
5. # zip -r testzip /etc/pam.d/ [use zip command in linux, this will create \"testzip.zip\" file which could be used to unzip in windows]

