In: Computer Science
Q1. Move the file “nfile2” into the “unix”
directory.
moving file into a directory we will use the mv command as
below
mv file_name path_of_directory
mv nfile2 unix/
Q2. Copy the file “nfile1” into the “java”
directory.
to copy file we will use th cp commond same as mv command the only
difference is we will use cp instead of mv
cp nfile1 java/
Q3. Show how you would create the files “test1”, “test2”,
& “test3” in the “test” directory to ensure that they have the
same file creation date/time.
We can do this in multiple ways.
Option 1.
go to the test directory using the command below :
cd test
After this execute touch command to create multiple files at a time as given below.
touch test1 test2 test3
Option 2
Specify the file while creating a new file using touch.
syntax: touch dir_path/file_name
command: touch test/test1 test/test2 test/test3
in the above command, we are creating test1, test2, test3 files in the test directory.
Q4. From the ~ folder, use the * and then the [ ] wildcard
procedures to list all the files in the “test”
directory.
we are firest going on directory using command change directory
cd
after that listing all files in tat directory using command ls
[a-z]* in bracket we are specify the range a-z
cd test
ls [a-z]*
Q5. From the directory structure above, give an example of
a relative path & an absolute path.
absolute path is that which specify the location from root (/)
path
for example suppose test directory is on Desktop then it's relative
path will
/home/abhi/Desktop/test
In the above path abhi is user. so in
your case it might be anything.
relative path is a path from present working directory. suppose if
we are on desktop the relative path will
Desktop/test
Q6. Use the ‘zip’ utility to compress the
‘labs.tar’ file to get the archive file labs.zip. Show how you can
uncompress the zip file that was created.
zip command is used to copress and unzip command is used to
uncompress.
zip labs.zip labs.tar
unzip labs.zip
Q7. Use the gzip utility to compress the archive
file labs.tar to get the file labs.tar.gz. Show two(2) ways that
you can retrieve the original contents from the labs.tar.gz
file.
gzip command creates the compress file and delete the original
file.
command to compress:
gzip labs.tar
Uncompress using gzip:
Way1:
gzip -d labs.tar.gz
Way2:
tar xvzf file.tar.gz