LAB 4

  Name: Muhammad Danial Bin Zainal Azlan          Matric Number: 192020173


PART 1

1. Run the following command: cd /tmp



2.    Use dmesg to create a file, so we can search for some information about your system:
dmesg > dmesgl.txt 




3.   Let's see if we can determine what network device is beingn used. Run: grep network dmesgl.txt





There will be no output.

4.    Try the following command: grep -i network dmesgl.txt



5.    The -i tells grep to ignore case. You should now see which network driver your system is using. Now try the folllowing command : grep -i cdrom dmesgl.txt




6.    grep returns a code based on the result of the search. Run the above command again
: grep -i cdrom dmesgl.txt



7.    Now run the following command: echo$?



8.    Assuming the text was found, the return code will be 0. Now search for a string that should not be there: grep -i   jimlewis dmesgl.txt




9.    Run the following command: echo$?



PART 2 (USING ZIP)

Here we will be experimenting with the zip and unzip coommand:

1.    Run the following command: cd /tmp


2.    Let's make a temporary directory: mkdir lbooktemp




3.    Run the following command: cd lbooktemp



4.    Run the following command:





5. run the following command: Create more files.




6.    Let's package and compress the first one to a single file




7    Run the following command



8.    Unzip the file with this command:




9.    Run this following command ls



10.    See content in zip file without extracting anything by running this following command: 



PART 3

1.    We can use the same file as before.



2.    Run this following command tar cvzf lbook.tar.gz*.txt




3.    Run this following command file lbook.tar,gz



4.    Run this following command to view tar archive



5.    Run this following command



6.    Run this following command again



7.    Now let's tar the whole directory




8.    Run this following command again

        


PART 4

1.    Run the following command: cd /tmp



2.    Create a file: sudo dmesg > file1.txt





3.    Now run ls- la and remember the info. We will use this later.




4.    Use the stat command to see practically everything you would ever want to know about the file: stat file1.txt



5.    Now suppose you have sent that file to someone that is running a Linux system, and want to ensure it did not get corrupted along the way. Run the following command: sum file.txt


-    The first number is the checksum and the second is the number of blocks for that file. If the other person runs sum on his copy of the file and sees the same info, the files are the same.

6.    We have created a lot of files by using the redirection operator. You can also use the touch command: touch file2.txt




7.    Since file2.txt did not already exist, touch will create it as an empty file. in fact, let's prove that file file2.txt



8.    So what happens if we run touch on an existing file? Does it empty it? No, it updates the time and date on it. Run the following command: ls -la file1.txt



9.    Now run the following command: touch file1.txt



10.    Run ls  -la file1.txt again. You should notice it now shows the current date and time on that file. 



11.    Suppose you want to just view a text file. Run the following command: less file1.txt



12.    When using the less command, press the Space bar to scroll down. Press Ctrl+Z to exit.




13.    Say we want to see just the first few lines in that file:
head file1.txt



14.    The head command shows the first 10 lines by default. how about the last 10 lines? Run the following command:
tail file1.txt
































Post a Comment

0 Comments