Class Test 1 Unix Software Tools

Total Page:16

File Type:pdf, Size:1020Kb

Class Test 1 Unix Software Tools

Class Test 1 Unix Software Tools

NAME:______STUDENT NUMBER:______

Write clearly. If you mean $ and write S, that is incorrect. If you mean dot (clearly put a dot). Assume you are on the university machines.

1. cd ../; cd .; cd /; cd ~; What directory are you currently in? ______

2. List all the files in the current directory with .txt extension? ______

3. What ‘files’ are always present in any directory? What are their names and what do they represent? How would you list all the files in a directory except these default files?______

4. In your home directory you usually have a number of hidden files associated with your shell (e.g. bash). For example the files

.bash_history .bash_logout .bashrc .bash_profile.

What command could you use to list only these files (i.e. files starting with a “dot bash”)?______

5. The above 4 files are “hidden”, indicated by the dot (these are also called “dot files”). Can we have hidden directories? ______

6. What command would you use to see what read/write/execute permissions a file has e.g. file.txt? ______

7. List as many ways as you can think of to get help on Unix/Linux?

______

8. Given a regular ascii file test.data, what does the command

cut –f1- test.data do? ______

9. What does the following achieve (i.e. what files will be created, what is their contents and which directory will you be in?). cd /; echo echo > echo.txt; cd;

10.You type alias alias=’’ and alias unalias=’’.(in both cases it is single quote and single quote, not a double quote) Will this cause a problem? Can you recover from this? ______

11.Explain the following. The command cat says that hello.txt does not exist, but when ls is executed, it says there is a file. Why is this?

$cat hello.txt

cat: hello.txt: No such file or directory $ls -l hello.txt

-rw-r--r-- 1 zlizjw1 Domain U 38 Feb 19 11:33 hello.txt

12. Issue chmod 742 file1.txt. What are the permissions after?

______

13. Issue chmod u+x file2.txt. What are the permissions after?

______

14. You have a java program (big.java) you want to run but it is “big” and will take a lot of processor time. If you run it with the command java big you may slow down the work of other people. How would you run the program to be kind or fair or polite to other people? ______

15. A process is running out of control. List all the command you could try to stop the program. List them in the order you would try them (i.e. the safest first, and the harshest last).

______

16. If we issue the command mkdir myDir then echo $? and get the value 0, what can we say happened? ______

17. echo hello > hello.txt ; echo bye.txt > hello.txt; echo bye >> hello.txt What files are created, and what it the final contents?

______

18. Which of the following are equal? ls –la; ls –l –a; ls –al; ls –a –l;

______

19. ls | uniq | wc and ls | wc should give the same output – why?

______

20.What command would you use to remove a file –file.txt (note “-“).

______

21.What permissions does a file normally receive? ______

Recommended publications