Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

CTS3348 Linux Assignment 3 Summer 2017 Note that this file was saved as Unix ASC

ID: 3846875 • Letter: C

Question

CTS3348 Linux Assignment 3 Summer 2017 Note that this file was saved as Unix ASCII, which has different linefeed/carriage return than DOS. You can properly view it within Linux, or use Notepad++ which understands the difference between Unix formatted and DOS formatted text files. You should immediately save this document as ..3.txt. You should answer all of the questions for this assignment by typing the answers in the spaces provided below the question. You will start off with a 75 should you NOT follow these directions. Below are questions related to the command line use of Linux. You can use the videos, man pages, and notes to answer these questions. Note that I will know if you 'google' for your answers as students who do this will do well on the assignments, and poorly on exams. 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's only part of the command. I want the entire command sequence. **** All of these questions can be answered by viewing the videos, notes, and the man pages. You will do well if you have worked in Ubuntu and copied the commands I've run while watching the videos ********* I suggest you TRY each command to make sure it works before submitting your assignments. If you need to create some files so you can try some of these commands, use 'touch '. If you need to put some content in a file so you can search contents, you can use 'gedit' (the graphical text editor), or use what I use in class: echo "some text here" > name.of.file. UNLESS OTHERWISE SPECIFIED ASSUME YOUR CURRENT WORKING DIRECTORY IS ~. There are a maximum of 100 points. ------------------- 1. I have a file with the following permissions: ---x--x--x 1 john john ....... budget.docx I want to change the permissions so that the file can only be read and written to by the file's owner (john)and group (john). What command would make that change? Use OCTAL notation(5 points). 2. Use UGOA notation to change the following file's permission from this: -rwxrwxrwx 1 john john ....... budget.docx to this: -rw-rw--rw-- 1 john john ....... budget.docx (5 points) 3. User angus_young was just fired, and I need to remove his account from my server and remove his home directory, but I also want to create a backup of all files in angus_young's home directory and save that to my home directory. What SINGLE command would do this? (5 points) 4. Yikes! I just ran the following command: # sudo chmod 000 ./mydirectory Now I can't read the directory or cd into it! Show me a command that would allow the directory's owner to cd to the directory and list the contents for the owner of the directory ONLY! (5 points) 5. I run a server that currently has 50 users logged in. I am interested in finding out if user 'angus_young' has logged in, and if so, when he logged in. What command sequence would I use to show me the status for 'angus_young' ONLY -- no one else (Hint: one of the commands is grep) (5 points) 6. What command would I use to find out the office number for 'angus_young' (assuming the /etc/passwd file contains this information) (5 points) 7. I plugged in my USB thumbdrive in Linux and it doesn't appear to work. What command would I run to identify whether the kernel loaded a driver? (5 points) 8. What is /dev/sdc2? (I want a detailed explanation of EACH component) (5 points). 9. I want to manually mount a thumb drive (/dev/sdc2) that has an VFAT (DOS) file system. I created a directory called 'usb2' on which to mount it. Specify the command to manually mount the thumb drive on the directory '~/usb2'. (5 points) 10. I'm finished with the thumb drive from Question 9 above. Specify the command to unmount the drive. (5 points) 11. I think a program might be running that's using a network connection. What command would I use to display all ESTABLISHED TCP and UDP connections along with the name of the program which established the connection? 12. What command would I use to find all files under ~ that contain the whole word "Ford" at the end of a line? (5 points) (Hint: create a couple of text files that have "Ford" at the end of a line. Then try some commands to see if they work!) 13. What command would I use to find all regular files under my home directory whose file size is less than 4096 bytes, whose extension is .txt, and whose contents contains the whole word 'Ubuntu' (case insensitive). Make sure to print out the file's name that contains the keyword! (Hint: you will use grep as one of the commands) ()5 points) 14. I have /dev/sdc2 mounted on /home/pc/usb2. My present working directory is /home/pc/usb2 I type 'umount usb2' but I get an error message. Why? What can I do to alleviate the problem? I want both the reason and the soluton! (5 points) 15. I want to find out how much space my home directory and all subdirectories are currently using and I also want that output to be friendly meaning I want to see KB, MB, etc in place of bytes. (5 points) 16. I typed 'who' from the command line and saw the following: angus_young pts/3 2015-10-15 13:10 (mint17.local) What does all that mean? (Tell me what EACH column means! 5 points). 17. I have a file called "mybackup.tar.gz" which is owned by user loveyhowell. I want to change the owner of that file to user jonasgrumby. Write the command to do this. (5 points) 18. I want to create a new user shagar. I want his home directory to be /home/sammy, and I want his user ID to be 55. What single command would do this? (5 points) 19. Regarding question 18 above, I want to modify shagar so his shell is /bin/tcsh. What command would do this? (5 points) 20. I want to allow shagar to be able to use 'sudo.' Explain what you would do to allow this in Mint. (5 points)

Explanation / Answer

1. To change the permission of the file "budget.docs" the following command is used. As only the owner(John) and the group shoud contain the read and write permission, the command of

'-rw-rw--- ' which can be represnted in binary as 110 110 000 which is equivqlent to 660, therefore the command is,

chmod 660 budget.docs

2. using UGOA,

chmod u=rw g=rw o=rw budget.docs

u-owner g-group o-others not in the group

3. The following command can be used to create an archive of angus_young's directory and remove the same.

on successful creation of archive the directory is deleted from the server.

4. the 'sudo' keyword can be used to access as root/ super user. by using sudo and the corresponding password the file with permission mode 000 can be accessed.

sudo -i

password:

ls -l // to list files owned

5. To check if Angus Young is logged in the following command is used,

who | grep 'angus_young'

6. To identify the phone numbers with in the file the 'grep' command along with the regular expressions can be used. The regular expression for the phone number is "d{3}[s-]{0,1}d{3}[s-]{0,1}d{4}" which is of the format ***-***-****

grep 'd{3}[s-]{0,1}d{3}[s-]{0,1}d{4}' */etc/passwd.txt

7.by using the command 'lsmod' all the loaded drivers will be listed.

8. the format of naming the device drivers in Linux-> dev/sdc2 represents the second partition of the third drive. The more detailed explanation is as follows,

dev- contains all the device files.

sd- sd repreents the the removable devices and SATA devices

c- refers to the patition (a,b,c,...z,Aa,Ab....)