QUESTION 1: EDITING A FILE FROM THE COMMAND LINE: There are several command-line text editors available. The easiest to use is called 'pico'. For example: 1. Create and open file Apple.txt by typing [~/HW1] pico Apple.txt 2. You will see the open editor. You write 'ACGT'. 3. To save what you wrote, you hold the 'Control' key and press 'O' to save what you wrote. 4. You simply press 'Enter' to confirm 'Apple.txt' as the name of the file to save to. 5. To exit the editor, you hold the 'Control' key and press 'X'. There are several other editors available. ASSIGNING PERMISSIONS: The following command gives read/write permissions to you, the user (u=rw), and no rights to the 'group' (g=) or 'other' (o=): [~/HW1] chmod u=rw,g=,o= Apple.txt or, as separate commands, [~/HW1] chmod u=rw Apple.txt [~/HW1] chmod g= Apple.txt [~/HW1] chmod o= Apple.txt or, also valid, You can first add read/write permission for yourself (u+rw), then remove read permissions for the 'group' (g-r) and for 'other' (o-r) [~/HW1] chmod u+rw,g-r,o-r Apple.txt or, as separate commands, [~/HW1] chmod u+rw Apple.txt [~/HW1] chmod g-r Apple.txt [~/HW1] chmod o-r Apple.txt There are many other other valid ways of doing this. To give give only yourself read permissions on Banana.txt: [~/HW1] chmod u=r,g=,o= Banana.txt To give only yourself write permissions on Grape.txt: [~/HW1] chmod u=w,g=,o= Grape.txt To remove all permissions for yourself or others on Lemon.txt: [~/HW1] chmod u=,g=,o= Lemon.txt To give yourself execute permissions on Orange.txt [~/HW1] chmod u=x,g=,o= Orange.txt The output should look something like (the first part of each line, listing the permissions, is what matters): -rw------- 1 asayad bioinfo 10 Jan 21 2008 Apple.txt -r-------- 1 asayad bioinfo 12 Jan 21 2008 Banana.txt --w------- 1 asayad bioinfo 14 Jan 21 2008 Grape.txt ---------- 1 asayad bioinfo 16 Jan 21 2008 Lemon.txt ---x------ 1 asayad bioinfo 18 Jan 21 2008 Orange.txt QUESTION 2: a. You will be able to open 'Apple.txt' and 'Banana.txt' using a text editor. You will not be able to open the others. b. You will only be able to modify and save 'Apple.txt'. You will be able to overwrite the contents of 'Grape.txt', but you can't read and modify the file contents before doing so. c. You will be able to copy 'Apple.txt' and 'Banana.txt'. To see this, try the following, and see which of the commands below work: [~/HW1] cp Apple.txt Apple2.txt [~/HW1] cp Banana.txt Banana2.txt [~/HW1] cp Grape.txt Grape2.txt [~/HW1] cp Lemon.txt Lemon2.txt [~/HW1] cp Orange.txt Orange2.txt d. You can rename all the files. You see this by trying the commands below [~/HW1] mv Apple.txt Apple2.txt [~/HW1] mv Banana.txt Banana2.txt [~/HW1] mv Grape.txt Grape2.txt [~/HW1] mv Lemon.txt Lemon2.txt [~/HW1] mv Orange.txt Orange2.txt e. You can delete all 5 files. However, you will be asked for confirmation before deleting them. For the write-protected files (Banana.txt, Lemon.txt and Orange.txt), the confirmation message mentions that they are write-protected. QUESTION 3: "?" means "any single character" "*" means "any sequence of zero or more characters" What we're doing with the commands below is filtering the list of directory contents to see if anything matching our preferred pattern exists. [~/HW1] ls Apple.txt Banana.txt Grape.txt Lemon.txt Orange.txt [~/HW1] ls Apple.txt Banana.txt Grape.txt Lemon.txt Orange.txt [~/HW1] ls Apple.txt Apple.txt [~/HW1] ls Banana.txt Banana.txt [~/HW1] ls ?????.txt Apple.txt Grape.txt Lemon.txt [~/HW1] ls ??????.txt Banana.txt Orange.txt [~/HW1] ls ????e.txt Apple.txt Grape.txt [~/HW1] ls ????????? Apple.txt Grape.txt Lemon.txt [~/HW1] ls * Apple.txt Banana.txt Grape.txt Lemon.txt Orange.txt [~/HW1] ls *.txt Apple.txt Banana.txt Grape.txt Lemon.txt Orange.txt [~/HW1] ls *e.txt Apple.txt Grape.txt Orange.txt [~/HW1] ls *n.txt Lemon.txt [~/HW1] ls *z.txt ls: *z.txt: No such file or directory [~/HW1] ls A* Apple.txt [~/HW1] ls *a* Banana.txt Grape.txt Orange.txt [~/HW1] ls *e* Apple.txt Grape.txt Lemon.txt Orange.txt [~/HW1] ls *r*e* Grape.txt Orange.txt [~/HW1] ls *z* ls: *z*: No such file or directory QUESTION 4: '>' Redirects the result of the command to a file you name. If the file doesn't exist, it is created. If it exists, the command fails and the file is not changed. (Beware, however, that some linux systems are set to automatically replace the old file with the new one, rather than protecting the old file.) '>>' Redirects the result of the command to a file you name. If the file doesn't exist, it is created. If it exists, your command output is appended to the end of the file. [~/HW1] cat Apple.txt > Temp1.txt Puts the contents of 'Apple.txt' into a new file called 'Temp1.txt'. [~/HW1] cat Banana.txt > Temp2.txt Puts the contents of 'Banana.txt' into a new file called 'Temp2.txt'. [~/HW1] cat Apple.txt > Temp2.txt Tries to put the contents of 'Apple.txt' into 'Temp2.txt', but fails because the file already exits. [~/HW1] cat Banana.txt >> Temp2.txt Appends the contents of 'Banana.txt' to the contents of 'Temp2.txt'. [~/HW1] ls > Temp3.txt Puts the output of the directory listing into 'Temp3.txt'. [~/HW1] ls -l > Temp3.txt Tries to put a "long" listing of the directory into Temp3.txt, but fails because Temp3.txt already exists. [~/HW1] ls -l >> Temp3.txt Appends the output of 'ls -l' to the current contents of Temp3.txt. [~/HW1] cat Banana.txt >> Temp3.txt Appends the contents of 'Banana.txt' to the current contents of Temp3.txt. [~/HW1] cat Temp3.txt > Temp3.txt Fails to change anything, because Temp3.txt already exists. [~/HW1] cat Temp3.txt >> Temp3.txt cat: Temp3.txt: input file is output file (You can't append a file to itself. At least, not in just one command.)