Question

In: Computer Science

the Unix/Linux commands Enter the “date” command to print the current date and time. Also, try...

the Unix/Linux commands

  1. Enter the “date” command to print the current date and time. Also, try the “cal” command.
  2. Enter the command “clear” to clear the screen.
  3. Use the command “cat .bash_hisrtory” to view your startup file. Note that each shell has a different startup file, and since we’re using the BASH (Bourne-Again Shell), the startup file is .bash_history. (if you can’t find this file think about one way to display!)
  4. Enter the “exit” command to close the terminal window.
  5. Enter the command “who” to display all users currently logged onto the system.
  6. Enter the commands “whoami” and “who am i” to display your own user information. Note the difference.

Whoami shows my username

  1. Enter the “finger” command with your login name to display detailed information about your terminal. (note: if you can’t find finger command, ask your instructor to install it)
  2. Change to the “/bin” directory.
  3. Display all files (ls –l) from the “/bin” directory.
  4. Change to your HOME directory.
  5. Use the “cat” command to create a sample text file called “textfile1”. Enter several lines of text of your choice into that file. The output redirection “>” should be used with the cat command “cat > textfile1”.
  6. Use the “cat” command to view the file you have just created. Then, use the “wc” command to display statistics information about that file (number of lines, words, and characters).
  7. The output redirection can be used with any command. Try the following command which prints all the files in the “/bin” directory into the file output:
  8. ls –la /bin > output

  1. Use the “cat” command to view the contents of the “output” file. How can you display the contents one page at a time?
  2. The output redirection “>” creates a file if it doesn’t exist, and over-writes its contents if the file exists. Try the following command which prints the lists of users into the “output” file we created earlier: who > output
  3. Use the “cat” command to display the contents of the “output” file. You’ll notice that the previous contents have been over-written.
  4. The output re-direction “>>” can be used to append contents to an existing file. Try this: “date >> output”. You’ll notice that the current date has been appended to the previous contents of the output file.
  5. The “touch” command can be used to create an empty file. Try this: “touch myfile”. Check to make sure the file “myfile” has been created.
  6. Try the “touch” command on an existing file “touch textfile1” or “touch output”. What is the effect?
  7. Create a new file called “memo.txt” with the following information “Hello there, my name is …yourname….”.
  8. Append the current date to the end of file “memo.txt”.
  9. Invoke the calendar command and redirect its output to the file “memo.txt”.
  10. Write a command to display statistics (lines, words, characters) about “memo.txt”.

Solutions

Expert Solution

  1. Try the “touch” command on an existing file “touch textfile1” or “touch output”. What is the effect?

when you run touch on an already existing file is that the file's access and modification timestamps are updated to the current time..

for more information on touch command, you can do "man touch".

2. echo “Hello there, my name is …yourname….” > memo.txt

above command will redirect the output of echo command to file having name memo.txt. if file already there, then content will be overwritten.

3. date >> memo.txt

this command will redirect the output of date command which is current date to file memo.txt. it will not overwrite, but at the end of the file it will append that output of date.

4. cal >> memo.txt

same as 3rd one, but redirects the output of calender command.

5. wc -lwc memo.txt

this will print statistics. l for line, w for word, c for character.

6. to display output of file pagewise... use following command...

cat output | more

Hope it helps. Feel free to comment your doubts.


Related Solutions

unix/Linux Create a tar command using the man command and the link referred to in To...
unix/Linux Create a tar command using the man command and the link referred to in To Practice and Explore: Text File Utilities #9. Preliminaries Use the man pages to learn more about tar Review the links referred to in To Practice and Explore: Text File Utilities #9 to see examples of using tar command Perform Use tar "to stuff" three files and then "unstuff" them into a new directory. Include the -v option. Task ll to show the original 3...
Unix / Linux 31. Given the first two commands, what is the expected output for the...
Unix / Linux 31. Given the first two commands, what is the expected output for the third command? (single quotes) $ echo * a b c $ x=* $ echo '$x' 32. Given the first two commands, what is the expected output for the third command? (Single quotes inside of double quotes) $ echo * a b c $ x=* $ echo "'$x'" 33. Given the first two commands, what is the expected output for the third command? (double quotes...
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...
Unix/Linux Turn in the following commands and any output from the commands. 1) ll to show the original 3 files
Unix/LinuxTurn in the following commands and any output from the commands.1) ll to show the original 3 files2) run the tar command to stuff three files3) ll to show the 'tar archive'4) mkdir newdir to create a new directory to unstuff the 'tar archive'
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
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...
linux Now use the date command and use redirection to APPEND today's date to the INSERTHERE...
linux Now use the date command and use redirection to APPEND today's date to the INSERTHERE file created (you want to append to the end of the file, not overwrite your name). What command did you use to do this?
QUESTION 1 Match the following LINUX/UNIX commands with what they do. du    whereis users who...
QUESTION 1 Match the following LINUX/UNIX commands with what they do. du    whereis users who am i A. display a compact list of users currently logged in B. locate the binary, source, and manual page files for a command C. summarize disk usage D. who am i currently logged in as on the Linux server. QUESTION 2 What rm command option (flag) would you use to remove a file that begins with a - (hyphen)? -f -p --   ...
Unix / Linux 21. Given the following command pipeline, provide a diagram (ascii art) or detailed...
Unix / Linux 21. Given the following command pipeline, provide a diagram (ascii art) or detailed description indicating all the Input/Output (I/O) connections. Every stdin, stdout, and stderr for each command will need to connect to something. grep a < words | wc -l > a_count.txt 22. Explain what is wrong (if anything) with the following command pipeline. cd | ls 23. Stream Editor: Write a sed command to delete digits, but only on lines that end with a period....
Unix / Linux 6. vi editor: In vi command mode, what are the keystrokes you would...
Unix / Linux 6. vi editor: In vi command mode, what are the keystrokes you would type to... Quit the vi editor and save any changes? 7. C language source files, by convention, have the suffix ".c". The associated "header" files have the suffix ".h". What is the command to perform the following task: List all the C source and C header files in the current directory. [Hidden files may remain hidden.] 8. C language source files, by convention, have...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT