Playground – Manipulating files and Directories in Linux

Playground – Manipulating files and Directories in Linux

This is a practice sheet for The following Video from Linux Command Line Journey Youtube Playlist. We would recommend you to watch the full video before doing this exercise.

1. Creating Directories

Click for answer
cd ~
mkdir playground
Click for answer
cd playground
mkdir dir1
mkdir dir2
Click for answer
mkdir -p ~/playground/dir1 ~/playground/dir2

2. Copying Files

Click for answer
cp /etc/passwd .
Click for answer
cp -v /etc/passwd .
Click for answer
cp -i /etc/passwd .

3. Moving and renaming files

Click for answer
mv passwd fun
Click for answer
mv fun dir1
Click for answer
mv dir1/fun dir2
Click for answer
mv dir2/fun .
Click for answer
mv fun dir1
Click for answer
mv dir1 dir2
ls -l dir2
ls -l dir2/dir1
Click for answer
mv dir2/dir1 .
mv dir1/fun .

4. Creating Hard Links

Click for answer
ln fun fun-hard
ln fun dir1/fun-hard
ln fun dir2/fun-hard

5. Creating Symbolic Links

Click for answer
ln -s fun fun-sym
ln -s ../fun dir1/fun-sym
ln -s ../fun dir2/fun-sym
Click for answer
ln -s dir1 dir1-sym

6. Removing Files and Directories

Click for answer
rm fun-hard
Click for answer
rm -i fun

Before:

After:

Click for answer
ls -l
Click for answer
rm fun-sym ./dir1/fun-sym ./dir2/fun-sym

e. Remove your “playground” directory. Remember, “playground” is a directory. How would you remove it ? Do you get the following error ?

Click for answer
cd
rm -r playground

All Done ! Congratulations.

Comments

No comments yet. Why don’t you start the discussion?

Leave a Reply

Your email address will not be published. Required fields are marked *