Module 4 Linux Filesystem Management

Réussis tes devoirs et examens dès maintenant avec Quizwiz!

What does mkdir do

Creates new directories

Three regular permissions may be assigned to each user

Read, write, execute

File and Directory Permission

Recall that all users must log in with a username and password to gain access to a Linux system. users identified by username and group memberships must have required permissions and access to these resources depends on username and group memberships

ln (link) command

The command used to create hard and symbolic links.

Directories have a different data block?

Their data blocks contain a list of filenames that are located within the directory.

How to copy directories and subdirectories

To copy a directory full of files which include the subdirectories and file, you must tell the cp command the copy will be recursive cp -r

updatedb

Update data base. new files can be searched for.

How to we exclude directories from being indexed with the updatedb command?

We can add them to the /etc/updatedb.conf file. This is also called (pruning).

cp command

copies files, has the same arguments as the mv command and used to make copies of files.

Other permissions:

everyone on system

What are the three standard Linux permissions?

execute, read, write

To view your group memberships and primary group

groups

Mode:

inode section that stores permissions

To view the inode number of hard-linked files to verify they are indentical use

ls -li

How do you create a symbolic link? How do you view the linked filenames?

ls -s file3 file4 ls -l

chmod syntax

u (user) , g(group), o (other), a (all categories) + (adds a permission) - (removes a permission) = (Makes a permission equal to) r (read) w(write)

Interpreting the Mode (2of2)

user or owner: refers to users with read, write, and execute permission Other: refers to all users on system Permissions are not additive * The system assigns the first set of permissions that are matched in the mode order: user, group, other Linux permission should not be assigned to other only

How to search the directories in the PATH variable for grep?

which grep

How do you override the interactive mode

-f option (force)

The command chmod 317 file1 would produce which of the following lines in the ls command?

-wx --xrwx 1 user1 root 0 Apr 29 15:40 file 1

What is a target in linux?

A file that exists.

Absolute vs relative pathing

Absolute means the the full file/directory path, relative means you are currently in the directory and you only have to move up or down a relative path to your file.

Data blocks

Data making up contents of a file, referenced by the inode.

Read

Definition for files Allows user to open and read the contents of a file, allows a user to list the contents of the directory if the user has been given execute permission.

How do you remove hard links?

Delete one of the linked files, which reduces the link count for the file.

type command

Displays the first result normally outputted by the which command

What the rmdir command do?

Removes directories, only if it has not files.

What the the rm command do?

Removes files Arguments are a list of files, can use wildcards, interactive mode by default. * Use -f option to override.

When you change the data in a file that is hard-linked to three others, ___.

The data in the file you modified as well as the data in all hard-linked files are modified because they share the same data and all have the same inode and file size.

Why are symbolic links easier to identify?

The filename points to a target using a arrow, using the ls -F also indicates symbolic links by appending an @ symbol.

How to see the link count?

The link count is set between the permissions and the user

What prompts will mv and cp give the user?

The mv and the cp warns the user that the target file will be overwritten and will ask to continue.

After typing the command umask 731, the permissions on all subsequently created files and directories will be affected. In this case, what will be the permissions on all new files?

c. ---r--rw- umask 731 0: No permissions are removed. 1: The execute bit is unset in the permissions. 2: The write bit is unset in the permissions. 4: The read bit is unset in the permissions. umasked read,write,execute for user umasked write and execute for group umasked execute for others

When applied to a directory, the SGID special permission ___.

causes all new files created in the directory to have the same group membership as the directory, and not the entity that created them

chmod -R 755 Desktop

drwx r-x r-x

See the contents of a certain variable in memory by using the $ metacharacter with the echo command

echo $PATH

Locate command

searches for files in the Linux directory tree. Looks in a premade indexed database of all files on system.

You can hard-link a file an unlimited number of times, however, the hard-linked files must reside on ____

the same filesystem

Given the following output from the ls command, how many files are linked with file1?

two

How to see aliases present in current shell?

type alias in the prompt

Execute

Allows a user to execute the file in memory (allows a user to enter the directory and work with directory contents. Avoid giving execute permission to files that are not programs or shell scripts.

Write

Allows a user to open, read, and edit the contents of a file, and also allows the user to add or remove files to and from the directory.

Chgrp

Change group owner of a file or directory Same argument, two arguments at minimum: the new group owner and the files or directories to change. chown user1.root file1 chown -R user1.root Desktop changes group owner the file1 to root, and Desktop recursively to root as well. This can also change the owner to user1 chown -R user1:root Desktop can also be used instead of .

chmod u+w,g+r-w,o+r-x file1

Change the mode of file 1 to rw-r--r--, add the write permission to the user of the file, add the read permission and take away the write permission for the group of the file, add the read permission and take away the execute the permission for other. -rw-r--r--

Chmod (change mode command)

Changes mode (permissions) of files or directories Takes two arguments at minimum, criteria used to change permissions and filenames to change If the permissions to be changed are identical for the user, group and other categories you can use the "a" character to refer to all categories.

chown

Changes ownership of a file or directory Two arguments New owner File or directory to change -R change recursively throughout the directory tree, sub directories within the directories. ex. chown root file1 chown -R root Desktop (Change the ownership of the directory Desktop to root)

Other uses of symbolic links

Commonly made to directories to simplify navigating the filesystem tree, and symbolic links made to directories are typically used to maintain compatibility with other UNIX and Linux systems. (ex. Fedora 28, the /usr/tmp directory is symbolically linked to the /var/tmp directory for this reason)

Inode table

Consists of several inodes Each describes a file or directory and contains a unique inode number for indentification The inode stores file size, data block locations, last date modified, permissions, and ownership.

whereis command

Displays the location of the command as well as any associated man and info pages.

What was created to define a standard directory structure and common file location for Linux?

FHS

A symbolic link is also known as a soft link and is depicted by an @ symbol appearing at the beginning of the filename when viewed using the ls -l command. True or False?

False

Only the root user can modify a file that has the immutable attribute set. True or False?

False

There is no real difference between the "S" and "s" special permissions when displayed using the ls -l command. One just means it is on a file, and the other means that it is on a directory. True or False?

False

find /boot -type d

Find all directories under /boot directory.

find /var -size +4096k

Find all files starting from the /var directory that have a size greater than 4096k(kilobytes)

Group permissions:

Group owner

Are pathnames absolute or relative?

It can be either, it can absolute or relative, for multiple files, you can use wildcards in pathnames

What does the mv command do? (Choose all that apply.)

It moves a directory, It moves a file

Why would we want to narrow the directories searched by specifying a subdirectory when possible?

It takes less time to search the /usr/local/bin directory and it's subdirectories when possible, compared to searching the /usr directory.

What must a user do to run cp or mv interactively and be asked whether to overwrite an existing file?

Just type cp or mv because they run in interactive mode by default.

What does mv (move) command do?

Moves files, minimum of two arguments source file/directory and target file directory Uses to rename files.

Pruning

Process of excluding files, directories, or filesystems from being processed by a command.

Interactive mode

Prompts user before overwriting files, usually you enter it with an i.

Find command Linux

Recursively search for file starting from a specified directory. find <start directory> -criteria <what to find> ex. find any files named "innitab" under the /etc directory. find /etc -name inittab find command with wildcard meta character example. Find all files that start with the letters "host" underneath the /etc directory root@server1 ~ # find /etc -name "host*"

Superblock

Section that contain information about the filesystem in general. Number of inodes and data blocks, and size of each data block

Each file and directory must have an inode, except for what?

Special device files also have data blocks associated with the inode.

Filesystem Hierarchy Standard (FHS)

Standard set of directories for Linux and UNIX systems Standard file and subdirectory contents. Simplifies the task of finding specific files Gives Linux software developers ability to locate files on any Linux system. Create non-distribution-specific software.

What are the three main sections of a filesystem?

Superblock, Inode table, data blocks

symbolic link characteristics

Symbolic linked files do not share the same inode and data blocks with their target file. They do not have to be on the same filesystem as their target file, as hard links do.

locate command

The command used to locate files from a file database. (faster than find, less versatile) Database is indexed like a textbook for fast searching, yet can become outdated as files are added and removed from the system. We have to run updatedb.

What happens if the file being searched does not exist in the PATH variable directory?

The which command lets you know in which directories it was not found.

Hard links need to reside on the same filesystem as the target, whereas symbolic links need not be on the same filesystem as the target. True or False?

True

Hard link

Two files share the same data. Whatever is modified in one file, is modified in another.

After typing the ls -F command, you see the following line in the output: -rw-r-xr-- 1 user1 root 0 Apr 29 15:40 file1

User1 has read and write, members of the root group have read and execute, and all others have read permissions to the file.

The root user utilizes the chgrp command to give ownership of a file to another user. What must the root user do to regain ownership of the file?

a. Run chgrp again listing the root user as the new owner.

Which of the following commands will change the user ownership and group ownership of file1 to user1 and root, respectively?

chown user1:root file1

A file has the following permissions: r----x-w-. The command chmod 143 would have the same effect as the command . (Choose all that apply.) 1 = execute (user) 4 = Read (group) 3 = write and execute (Others)

d. chmod u=x,g=r,o=wx file1

Common Linux file management command

mkdir (creates directories) rmdir(Removes empty directories) mv (Moves/renames files and directories) cp (Copies files and directories full of files (with the -r or -R option) alias (Displays BASH shell aliases) rm(Remove files and directories full of files (with the -r or -R option) unlink (Removes files)

Which command do you use to rename files and directories?

mv

User permissions:

owner

Interpreting the Mode

r - Read w - write x - execute rwx rwx rwx user - group - other

Binary of permissions

read 2^2 = 4 write 2^1 = 2 execute 2^0 = 1 421 421 421 rwx rwx rwx 7 7 7 4+2+1 = 7

chmod u=rw, g=r, o=r file2

rw-r--r--

The default permissions given by the system prior to analyzing the umask are ____ for directories and _____ for files.

rwxrwxrwx and rw-rw-rw-

The which command ___.

searches for a file only in directories that are in the PATH variable

Find command rules

slower than locate (Does not use premade index of files; instead, it searches the directory tree recursively, starting from a certain directory) if using wildcard metacharacters, ensure that they are interpreted by the find command; place wildcards in quotation marks to reduce search time, specify the sub directory to be searched.

What does the /var directory contain?

spools and log files

How to access lost and found

sudo su enter password: cd lost+found

symbolic link characteristics (1 of 2)

symbolic linked file is a pointer to the target file, data blocked in the linked file contain only the pathname to target file, editing the symbolic linked file edits the target file, and if the target file is deleted, the symbolic link serves no function.

Creating a empty file

touch

If information returned may not fit on screen

use more or less command ex. locate inittab | more - if the command produced too many results locate inittab | more/less command can be used to pause the output.

How to view the current username

whoami

You noticed a file in your home directory that has a + symbol appended to the mode. What does this indicate?

Additional entries exist within the ACL of the file that can be viewed using the getfacl command.

chmod 540 file1

-r-x r-- ---

Common Criteria Used with the find command

-amin -x Searches for files that were accessed less than x minutes ago -amin +x Searches for files that were accessed more than x minutes ago -atime -x Searches for files that were accessed less than x days ago -atime +x Searches for files that were accessed more than x days ago -empty Searches for empty files or directories -fstype x Searches for files if they are on a certain filesystem x (where n could be ext2, ext3, and so on) -group x Searches for files that are owned by a certain group or GID (x) -inum x Searches for files that have an inode number of x -mmin -x Searches for files that were modified less than x minutes ago -mmin +x Searches for files that were modified more than x minutes ago -mtime -x Searches for files that were modified less than x days ago -mtime +x Searches for files that were modified more than x days ago -name x Searches for a certain filename x (x can contain wildcards) -regex x Searches for certain filenames using regular expressions instead of wildcard metacharacters -size -x Searches for files with a size less than x -size x Searches for files with a size of x -size +x Searches for files with a size greater than x -type x Searches for files of type x where x is: b for block files c for character files d for directory files p for named pipes f for regular files l for symbolic links (shortcuts) s for sockets

PATH variable for ls

1. type ls 2. system recognizes the command was not an absolute pathname (e.g. /usr/bin/ls) or (e.g., ../../usr/bin/ls) and then proceeds to look for the ls executable file in the /usr/share/Modules/bin directory; then the /usr/local/sbin directory and then the /usr/local/bin directory, /usr/sbin directory

Permissions

A list that identifies who can access a file or folder and their level of access.

Why do we not need to specify a full pathname to ls (usr/bin/ls) ?

A special variable called PATH is placed into memory each time a user logs in to the Linux system

Symbolic link

A symbolic link, also termed a soft link, is a special kind of file that points to another file, much like a shortcut in Windows or a Macintosh alias. Unlike a hard link, a symbolic link does not contain the data in the target file. It simply points to another entry somewhere in the file system.

To exclude /etc directory from being indexed by the updatedb command

Add etc as an argument to the PRUNEPATHS = line within /etc/updatedb.conf


Ensembles d'études connexes

Somatic symptom and dissociative disorders

View Set

Econ Final Exam (Exam 3 Answers)

View Set

NU372 Week 1 EAQ Evolve Elsevier: Infection (Custom Quiz)

View Set