LAB 4

PART 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 being used. Ru n: grep network dmesgl.txt



It will show nothing but that's okay

The output might not be very informative . But what if case is an issue? Try the following command: grep -i network dmesgl.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 dmesgl.txt


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





Now run the following command: echo$?


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


Run the following command: echo$?







PART 2 ( USING ZIP)



Here we will experiment with the zip and unzip command::



1. Run the following command: cd /tmp

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

3. Run the following command: cd lbooktemp
























PART 3: (USING TAR)




















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 file1.txt



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



9.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

10. Now run the following command:

touch fi1e1.txt

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

12. Say we want to see just the first few lines in that file:

head fi1e1.txt

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

tail file1.txt







Comments