IMPORTANT NOTE:
**************************************************
1. PLEASE NOTE THAT THIS IS A GUIDE PREPARED FOR YOU TO LEARN SOMETHING IN LINUX.
2.PLEASE DO NOT COPY THIS PICTURES AND COPY IN YOUR LAB REPORT AS ANSWERS.IF YOU DONT UNDERSTAND ANYTHING YOU CAN DIRECTLY PM ME @ MY WHATSAPP LINK.THANK YOU AND GOOD LUCK.
3.YOU SHOULD LEARN LAB 2 COMMANDS BEFORE PROCEED INTO THIS.IF YOU HAVEN'T SIMPLY GO TO THE MENU ABOVE AND SEE THE LAB 2 GUIDE.
**************************************************
PART 1
1. To comment a line, precede it with a # symbol.
2. To create a variable, use the export tag.
3. To create an alias, use the alias tag (as shown earlier in this chapter).
4. Control statements are allowed; see the if clause in the previous screenshot.
5. After modifying your .bashrc file, remember to source it using the dot operator
as follows:
. .bashrc
**************************************************
ONLY KALI LINUX USERS: REFER THE VIDEO BELOWFor this part 1, we will add the export PS1="\h \u \w \$ " in the bashrc so that the changes made will be made permanent.
In previous lab,when we use export PS1="\h \u \w \$ " in the terminal it changes only temporarily in the terimal.When we close back and open the terimal the changes are gone.
So in this lab , we use .bashrc file to save the PS1 permanently and we also can remove it if we don't want.
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.
8.Now you can see when you remove the export PS1 , the PS1 is changed back to the default color and format.
VIDEO GUIDE FOR PART 1
**************************************************
PART 2
Before getting into this make sure create 3 dummy files as shown in the lab module.See the video below.
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
Press y or Y to confirm your installation
1.screen -list: It shows all of the windows
2. screen <program>: It creates a new window and run that program in it
(SKIP THIS PART-ITS A WRONG COMMAND)
**************************************************
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.
3. Do this two more times.(Press Ctrl+A and press C two times) -
Your screen will get cleared.NO OUTPUT IS SHOWN IS ON SCREEN.(You can refer the full video below for more info on it)
4. Try typing Ctrl + A + 0.
5. Try Ctrl + A + 3.
**************************************************
FULL VIDEO TUTORIAL FOR PART 7(SCREEN)
**************************************************
EXTRA
**************************************************
**************************************************
SUBSCRIBE TO ARVINDUNIMAP.BLOGSPOT FOR THE NEXT POST DIRECTLY DELIVERED TO EMAIL INBOX.
**************************************************
Comments
Post a Comment