Tuesday, July 15, 2014

Road to RHCE - Day 6

Day 6


bash configuration

bash is one of the login shells available for users in linux & the most commonly used shell as well.

Below are the important configuration files for bash. These files are present under every user's home directory -

.bashrc                           - contains the session configuration of the user
.bash_profile                  - contains the profile info of the user
.bash_logout                  - contains the commands/actions to be executed at end of the session (logout)
.bash_history                 - history of commands used by the user (this file will be populated only during the first successful logout)


There are also global shell configuration that can be set for all users via below file -

/etc/bashrc
/etc/profile


inode

inode -> index node


To check the inode of a file or directory

ls -i [filename]


Links

There are two types of links -

hard link
soft link

hard link

  • points directly the memory location of the file
  • same inode as that of the physical file
  • can be accessible even if the actual file is deleted
  • not possible to create hard links for directories
  • like a backup for the physical file
  • occupies the same space as that of the file


soft link

  • points to the file
  • different inode than the physical file
  • can not be accessible if the physical file is deleted
  • it is possible to create soft link for directories
  • does not occupy additional disk space


To create a hard link

ln [filename] [link_name]


To create a soft link

ln -s [filename] [link_name]


Special Permissions

There are three special permissions that can be set for files & directories -

Special userid (suid)    -> owner
Special groupid (sgid) -> group
Sticky bit                     -> others


Special userid

If set, the file will get executed based on the owner's permission and not based on the executor's permission.


To set special user id

Symbolic Method -> chmod u+s [filename]
Numeric Method  -> chmod 4755 [filename]

[! the first digit (4 for owner, 2 for group, 1 for others) denotes the special permission]


Special groupid

If set for a directory, all the future files/directories that gets created under that directory will have the group owner same as that of the parent directory.


To set special groupid

Symbolic Method -> chmod g+s [directory]
Numeric Method  -> chmod 2755 [directory]


Sticky bit

If set for a directory whose content have permission set as 777, other users can edit the contents of that directory but cannot remove or rename or move them.


To set sticky bit

Symbolic Method -> chmod o+t [directory]
Numeric Method  -> chmod 1777 [directory]


To flush the history of the current logged in user

history -c



-- End of Day 6 --

No comments: