0% found this document useful (0 votes)
8 views3 pages

Peer Tutor P1 W3

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views3 pages

Peer Tutor P1 W3

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

Peer Tutor Exercise P1W3

Aim
Execute simple shell commands to practice relative and absolute paths.
Practice commands: rm , mkdir, rmdir, touch, cat , cp , mv, pwd, whoami
Get help using: man

Guidelines
- Use your ubuntu server environment to complete these tasks.
- Use "Tab competition" as much as possible
- Copy your commands or screenshots into this document.
- "Your user's home directory" is /home/yourusername
"The home directory" is /home.

Tasks

1. Your environment:
a. What is your present working directory when you log in? /home/jolonas
How can you find out? pwd

b. What is your username? jolonas


How can you find out? whoami

c. Are you root? Do you have privileged access? Are you an administrator? Ik
ben root, heb privileged acces en ben administrator
How can you see that? root: whoami, privileged acces en administrator:
groups

2. Working with relative and absolute paths:


a. How can you make the folder /tmp your present working directory?
What command did you use? cd /tmp
Did you use a relative path or an absolute path? absolute path
Move back to your home directory. Command? cd

If you used an absolute path, move back to "tmp" folder and use a relative
path. Command? cd tmp
If you used a relative path, move back to "tmp" folder and use an absolute
path. Command?

b. Move back to your user's home directory (~)


Create an empty file named "hello.txt" in your home directory using the
"touch" command

Copy the file to the /tmp folder using absolute paths. Command? cp ~/hello.txt
/tmp/
Which command can you use to check if the file was copied? (without using
the cd command)? ls /tmp/hello.txt

Copy the file to the /tmp folder using relative paths. Command? cp hello.txt
/tmp/
Which command can you use to check if the file was copied? (without using
the cd command)? ls /tmp/hello.txt

c. Create an empty file named "byebye.txt" in your home directory using the
"touch" command.
Move the file to the folder /tmp.

Which command do you use with absolute paths? cp ~/byebye.txt /tmp/


Which command do you use with relative paths? cp byebye.txt /tmp/
Which command do you use to delete the file? rm byebye.txt

d. Move to the folder /etc. Make it your present working directory.


Command? cd /etc

Use TAB completion to create the following commands.


Create a folder "PT_absolute" in your user's home directory using an absolute
path. Command? mkdir /home/jolonas/PT_absolute
Create a file "absolute.txt" inside the folder "PT_absolute" using an absolute
path. Command? touch /home/jolonas/PT_absolute/absolute.txt
How do you check if the file creation was successful? Command? ls
/home/jolonas/PT_absolute/

Create a folder "PT_relative" in your user's home directory using a relative


path. Command? mkdir ~/PT_relative
Create a file "relative.txt" inside the folder "PT_relative" using a relative path.
Command? touch ~/PT_relative/relative.txt
How do you check if the file creation was successful? Command? ls
~/PT_relative/

e. Assume your present working directory is /etc.


Give 3 different commands for moving back to your users home directory.
1 ? cd ~
2 ? cd /home/jolonas
3 ? cd ../../home/jolonas

3. How can you see the contents of the text file "syslog"
The file is located in the folder /var/log
Command? cat /var/log/syslog

4. Find more information on the following commands: cp, mkdir, ls


a. Which option do you use with cp when you want to make sure you don't want
to overwrite newer files. You only want to copy (overwrite) a file when the
version is newer, or the file doesn't exist yet.

cp -u

b. Which option do you use with mkdir so that "parent directories" are created
when needed.
In other words, which option do you need to create subfolders and their
parent folders at once.

mkdir -p

c. Which options do you use with ls to see file sizes in an easy to read way. By
default file sizes are listed in quantity of bytes, but for us it is easier to
understand file sizes with units, eg. 1.2M rather than 1171868 bytes

ls -h

You might also like