week-1-lecture-exercise-solution
CHC4010 DevOps Week 1 – Lecture Exercises Using the Command Line
Task 2: Navigate the file system
Find out the current directory and open it in finder/file explorer. For Linux terminal, use the command
pwdto find out the location of the current directory. For Windows Powershell, the location of the current directory will be shown before the prompt. To open the current directory in finder/file explorer: Linux:open .Windows:start .Find out all the files and child directories (subfolders) in the current directory (including the hidden ones) and the time when they are last modified. Linux:
ls -aWindows:ls -HiddenGo into the child directory Documents.
cd DocumentsGo into the parent directory of your home directory.
cd ~/..Go to the root directory. Linux:
cd /Windows:cd C:\
Task 3: Navigate the file system
In your home directory, create a new folder called
dops.cd ~mkdir dopsIn the
dopsfolder, create a new filetest.txt.cd dopsLinux:touch test.txtWindows:ni test.txtWrite the content list of your home directory into
test.txt, followed by the sentence “This is my home directory”.ls .. > test.txtecho “This is my home directory” >> test.txtOpen
test.txtto check it has the correct content. Linux:open test.txtWindows:start test.txtIn
dopsfolder, make a new folderweek1.mkdir week1Copy
test.txtintoweek1folder and rename it tohome_dir.cp test.txt week1mv week1/test.txt week1/home_dir.txtDelete the test.txt file that’s directly under dops folder.
rm test.txtIn
dopsfolder, create 4 python files with whatever names you like.ni hello.pyni hello1.pyni hello2.pyni hello3.pyUsetouchinstead ofnifor Linux.Move these python files into
week1folder.mv *.py week1Delete all python files in week1 folder but leave
home_dir.txtintact, with only one line of command.rm week1/*.py
Last updated