0% found this document useful (0 votes)
12 views

CYB202_Lab4

The document outlines a series of lab projects focused on Linux filesystem management, covering tasks such as creating directories, copying files, organizing files, managing links, finding system files, removing files, setting permissions, and configuring filesystem attributes. Each project includes objectives, explanations, and results of commands executed, demonstrating successful completion of tasks along with encountered errors and their resolutions. The document serves as a comprehensive report on the student's practical experience in Linux administration.

Uploaded by

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

CYB202_Lab4

The document outlines a series of lab projects focused on Linux filesystem management, covering tasks such as creating directories, copying files, organizing files, managing links, finding system files, removing files, setting permissions, and configuring filesystem attributes. Each project includes objectives, explanations, and results of commands executed, demonstrating successful completion of tasks along with encountered errors and their resolutions. The document serves as a comprehensive report on the student's practical experience in Linux administration.

Uploaded by

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

Course: CYB202-Linux Administration

Lab 4: Linux Filesystem Management

Student Name: Mouli Jadapolu


Student ID: 23108093
Instructor Name: Ali Nadeem
Section: Cyber Security (Room no: 309)
Due Date: July 5th, 2024
Project 4-1
Objective: Create Directories
Explanation: I successfully logged in to the computer and created new
directories in this project.
4. The contents of the subdirectory listed are:
Sample1, sample1B, sample2, sample3. todelete/, undersamples/
5. The contents of the subdirectory mysamples are
undersamples/
6. todelete/ appears in the list, it confirms that the directory creation was
successful.
8. /home is my current directory.
9. No subdirectory created appears listed in the display.
Project 4-2
Objectives: Copy files and directories
Explanation: I successfully copied files and directories using the cp command
in this project.
3. The error message displayed on the screen is
Cp: missing destination file operand after ‘sample1’
Because the ‘cp’ command requires at least two arguments: the source file and
the destination. The error message indicates that the destination file operand is
missing.
4. Four files and their names are
sample1, sample1A, sample2, sample3
5. Four files and their names are
sample1, sample1A, sample2, sample3
6. Yes, sample1B was successfully copied.
7. Error
Cp: missing destination file operand after ‘/root/sample2’
8. Yes, sample1B was successfully copied.
9. Six files and their names are
sample1, sample1B, sample2, sample3, todelete/, undersamples/
10. I received an error message
cp: -r not specified: omitting directory ‘mysamples’
Without ‘-r’ option, ‘cp’ will not copy directories and will instead display an
error message indicating that the directory is being omitted.
11. Yes, all directories were successfully copied.
The contents of ‘mysamples’ are listed, indicating a successful copy.
Project 4-3
Objective: Organize files and directories.
Explanation: I successfully used the mv command to rename and move files
and directories in this project.
3. Error message displayed
mv: missing destination file operand after ‘sample1’
Because the ‘mv’ command requires two arguments: the source and the
destination. The error message indicates that the destination file operand is
missing. Without the destination, it cannot complete the command.
4. Four files and their names
Sample1 sample1B sample2 sample3
The original ‘sample1’ file has been renamed to ‘sample2’.
5. One file listed: ‘sample1A’
The ‘mv’ command moves ‘sample2’ into the ‘mysamples’ directory.
Therefore, ‘sample3’ no longer appears in the current directory but is inside
‘mysamples’.
7. Three files and their names
sample1, sample1B, sample3
‘sample2’ is no longer in the current directory because it was moved to the
parent directory (‘..’).
9. The command moves sample4 to the mysamples directory and renames it to
sample2.
12. Two files and their names
sample1A, sample1B
16. The mv command can handle directories by default, so no recursive option
is needed for renaming directories.
Project 4-4
Objective: Create hard and symbolic links.
Explanation: I successfully make and view links to files and directories.
2.ls -F command will display the files and directories in the ‘samples’ directory.
The link count for all files and directories in samples is ‘1’.
3. No, the output of ls -F does not indicate that ‘sample1’ and ‘hardlinksample’
are hardlinked. It will simply list the files and directories as shown in the below
screenshot.
Yes, the output of ls -l indicates that ‘sample1’ and ‘hardlinksample’ are hard-
linked by showing the same link count. The link count for both sample1 and
hardlinksample is ‘2’.
Yes, the two hard-linked files have the same inode number, both
‘hardlinksample’ and ‘sample1’ share the inode number 5201, indicating they
are hard-linked.
4. ‘3’ is the link count for the given files, indicating that there are three
references to the same file.
6. Yes, the contents of `sample1`, `hardlinksample`, and `hardlinksample2` are
the same because they are hard links pointing to the same inode, which means
they reference the same data on the disk.
7. ls -F output: Yes, the @ symbol indicates symlinksample is a symbolic link.
ls -l output: Yes, the arrow (->) indicates symlinksample is a symbolic link to
sample2.
ls -li output: No, sample2 and symlinksample do not have the same inode
number, confirming symlinksample is a symbolic link.

9. The size of `symlinksample` is smaller than `sample2` because it contains


only the reference ("sample2"), and the contents of `sample2` are displayed by
`cat sample2` command.
10. The `samba` link is indicated as a symbolic link to a directory, and upon
changing into `samba`, it reveals symbolic links to files from `/etc/samba`;
running `ls -F /etc/samba` lists its actual files and directories.
Project 4-5

Objective: Find system files


Explanation: I find files on the filesystem using the find, locate, which, type
and whereis commands.
2. Initially, the locate command will not find the newfile because the locate
database has not been updated yet.
3.After running updatedb, the locate command should find the newfile quickly.
The locate command uses a database to quickly find files.
4. The find command should find the newfile, but it may take some time
because it searches through the entire file system starting from the mouli
directory.

5. If newfile is not in the /home directory, the find command will not find it. The
time taken will depend on the size of the /home directory, but it should be
quicker than searching from the home directory.

6. If `newfile` is in `/home`, the `find` command will find it quickly due to the
smaller search scope.

7. The which command will find grep because it is a standard utility included in
the system PATH.

8. These commands may return more information than which, as they provide
additional context or locations for the command.

9. Lists files in /home whose names start with "sample".

10. Lists all symbolic links in the /home directory.

11. Lists all zero-size files on the entire system, displayed one screen at a time
for easier viewing.
Project 4-6
Objective: Remove files and directories
Explanation: I deleted files and directories using the rmdir and rm commands
successfully.
3. Both directories are empty, they will be deleted successfully; otherwise,
rmdir will fail because it can only remove empty directories.
4. The message will be along the lines of rm: remove regular file 'sample1' for
each file. Answering 'n' means the files will not be deleted.
5. I would not prompt because the -f option forces the removal. All three files
were deleted successfully. Another command that can be used to delete a file in
Linux is unlink.
6. The samples directory is not empty; I got an error message like rmdir: failed
to remove 'samples': Directory not empty.
7. The samples directory and all files within it are deleted successfully without
any prompts.

Project 4-7
Objective: Set access permissions
Explanation: I applied and modified access permissions on files and directories
and tested their effects successfully.
3. The output shows the file permissions. The first set of characters indicates the
read, write, and execute permissions for the owner, group, and others.
4. No one has read, written, or executed permissions on the file permsample.
The permissions will show as ----------.

5. Yes, I was able to delete the file permsample because the -f option forces the
removal regardless of the file's permissions.
6. The current directory is / and the directories under / are listed.
7. The owner and group owner of the foruser1 directory are displayed. If logged
in as home, I would be in the "user" category with the permissions listed for the
owner.
8. Initially, lists files in the /home directory, copies the hosts file from /etc to the
current directory, and then lists the contents again to confirm the hosts file is
present.
10. The success of cd /home depends on existence and permissions.
Successfully changed into /home
I didn’t get any error with rm -f hosts are due to the file is already existing or
permissions are not restricted.

12. Depending on permissions, changing write permissions for others on /home


succeeds.
13. After changing permissions and logging in as home, you can delete hosts
that exist in /home.
15. Copies hosts from /etc to /home.
17. Lists detailed file information; check owner and group owner of hosts.
19. I was successful in viewing the contents of hosts, assuming the file exists,
and I have read permissions.
23. I was successful in deleting the first line and saving changes because you
now have write permissions granted by chmod o+w hosts.

24. Check execute permission (x) on hosts; I make it executable because it is


intended to be run as a program or script.
Project 4-8
Objective: Set default permissions.
Explanation: I viewed and manipulated the default file and directory
permissions using the umask variable successfully.
2. 0022 is the default umask variable.
3. Creates utest1 file; permissions (rw-r--r--) are default, differing from umask
settings which affect default permissions.
Creates udir1 directory; permissions (rwxr-xr-x) are default, differing from
umask settings which affect default permissions.
5. Creates utest2 file; permissions (-rw-r--r--) are default, and may not agree
with umask settings in Figure 4-5.
Creates udir2 directory; permissions (drwxr-xr-x) are default, and may not agree
with umask settings in Figure 4-5.
Project 4-9
Objective: Set file and directory ownership
Explanation: I have successfully viewed and changed file and directory
ownership using the chown and chgrp commands.
3. Changes group ownership to sys for ownersample and ownerdir. Successful
because I have permission to change group ownership on these files.
4. Changes ownership to user mouli for ownersample and ownerdir. Successful
because I have permission to change ownership to mouli.
5. Successful despite not being the current owner due to having sufficient
privileges to change ownership to any user.

7. Changes ownership recursively to mouli for ownerdir and its contents;


successful because I have permission to change ownership.
8. Changes ownership recursively to mouli for ownerdir and its contents;
successful because I have permission to change ownership.
Project 4-10
Objective: Set special permissions and ACL entries
Explanation: I did this with the view, set special permissions on files and
directories, and modified the default ACL on a file.
2. Successfully creates specialfile; ownership and group ownership can be
determined by ls -l.
3. Sets the setuid special permission on specialfile. I executed by another user,
the effective user during execution would be the owner of specialfile.
4. Sets setuid (4) and setgid (2) special permissions. I executed by another user,
they execute as the owner and are a group member.
5. Removes execute permission. Special permissions like setuid and setgid
retain their meaning regardless of execute permission.
7. Sets the sticky bit (1) on public, allowing any user to add or remove files
from the directory, but only the owner of a file can delete their files within it.

16. Typically shows additional ACL entries beyond user, group, and other.
17. Yes, ‘+’ symbol following the mode, indicating extended ACLs.
Useful for providing specific users or groups with different access levels to a
file or directory, without altering standard Unix permissions.
18. No, there won't be a `+` symbol following the mode after running `setfacl -b
aclfile`.
Project 4-11
Objective: Set filesystem attributes
Explanation: I have successfully configured and researched filesystem
attributes.
2. Shows filesystem attributes set on toughfile by default, typically none (--------
-----).
3. Sets the immutable attribute (i) on toughfile.
4. The vi editor warns that the file is read-only due to the immutable attribute.
Changes cannot be saved using w!
5. Unable to delete toughfile due to the immutable attribute.
6. Removes the immutable attribute (i) from toughfile.

7. Setting the +c attribute on a file tells the Linux kernel to compress and
decompress the file transparently as it is written to and read from the filesystem,
helping to save disk space.

Setting the +s attribute ensures that when a file is deleted, its data blocks are
immediately overwritten, making it harder to recover deleted data using file
recovery tools.

You might also like