Question

In: Computer Science

PART 5: Learn about commands used to view contents of files: use the cat command to...

PART 5: Learn about commands used to view contents of files:

  1. use the cat command to review the contents of the /home/test/passwd.bak

type:   cat passwd.bak

2. now add the |more to the last command (see what happens when you push the up arrow curser key-it recalls the last command)

3. now try to cat the passwd.bak file but look at the first few lines and then the last few lines using the head and tail commands

type:  head passwd.bak   and    tail passwd.bak

4. let’s now add the n2 option to the head and tail commands and see what happens

5. let’s look more at the cat command and redirection of output to a file:

type:  cat > file1 and enter a paragraph about how you feel about Unix. Hit the ctrl and d to exit

6. create another file:  ls -ali > file50

7. add to that file:  cat /passwd.bak >> file50

8. review your work using the cat command

9. try to pull out any lines from the file50 with root:  grep root file50

10. HAND-IN: Screen Capture #4 of of the above activities

PART 6: Let’s practice utilizing files and directories in our file systems structure:

  1. create the following hierarchical directory structures:

      test

         |

              dir1         dir2        dir3          dir4

                                               |

                                      dir5      dir6

2. create some files in all of these directories using the cat or touch command

3. try a new command: move or mv. Use the mv command to move a file from one directory to another but notice that the inode number stays the same

4. use rm and rmdir to remove two files and dir4

5. HAND-IN: Screen Capture #5 of of the above activities

Solutions

Expert Solution

All the activities are shown in the form of screen shots. Please note i have created a file with the same name under the same path what is been mentioned in the problem statement ie. /home/test/passwd.bak.

Screen 1 : It shows only the command used to display the file /home/test/passwd.bak content

Screen 2: It shows when i open the file passwd.bak

Screen 3: As the entire file does not fit in a screen, we have to use more command to display the content of the file page wise. Hence we go for the following command :

cat /home/test/passwd.bak | more ( This command uses the pipe feature of the shell indicated as "|" , which takes the output of previous command as input and produces the results. You will see the keywor More at the end of the screen. )

Screen 4: When you view the file using the following command it displays the top 10 lines from the beginning of the file. (The head command, by default it displays top 10 lines if the number of lines option is not specified.)

head /home/test/passwd.bak

Note : The 10th line is a blank line. Ok.

Screen 5: Similarly, to display the bottom 10 lines of the file, we use the tail command. This command also prints 10 lines by default if we dont mention how many lines from the bottom is not specified. the command is as follows:

tail /home/test/passwd.bak

Screen 6: Now , lets see the change, by providing the number lines to be displayed from the begining with an option:

head -n 2 /home/test/passwd.bak

This command displays only the two lines from the begining of the file. Here the option -n is used to specify the number of lines from the begining.

Screen 7 : Lets see the same option with the tail command. To display the required number of ending lines of a file the command is :

tail -n 2 /home/test/passwd.bak

The above command displayed las two lines of the file.


Related Solutions

Research Managing Files via the Command Line Interface (CLI) commands, flags, and options that allow you...
Research Managing Files via the Command Line Interface (CLI) commands, flags, and options that allow you to: copy, delete, rename, and move files on Windows and Linux.
Two commands are received 5 microseconds apart. The execution time for the first command is independent...
Two commands are received 5 microseconds apart. The execution time for the first command is independent of the second and is exponentially distributed with a mean of 15 microseconds. The execution of the second command is exponentially distributed with a mean of 20 microseconds. What is the expected time from the start of execution of the first command to the completion of the second.
Use Workbench/Command Line to create the commands that will run the following queries/problem scenarios. Use MySQL...
Use Workbench/Command Line to create the commands that will run the following queries/problem scenarios. Use MySQL and the Colonial Adventure Tours database to complete the following exercises. 1. List the last name of each guide that does not live in Massachusetts (MA). 2. List the trip name of each trip that has the type Biking. 3. List the trip name of each trip that has the season Summer. 4. List the trip name of each trip that has the type...
Q3.  Networking commands – ping, mount, hosts, netstat The ping command can be used to check the...
Q3.  Networking commands – ping, mount, hosts, netstat The ping command can be used to check the network working condition between two systems.  You may have to find the path name of the ping command file using which or whereis command and then type the full/absolute path name of the ping command.  Issue ping command with UNIX server IP address as argument.  If the command does not stop after displaying five packets transfer and receive information, terminate the command using ctrl-c.  Otherwise, the command may...
Look up and use each of these Linux commands. (Each command will have two parts) Summarize...
Look up and use each of these Linux commands. (Each command will have two parts) Summarize their function then use the command Use the Command and document the output (<parameters of your choice> Command Function info cat Demonstrate 'cat' in use   man cp Demonstrate 'cp' in use   man touch Demonstrate 'touch' in use   man mv Demonstrate 'mv' in use   man rm Demonstrate 'rm' in use   info wc Demonstrate 'wc' in use   man find Demonstrate 'find' in use   man chmod Demonstrate...
4. Identify the tool is used with the netstat command to view a system's routing table?...
4. Identify the tool is used with the netstat command to view a system's routing table? Run the identified command and highlight the output of the command with an appropriate result and discussion.
Explore how to use various combinations of switches for the DIR command to find files/folders in...
Explore how to use various combinations of switches for the DIR command to find files/folders in C:\WINDOWS\SYSTEM32 directory. Objective: List each search line by line and give then the command used to discover the following and include a small sample of your discovery. (Example: How would you pause the display? DIR /P and give two files discovered) What switches would you use to find. Example of structure: #!/bin/bash # EOQ-111.sh maw 2/24/20XX # Archive class work and set all files...
Try the Linux commands listed below. Post your thoughts about how to use these commands. Discuss...
Try the Linux commands listed below. Post your thoughts about how to use these commands. Discuss options that you might use with them, compare and contrast them and/or ask questions about commands you are not sure about. mount and umount more and less head and tail grep kill / xkill / pkill / killall su and sudo man and whatis ping and traceroute
1. In terms of security, why would you not use rm command to delete files? 2....
1. In terms of security, why would you not use rm command to delete files? 2. Shred and dd are tools used to securely delete files. Which is the best tool for securely deleting a file from a system and why? Consider the limitations of each tool when choosing your answer. 3. What encryption is used to encrypt HTTP traffic (HTTPS)? 4. The CIA triad , confidentiality, integrity, and availability represent the three goals for cybersecurity. Which goal(s) does/do encryption...
Questions: Explain the following Linux commands Show your work examples/outcome. 1. command used to locate /Home/...
Questions: Explain the following Linux commands Show your work examples/outcome. 1. command used to locate /Home/ Directory…show the outcome 2. command used for October 2020 3. mv command and cat command 4. commands used- move to parent directory? 5. Explain why command is used ls -R?   What is the meaning of -R ? 6. Explain and describe two examples of how the touch command. 7. Explain what is the outcome of the commands ls -C ? 8. Explain command echo....
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT