Linux Basic
File Structure
***************
/bin : User binaries (Common Linux command need to use in single user mode)
/sbin : System binaries (Commands under this is for system maintenance purpose used by system admins)
/etc : Config files (etc: extended text configuration)
/dev : Device files
/proc : Process info (Contains running process info, Once system get reboot then all the related files will get clear and will create new info. because it retrieves information from kernel and memory.)
/var : Variable files (It contains logs)
/tmp : Temporary files (Contains temporary files created by system and user, Once system get reboot then all the files will get clear)
/usr : User programs (USR: Unix system resource. Contains binaries, libraries documentation files. Under it we have bin(Eg: less,awk) and sbin(Eg: cron, sshd) which contains binary files for user programs.)
/home : Home directories
/boot : Boot loader files(kernel files, grub files etc)
/lib : System libraries(Contains library files that supports the binaries that are located in /bin and /sbin)
/opt : Optional add-on apps(Contains add on installed application related files)
/mnt : Mount directory (To mount any foreign device temporarily)
/media : Removable device(To mount any removable device)
/srv : Service data (Contains server specific service data)
**\=======================================
Types of Permissions**
1 ==> Command Execution based Permissions ==> SUDO + SUID
2 ==> File and directory based Permissions ==> chmod + setfacl
\==> chown + chgrp
\==> ls -l ==> ls -ld ==> getfacl
\=======================================
Types of user login ==>
1- Super user ==> root ==> # ==> private place [ home directory ] + public place [ full ]
2- Normal user ==> deepak ==> $ ==> private place [ home directory ] + public place [ read only ]
\=======================================
File and directory Permissions
\=======================================
Attributes ==> Three
\======================================
read ==> r ==> 4
write ==> w ==> 2
execute ==> x ==> 1
symbolic Numeric
Code Code
\=====================================
none ==> — ==> 0
\=====================================
/share <== Automatic Permissions or default permissions
\=====================================
pair
rwx or 4+2+1 ==> 7
r-x or 4+0+1 ==> 5
rw- or 4+2+0 ==> 6
r — or 4+0+0 ==> 4
— — or 0+0+0 ==> 0
\=====================================
Permissions
1- Default permission or automatic permissions ==> umask value
2- custom permissions ==> as per need we can customised it ==> chmod
\=====================================
[ root @ localhost ~ ] # touch /xyz ==> file ==> 6 4 4 [ owner group-owner others ]
[ root @ localhost ~ ] # mkdir /share ==> directory ==> 7 5 5 [ owner group-owner others ]
\=====================================
[ deepak @ localhost ~ ] $ touch /tmp/abc ==> file ==> 6 6 4
[ deepak @ localhost ~ ] $ mkdir /tmp/data ==> directory ==> 7 7 5
\=====================================
file or directory # ls -l /xyz OR # ls -ld /share
10 bit ==> 1 + 9 ==> 1 ==> presentation ==> blank ==> file
\==> d ==> directory
\==> l ==> soft link or shortcut
9 ==> Three Block ==> first block ==> owner
second block ==> group
Third block ==> others
# ls -l /xyz
- r w — r — — r — — ==> 6 4 4
# ls -ld /share
d r w x r — x r — x ==> 7 5 5
\=======================================
read
write
execute
\======================================
# mkdir /share
# ls -ld /share ==> owner ==> root
\==> group ==> root
\==> others ==> except of root ==> others
d rwx r-x r-x
# chmod o+w /share
# ls -ld /share
d rwx r-x rwx
\=======================================
# mkdir /share ==> 7 5 5
# chmod 750 /share
other ==> zero
sunil ==> r — x
soniya ==> r w x
alok ==> r w x
Types of permissions changing method
using chmod command ?
1- numeric based ==> # chmod 777 /data
# chmod 770 /data
2- Symbolic based ==> # chmod u=rwx,g=rwx,o=rwx /data
\======================================
Permissions
1- chmod ==> one short ==> overall ==> owner group others but you can not mentioned the
particular user name and group name
2- setfacl ==> Other user/groups ==> name based permissions apply
\======================================
permissions apply ==> chmod + setfacl
owner ship change ==> chown + chgrp
\======================================
ACL Umask numeric symbolic
\======================================
Chattr
[ Change Attributes ]
\===========================
1- chmod
2- chown
3- chgrp
4- ACL or setfacl
5- ls -l
6- getfacl
Chatter
1- Chatter command basically use to apply very high level
Permissions on any file and directory.
2- This permissions can also control the super user.
3- This permissions basically restrict the direct and indirect
changes into any area.
\======================================
ACL [ Access Control List ]
\=======================================
ls -l
ls -ld
chmod ==> change the permissions ==> overall ==> owner group others
setfacl ==> to apply the permissions ==> using the username and group name
chown ==> to change the ownership
chgrp
\=======================================
chmod ==> one short
setacl ==> to apply the ACL
getfacl ==> to find out report about acl based permissions
\=======================================
# touch /tmp/xyz ==> file ==> 6 4 4
# chmod 770 /tmp/xyz ==> other zero
# chmod 777 /tmp/xyz
soniya ==> r —
deepak ==> rw- ==> setfacl
alok ==> rwx
\=========================================
rahul sachin
\=========================================
How to Check ACL permission is running or not on this file
# ls -l /etc/passwd
— — — — — — . ==> NO acl
+ ==> we have applied acl on this files.
# getfacl /etc/passwd
\========================================
ACL ==> it is mainly use to apply permission on any
file or directory with any particular username
and group name.
Create a simple file and do ls -ltr
to see the details of the files.
##