Manipulating files and directories Flashcards
What is the command to create a directory?
mkdir
What is the command to remove an empty directory?
rmdir
What is the command to remove a directory with contents
rm -r
What is the command to create a parent directory and subdirectory?
mkdir -p
i.e mkdir -p parent/child
What is the command to create a non existing file/ update the timestamp of an existing file/directory?
touch
i.e touch file
What is the command to rename a file/directory?
mv
i.e mv oldname newname
What is the command to copy a directory and its contents?
cp -r
-R –recursive
What is the command to create a symbolic link?
ln -s >pathtoreference< >link<
i.e ln -s /var/spool/mail mail
When creating a symlink, what are the permissions?
Full permissions to view where the link points to, however it does not reflect the permissions of the file it is linking to.
How do you create a hard link?
ln >pathtorefrence< >link
How does a hard link work?
Links directly to an inode on the file system, inode location will exist until all referring links are removed. Permissions/time stamp are identical across links. Unlike symbolic links hard links cannot link across file systems (inc. partitions)
How do you view the inode for a file/directory?
ls -i
How many links will a symbolic link have vs a hard link?
Symbolic link will have 1 link to the location
Hard link will have 2 links because each links to an inode location
What is the syntax that constitutes a file permission?
- |rwx|rwx|rwx (read write execute)
type|user|group|other
no access means -
i.e -|r-x|-w-|rw-
What is the syntax that constitutes a directory permission?
d|rwx|rwx|rwx (read write cdinto)
type|user|group|other
no access means -
i.e d|r-x|-w-|—
What is the octal notation associated with a file/folder permission?
d|421|421|421
d|rwx|rwx|rwx
-|421|421|421
-|rwx|rwx|rwx
What would the octal notation equivalent be for d|r-x|r-x|rwx?
d|r-x|r-x|rwx = d|5|5|7
d|4+0+1|4+0+1|4+2+1