You are on page 1of 3

Lab 1: Using the command line

BE CAREFUL USING THE COMMAND LINE – IT MAKES IT VERY EASY TO DO


THINGS LIKE DELETE FILES OR DIRECTORIES, WHICH YOU MIGHT NOT WANT TO DO!

If you are familiar with using the command line, you will find this introduction very easy. Use your expertise
to help other students with their exercise, and then move quickly on to Section 3.

There are three sections to this task. Section 1 is for students on Windows machines only. Section 2 is for
students on Macs or Linux machines. Section 3 is for everyone.

Section 1 - Windows machines


Open the command prompt. You can find this by searching under the Windows Start menu.
1 At the prompt enter the command
time
This displays the current time. You could then reset the system time, however I recommend that
you do not do that, but simply press enter again to exit without changing.

2 Enter
cd
and record the response. This is the current working directory.

3 Enter the command


cd..
Enter the command
cd
again and record the response. You can see that the working directory has been changed. cd..
moves you up to the parent directory.

4 Change your working directory back to the original working directory by entering
cd <the path that you wrote down at step 2>
Use cd again to check that you are in the directory you expect.

5 Enter
dir
What does this command do?

6 Enter
tasklist
What does this command do?

7 Check that you are in a directory you can write to. You are going to create a new folder. Enter
mkdir LabOne
Enter
cd LabOne
to move to this new folder.

| Kaplan International Pathways | 1 | kaplanpathways.com


8 Next you are going to create and write to a file. Enter
echo this is the text I’m writing > testfile.txt
Open the file to see what you have created.

9 You can also write the output from other commands to file. Enter
systeminfo > SystemInfo.txt
What does this file contain?

10 To remove the files and folder we have created, enter


cd..
to return to your original working folder. Then enter
rmdir LabOne
and record the response you get.

11 The command line will not allow you to delete the folder if it contains files. Enter
rmdir LabOne /s
the /s switch tells it to remove the folder LabOne and everything inside it (including subfolders and
all files).

12 Enter
cls
to clear all your commands from the command line window.

13 Enter
doskey /history
you can see this returns a list of all the commands you have entered during this session – this might
be a useful command to use on first receiving a computer for evidence retrieval! Copy this text and
paste it into your notes.

14 Now upload your notes document.

Section 2 - Macs/Linux
Macs and Linux use slightly different commands to Windows.

Open the Terminal


1 At the prompt enter the command
date
This displays the current time and date.

2 Enter
pwd
and record the response. This is the current working directory. (pwd stands for ‘print working
directory’)

3 Enter the command


cd ..
Enter the command
pwd
again and record the response. You can see that the working directory has been changed. cd..
moves you up to the parent directory.

4 Change your working directory back to the original working directory by entering
cd <the path that you wrote down at step 2>
Use pwd again to check that you are in the directory you expect.

| Kaplan International Pathways | 2 | kaplanpathways.com


5 Enter
ls
What does this command do?

6 Enter
rc-status
What does this command do?

7 Check that you are in a directory you can write to. You are going to create a new folder. Enter
mkdir LabOne
Enter
cd LabOne
to move to this new folder.

8 Next you are going to create and write to a file. Enter


echo this is the text I’m writing > testfile.txt
Open the file to see what you have created.

9 You can also write the output from other commands to file. Enter
sudo lshw > SystemInfo.txt
What does this file contain?

10 To remove the files and folder we have created, enter


cd ..
to return to your original working folder. Then enter
rmdir LabOne
and record the response you get.

11 The command line will not allow you to delete the folder if it contains files. Enter
rmdir LabOne -r
the -r switch tells it to remove the folder LabOne and everything inside it (including subfolders and
all files).

12 Enter
clear
to clear all your commands from the command line window.

13 Enter
ls -al
and then
cat .bash history
you can see this returns a list of all the commands you have entered during this session – this might
be a useful command to use on first receiving a computer for evidence retrieval! Copy this text and
paste it into your notes.

14 Now upload your notes document.

Section 3 – For all systems


Explore ethical hacking and other roles in cyber security. Sign up for a free account at Try Hack Me - sign
up

Unless you have a lot of experience already, choose the Pre Security pathway.
Start with Intro to Offensive Security and try your hand at hacking into a bank.
Then try Intro to Defensive Security and see if you can keep an organisation safe from intrusion.

| Kaplan International Pathways | 3 | kaplanpathways.com

You might also like