Here are the steps you followed to create a symbolic link:
- First, determine if the
nmap
installation file is in your home directory. Use ls -l
to list all files and directories.
- You now know that the
nmap
application is in your home directory. Test the nmap
setup program by typing nmap -h
. This runs the Help file. Notice from the Help file that this is nmap
version 1.0.
- You now wish to allow users to access the
nmap
file. However, you do not wish to update multiple directories with the file constantly, and thus you want to create a symbolic link. To do this, first assert root privileges so you can create a folder for user2.
Solution: Type su
and enter the root password.
- Using a full pathname in the command (for example, /home/user2/), create a new directory named
nmap
in the user2 folder.
Solution: mkdir /home/user2/nmap
- Change the owner of this directory from root to user2, using a full pathname in the
chown
command.
Solution: chown user2 /home/user2/nmap
- Still working as root, change the group for the /home/user2/
nmap
directory so that it belongs to the user2 group.
Solution: chgrp user2 /home/user2/nmap
- You are still in the user1 directory. Create a symbolic link from the nmap file in your home directory to the /home/user2/nmap/nmap file.
For this step, use
$HOME
to refer to your home directory, and /home/user2/nmap when creating the symbolic link. Hint: Do not forget to specify the name of the symbolic link in the second part of your ln
command.
Solution: ln -s $HOME/nmap /home/user2/nmap/nmap
- Verify that the link now exists in the /home/user2/nmap directory by using
ls -l
and the full path.
Solution: ls -l /home/user2/nmap
- You are still in the /home/user1 directory. To prepare for the new nmap 2.0 program, delete the
nmap
file. Hint: Do not delete the link in
/home/user2/nmap.
Delete the actual file by using a full directory path.
Solution: rm /home/user1/nmap
- Confirm that you wish to delete the file.
Solution: y
- Verify that the /home/user2/nmap link still exists in the /home/user2/nmap directory using
ls -l
.
Solution: ls -l /home/user2/nmap
- You still have a symbolic link in the user2 directory, but as of now, it does not link to an existing file. This is because you have deleted the source
nmap
file. You are still in the user1 home directory. Using the mv
command, move the new nmap
file from the
/home/user1/setupfiles
home directory to the /home/user1 directory. For this step, enter the full directory pathname (for example, /home/user1/setupfiles/nmap).
Solution: mv /home/user1/setupfiles/nmap /home/user1/nmap
- Verify that you have moved the new
nmap
file to the /home/user1 home directory with ls -l
.
Solution: ls -l
- Using
ls-l
again, verify that the link in the /home/user2/nmap directory still exists. Hint: Use /home/user2/nmap in the command.
Solution: ls -l /home/user2/nmap
- The link in /home/user2/nmap is again valid, because you have placed a new file into the user1 directory. Creating symbolic links can help you save valuable time as a systems administrator, because it allows you to store files centrally, while still allowing users to access them.
Now, go to the /home/user2/nmap directory.
Solution: cd /home/user2/nmap
- Issue the
nmap -h
command.
Solution: nmap -h
- Notice that you are now using version 2.0 of the program. The
nmap -h
command works because you have created a symbolic link from the /home/user2/nmap subdirectory to the /home/user1 directory. You can keep replacing the nmap program with newer versions, and as long as the name of the program remains the same, all users will be able to access that program without any further administration on your part. Now, surrender root privileges.
Solution: exit