Lab 3 CREATE .TXT FILES WITH TERMINAL
1. To view .bashrc file, we can use command line "cat .bashrc"
output :
- The # symbol is used to comment in the terminal.
- The "export" command is used to create a variable in environment variable.- The "alias" command is used to assign a long command line to a variable.
- The control statements are allowed in the terminal. Example like "if".
- If user wish to modify the .bashrc file , command line ". .bashrc" must used.
2. When we call out a file with blanks and special characters, we will get error like this :
* This show me trying to call out file 'blank file.txt', it prompt out no such file or directory.space file.txt
-To solve this error, we add "" to the command line and like this :
- if we use Tab to auto fill a file with space, it will ouput symbol \ for space.
press Tab :
special>.txt
- If we try to list special>.txt in terminal without "" or \ :
-dashstart.txt
- If we try to list -dash.txt in terminal we will get error but if we add ./ to it :
example :
*0 mean no error
- Then we test ping at phooey(which is unavailable) and we get '2' when using command "echo $?"
*2 is the error code of last command
4. We can save the output of a command in terminal into a file by using ">" :
*The output of ifconfig is saved to file1.txt and used cat to display content of file1.txt.-we can also use different direction "<" to input text file to the terminal command :
example: write content of file1.txt to sort in terminal
-we can use two direction "<" and ">" to insert file to use in terminal and save the output to another file :
-we can also send the output to another command using the pipe operator in the terminal.
Example : Display only lines from route that only have eth0 using pipe operator
5. We can send the output of a terminal to another terminal. By using "tty" to determine the terminal current in and where to send, we can send to another terminal using "> /dev/pts/...".
Example : Sending output of route from a terminal to another terminal located at /dev/pts/1
Output:
6. We can use program Screen to do many action using shortcut keys :
-Press ctrl + A , then press C . Do this 3 times to open 3 new bash window
-Then press ctrl + A, then 3 , twice to show that bash window 3 is exist.
- END OF LAB 3 -
Comments
Post a Comment