LAB 4

 LAB 4 : OPERATING SYSTEM




Run the following command : cd /tmp
After that use dmesg to create file : dmesg > dmesg1.txt
If fail use this command sudo dmesg > dmesg1.txt





we can see the file we create using that command





Run command : grep network dmesg1.txt to determine what network device is been used. The results will show nothing because the output may not be very informative.
But what if case is an issue? We can try the following command : grep -i network dmesg1.txt





The -i tells grep to ignore case. You should now see which network driver your system is using






Now try the following command : grep -i cdrom dmesg1.txt 
grep returns a code based on results of the search. Run the above command again (remember the up arrow shortcut)





Now run the following command : echo $?






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



Run the following command again : echo $? The return code should not be 0.



Part 2


Run the following command : cd /tmp  and make temporary directory : mkdir lbooktemp




Run the following command : cd lbooktemp




To create some files : ls > f1.txt; route > f2.txt; sudo dmesg > f3.txt 





Then,create some more files: ifconfig.dat; dmesg > dmesg.dat




Let`s package and compress the first ones into a single file using this command :
 zip lbook1.zip*.txt*.dat

                                                 



Unzip the file with this  following command :





The unzip program is used to extract files out of a zipped file (also called an archive). Make another directory using this command: mkdir test  and run the following command. Now unzip the file using this command : unzip lbook1.zip



We can view the contents of a zip file without extracting anything by running the following command: unzip -1 lbook1.zip



Part3



Run the following command: cd/tmp





Create a file: sudo dmesg >file1.txt and run ls -la command , remember the info because we will use it later.




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




Now suppose we 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 fllowing command: sum file1.txt 


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





 We have created alot a files by using the redirection operator. We can also use the touch command: touch file2.txt. However,since file2.txt did not exist, touch will create as an empty file. 

Let run the command : file file2.txt to prove it



So if we touch on existing file what will happen? It will update the time and data on it 
Try run this command : ls -la file1.txt





Now run the following command : touch file1.txt and run ls -la file1.txt. We should notice it shows the current date and time on i


Then run the following command : less file1.txt
  • When using the less command press the space bar to scroll down. Press Ctrl+Z to exit
Says we want to see just the first few lines in that lines : head file1.txt





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




Comments