Question

In: Computer Science

Linux Fundamentals part 3 Below are questions related to the command line use of Linux. You...

Linux Fundamentals part 3

Below are questions related to the command line use of Linux.  You can use the videos, man pages, and notes to answer these questions. 

Remember that Linux is CASE SENSITIVE.  Rm and rm are NOT the same command.  I will count off totally for a question if you do not take this into account.

For each command give me the ENTIRE COMMAND SEQUENCE.  If I ask you  'What command would I use to move the file one.txt to the parent directory and rename it to two.txt?", the answer is NOT 'mv'. That is only part of the command. I want the entire command sequence.

10. Find all files under the current directory with an accessed time was more than 2 days ago.


11. I have a file called 'BackupLogs.tar.bz2' in my home directory (because you made it from Questions 4 and 8, right? Right!). I want to uncompress and unarchive the files in it. What single command would I use?


12. I have a file called BackupLogs.tar.bz2 and I want to uncompress and ONLY uncompress the file (NOT uncompress and unarchive). What command would I use?


13. I want to search for all files in the directory ~/Documents which contain the keyword "add", case sensitive, and as the whole word only. Words like addendum, addition, etc, should not be found in the results; just 'add'. Additionally, I only want to see the name(s) of the file(s) that have matches as a result of running the command. This means your result should show not the keyword hit AND surrounding text, but rather suppress that output and instead display just the file name. What command would I use? This may sound complicated, but break down each step and use the man page.


14. I have a large file named walloftext.txt and I want to view only the first 5 lines of the file. What command would I use?


15. Same as file as Question 14, but I want to view only the last 7 lines.

Solutions

Expert Solution

Q 10.

find -iname "*" -mtime +2 -print [For all files]

find -iname "*.txt" -mtime +2 -print [for txt file] you can add any extension

-mtime +2   looking for a file modified 2 days ago.

-mtime -2 less than 2 days.

-mtime 2   exactly 2 days.

Q.11

tar -cvzf BackupLogs.tar.bz2 BackupLogs [ compress and archive in single command]

tar -xvzf BackupLogs.tar.bz2 [if you zip with sudo then sudo use for uncompress and unarchivealso)

-x: Extract.

-v: Verbose

-j: Bzip2

-f: File

Q12

ONLY uncompress the file

bunzip2 BackupLogs.tar.bz2 [output will be BackupLogs.tar]

Q13

grep -w "add" *

-w for whole words only and * for find from all files from Documents

Q14

head -5 walloftext.txt [ -5 for first 5 lines]

also you can see last 5 lines use only tail insted of head

Q15

tail -7 walloftext.txt [you will get last 7 lines]

---------------------------------------------

hope this will help you .


Related Solutions

Linux Fundamentals part 4 final Below are questions related to the command line use of Linux....
Linux Fundamentals part 4 final Below are questions related to the command line use of Linux. You can use the videos, man pages, and notes to answer these questions. Remember that Linux is CASE SENSITIVE. Rm and rm are NOT the same command. I will count off totally for a question if you do not take this into account. For each command give me the ENTIRE COMMAND SEQUENCE. If I ask you 'What command would I use to move the...
LINUX In Linux command line write a shell script ex1.sh that uses IF THEN to Prompt...
LINUX In Linux command line write a shell script ex1.sh that uses IF THEN to Prompt the user to "Enter a number between 1 and 10". (Hint: Use the 'echo' and 'read' commands in the script. See the slide about the 'read' command) If the number is less than 5, print "The number is less than 5" (Hint: You will read input into a variable; e.g. read NUM. In the IF statement, enclose $NUM in quotes; e.g. "$NUM". Also, remember...
Introduction Write in C++ at the Linux command line a program that is the same as...
Introduction Write in C++ at the Linux command line a program that is the same as the previous collection app project but now uses a class to store the items and also can save the items to a file that can be read back into the array by the user when the program is re-started. You can use your project 1 submission as a starting point or you can do something new as long as it meets the listed requirements....
Linux 1. Give a command line (one command) for displaying the files lab1, lab2, lab3, and...
Linux 1. Give a command line (one command) for displaying the files lab1, lab2, lab3, and lab4. Can you give another command lines that do the same thing by making use of the file name similarities? What is the command line for displaying the files lab1.c, lab2.c, lab3.c, and lab4.c? (Hint: use shell metacharacters.) 2. How to determine the number of users who are logged on to Linux server system at this time? What command did you use to discover...
Ubuntu Linux HW2: 1. Give one line of the Linux command to see your (your login...
Ubuntu Linux HW2: 1. Give one line of the Linux command to see your (your login ID) credential data from the passwd file. Use a pipe and grep command. 2. Give one line of the Linux command to calculate the following and save it in the hex to a file calcOut. Use bc and <<<. 3+2*4 Submit Screenshots HW3: Permission Show the result clearly after each of the following commands are executed. 1. Create a subdirectory, “HW3”. Write the Linux...
linux: Become the root user for this exercise. What command did you use to do this...
linux: Become the root user for this exercise. What command did you use to do this again? $ Now that you are root, create a new user on your system called labsevenuser. What is the command you used to create this user? # Set a new password for the new user you just created in step 2 above. What is the command you used to do this? # Create a new group called awesomepeople. Add the user you created in...
linux: Become the root user for this exercise. What command did you use to do this...
linux: Become the root user for this exercise. What command did you use to do this again? $ Now that you are root, create a new user on your system called labsevenuser. What is the command you used to create this user? # Set a new password for the new user you just created in step 2 above. What is the command you used to do this? # Create a new group called awesomepeople. Add the user you created in...
linux use the command dmesg, use grep to filter and then redirect just the lines with...
linux use the command dmesg, use grep to filter and then redirect just the lines with the word Linux in them from the output generated by the dmesg command. redirect this output to a file at the path PutFileHere/Dmesgoutput.txt. What command did you use to do this, if there is no output choose a different word to grep for in the output of this command and substitute that word.
Using Linux in VirtualBox To display your system date: Type date in the command line, and...
Using Linux in VirtualBox To display your system date: Type date in the command line, and press Enter. What do you see?                                            You might see the abbreviation EDT (Eastern Daylight Time) instead of EST (Eastern Standard Time), or another time zone abbreviation, such as MDT (Mountain Daylight Time) or CST (Central Standard Time). Notice also that UNIX/Linux uses a 24-hour clock. Type Date in the command line, and press Enter. What error do you see?                                    The system error...
please use linux or unix to complete Diff command The diff command displays differences between two...
please use linux or unix to complete Diff command The diff command displays differences between two files on a line-by-line basis. It displays the differences as instructions that you can use to edit one of the files ( using the vi editor) to make it the same as the other. When you use diff, it produces a series of lines containing Append (a), Delete (d), and Change (c) instructions. Each of these lines is followed by the lines from the...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT