LAB 3

 Name: Muhammad Danial Bin Zainal Azlan          Matric Number: 192020173

 

Part 1


1.use sudo nano .bashrc to open .bashrc file


 

2.You can see the default aliases and if statement codings. You can create your own aliases if you want. In this lab ,we will just learn how to add the export PS1 command in the .bashrc.

So go to the last line coding .Below that add "export PS1="/h /u /w /$ " and save it.

3.To load the saved .bashrc file in the terminal type  " . .bashrc "  and press Enter.

 


 4. Now you can see the PS1 is changed.

 

 
5.To undo it, go the .bashrc file again .




6.And remove the export PS1="\h \u \w \$ "  and save it.

 


 7.Use . .bashrc to load again the .bashrc in the terminal.

 

PART 2

Before getting into this make sure create 3 dummy files as shown in the lab module.

 
 
1. Run "ls -la file with blanks.txt" and notice the errors.
 

2.    Now run it again, but enclose the filename in quotes: ls -la "file with       blanks.txt"; it will work properly now


3. Enter "ls -la file" and press Tab. It will escape the blanks for you.
 

4. Run ls -la special>.txt. Observe the error.


5. Enclose in quotes as before using the following command: ls -la "special>.txt"
 

 6. Now try ls -la -startswithdash.txt and then try quoting it. Doesn't work, right?
 
 
7. Precede the filename with the ./ operator using the following command: ls -la ./-startswithdash.txt

 

 
PART 3 

1. Run the following command: ping -c 1 packt.com


2. It should succeed. Run the following command: echo $?

3. You should get a 0 for success.




4. Now run the following command: ping -c 1 phooey




 5. Run echo $? again. It should return a non-zero value to indicate failure.
 

 

PART 4


For kali linux users: make sure you have created an empty file named file1.txt in home directory. 

1. Enter ifconfig > file1.txt. You won't see anything, because the output went into the file.


 
 2.      Run cat file1.txt. You should now see the output.
 

 3. This works the other direction as well, to read from a file run the following command:
sort < file1.txt
 

 4. You can even do both in one step: sort < file1.txt > output-file.txt
 
 

 

5. You can also send the output to another command using the pipe operator. For example, run route | grep eth0. The above command would display only the lines from route that contain the phrase eth0.
 
 

 
 PART 5( SENDING OUTPUT FROM ONE TERMINAL TO ANOTHER TERMINAL)
 
 

 

We show how to send the output from one terminal to another in the following steps:

1.      In one terminal run the tty command. The output should be something like /dev/ pts/0

2.      In the other terminal run the route command. You will see the output in that terminal.

3.      Now run route again, but now using the command:

route > /dev/pts/0

   4.    The output will go to that other terminal.

 
 PART 6 (SCREEN)

Before using the screen command you have to install the screen directory using the following command.

sudo apt-get install screen
 
 
 

 
 1.screen -list: It shows all of the windows
 
 

 
 PART 7

1. In a terminal run the screen -L command.
 
 
 
 

 
 
2. Now press Ctrl + A and then press C. This will create another window.

Note: Before typing it,type: screen bash command to activate screen commands.


 
 

 
 
 As you can see , the command will clear the screen and open another new window.


 
 **************************************************
 

Post a Comment

0 Comments