CS代写 FIT2093 Week 2 Laboratory Sheet Solution Basic Linux File Management & Comm

FIT2093 Week 2 Laboratory Sheet Solution Basic Linux File Management & Commands
IMPORTANT NOTES:
1. Follow the instructions to install on your device the relevant software to allow you to log in and connect to your Virtual Machine on Monash Cloud server.
2. Study lecture materials at least 1 hour and prepare Question 1-4 under Lab Tasks section prior to the lab session. Prepared questions will be discussed in the lab session.

Copyright By PowCoder代写 加微信 powcoder

1 Overview
The objective of this lab is to introduce the students to the basic Unix commands. UNIX-like systems are increasingly being used on personal computers, mobile phones, web servers, and many other systems. This laboratory exercise reviews some of the essential commands and capabilities that match likely needs of FIT2093 students.
2 Lab Tasks: File and Directory manipulation
Root Directory and its Subdirectories. In this lab, we will use the Ubuntu 64-bit VM on Cloud. We will learn some basic Linux file and directory manipulation commands in the command terminal, so that we can use the com- mand terminal in future labs in this unit. A list of important unix commands is given in Table 1. For more details and examples for using these commands, refer to the Linux commands quick reference link on the week 2 Moodle lab material page.
Every file and directory in the file system has a path. Unix paths are delimited by forward slashes ( / ). e.g. A login name, Mark, has a directory as /srv/home/mark in the VM. After logging your VM, your directory follows the same pattern as /srv/home/[username], where [username] is your Monash authcate user name.
Figure 1: Unix file system hierarchy.
Special directories.
• Root Directory ( / ): The Top-Most directory.
• Bin Directory ( /bin ): Executable programs that comprise the GNU/Linux utilities. • Home Directory ( ~ ): Current User’s directory.
• Current Directory ( . ): The directory you’re in.
• Parent Directory ( .. ): The directory above.
Absolute paths: start with “/” i.e. the root directory. Relative paths: start from your current directory.

Week 2 Laboratory Sheet Solution
whatis
–help
> [filename]
cat [filename]
an interface to the on-line reference manuals display manual page descriptions
print a help message and exit
prints the last 50 commands
print lines matching a pattern
send the output of the command to that file concatenate files and print on the standard output make directories
remove empty directories
remove files or directories
copy files and directories
move or rename files and directories
search for files in a directory hierarchy
find files by name
print name of current/working directory
list directory contents
change working directory
The GNU version of the tar archiving utility
Table 1: File and Directory Manipulation Commands.
1. To poke around the Linux file system, open a Linux command terminal and take a look at the files in the root directory using the cd / command to change to the root directory, followed by the ls command to list the contents in the root directory. Experiment with variants of the ls command to see additional information, for example, what information does ls -l display, and what does ls -a display? (note: we will learn about the access control permissions of files in UNIX in a later lab). You should see directories with names like /bin, /home, /lib, and /usr.
ls -l displays a ‘long listing’ showing access rights for the files (to be discussed in a later lab) as well as time and date and size information. ls -a lists ‘hidden’ files (not shown on the basic ls command) whose name starts with a dot ( . ).
2. There is an archive file with the filename poems.tar.gz on the /srv/fit2093files/fit2093lab , which contains a collection of poems by different writers. Use the change directory command cd to change your current directory to that directory and copy the file poems.tar.gz from /srv/fit2093files/fit2093lab to /srv/home/[username]. Then, list its contents to verify that it contains the file poems.tar.gz. Then run the command tar -xzvf poems.tar.gz to extract the contents of this archive file to your home directory.
• To change to the desired directory, use the command cd ~ or cd /srv/home/[username].
• To copy the file from server to the desired folder, use the command
cp /srv/fit2093files/fit2093lab/poems.tar.gz ~
or cp /srv/fit2093files/fit2093lab/poems.tar.gz /srv/home/[username].
• To extract the file, type tar -xzvf poems.tar.gz, as stated in the task. The options are: x to extract, z for type gz or Gnu Zip, v for verbose, and f [filename] to specify the filename of the archive. Check this with man tar or tar –help.
3. Thearchivefileextractedintheprevioustaskshouldhavecreatedadirectorycalled/home/[username]/poems. Change your current directory to the latter. What command can you use to display the path of your current directory to verify that? Perform the operations in the following tasks from this poems directory.
To change to the poems directory, use cd /home/[username]/poems. To display the path of the current directory, use pwd.

FIT2093 Week 2 Laboratory Sheet Solution
4. Poems by both Angelou and Neruda are in the same directory. Create a separate directory for Neruda and move all his poems to the new directory. Rename the original directory as Angelou. (Hints: Auto-complete function: Try clicking “Tab” after keying first few characters of the folder name).
To create a new directory named Neruda issue the command mkdir Neruda while the current directory is /srv/home/[username]/poems, the file and directory names are case-sensitive. To move the files starting with Neruda issue mv “Angelou and Neruda “/Neruda* Neruda/ and to rename the folder issue mv “Angelou and Neruda /” Angelou. You can use the auto-complete (tab) feature of command line to enter the folder names for the above commands. Given there are spaces in the folder names if you are typing the complete name you must use double quotes.
5. There is only one poem by Blake. Move that poem to Others directory and delete the directory Blake.
To move all the files under Blake folder issue mv Blake/* Other/ and to remove Blake directory issue rmdir
Blake, if you get the error that directory is not empty issue ls -la Blake/, the output may look as follows:
drwxr-xr-x 2 [username] allposixstaff 4096 Feb 24 10:24 .
drwxr-xr-x 9 [username] allposixstaff 4096 Feb 24 10:23 ..
-rw-r–r– 1 [username] allposixstaff 213 Mar 25 2017 ‘._Blake – A Poison Tree.txt’
-rw-r–r– 1 [username] allposixstaff 120 Mar 1 2018 ._.DS_Store
-rw-r–r– 1 [username] allposixstaff 6148 Mar 1 2018 .DS_Store
To delete the files inside Blake folder issue (be careful with this command as it can wipe out the entire system if used incorrectly)
rm -rf Blake/.*
Now you should be able to remove the directory using rmdir Blake.
6. Create a text file called blank.txt using the gedit text editor and add some text to the file.
Use gedit blank.txt to run the editor and create and edit/add text to the file, then save it before quitting
from gedit.
7. Use cat command to display the contents of the file.
cat blank.txt
Further Exploration
1. The Linux command ln can create a symbolic (soft) link to a target file or folder, similar to the “shortcut” in Windows operating system. Learn how to use ln to create a symbolic link by using the proper options and try it by yourself in the VM.
Use ln -s [target] [link name] to create a symbolic link [link name] to the target [target].

程序代写 CS代考 加微信: powcoder QQ: 1823890830 Email: powcoder@163.com