Linux-Directory
1. / = Directory is called root directory . head/parent of the all directory. *2./bin * *contains executable/program/commands to achieve the basic tasks that accessible for every system user and root user. Eg: ls,cat,touch,cp,mv. => # = Root user => $ = Normal user 3. /sbin => *contains /executable/program/command to achieve the system level task or system level settings for Only root user can executable . Not accessible for normal user. Eg: ifconfig,iptables,fsck,fdisk *4. /dev = Linux/Unix is treats everything as file including hardware devices * /dev is a directory that provides device files acting as interfaces between hardware and user-space programs. These files allow software to communicate with hardware without direct access. *what is mean user space user space - run regular program without direct access of hardware access,like browser and ,text editor, command line tool ls, cat. /dev paths /dev/sda - sata disk(primary device) /dev/hda - IDE hard disk /dev/sdb - secondary device /dev/cdrom - CD/DVD drive /dev/tty - terminal interface. Two main type of device:- i. Character device= Transfer the data byte to byte(used for serial communication),perform wise it slower and small data Example: keyboard ,mouse, serial port,mic /dev/tty - terminal interface, /dev/input/mice ii.Block device = Transfer data block to block, preform wise it faster and large data example: storage device:- ssd ,usb , hhd *we will see device management detailed info and create device and so on. *5 . /etc * *Sytem directory ,it contains system-wide configuraiton file and installed program settings.it not for user specific ,does not contain binary executable like /bin or /sbin only contain text based configuration files, require root(sudo) access to modifying /etc . Linux application and services read the setting from /etc . *etc/ contain ,system and network settings ,serives and boot and startup scripts......etc. example: $ sudo vim /etc/hostname Common files and Directories:- i./etc/passwd - store the use account information ii. /etc/shaddow - store encrypted password iii. /etc/group - define usr gourps iv. /etc/hosts - map to hostanme to ip address v. /etc/fstab - contains info on mounted(connected) filesystems vi. .etc/hostanme - view hostnbame and also u can edit vii. /etc/reslov.conf - configure of dns settings viii. /etc/network/interfaces - stores nework configuration files ix. /etc/ssh/sshd_config - store ssh server settings x. /etc/systemd/ stores systemd serice configuation Be careful when editing, as changes affect the entire system. *6./home (home = ~) * /home directory in store user home directories , every user on the system has a personal folder inside of /home , you can view user related documents , downloads ,file, configuration and settings....etc. System-wide configuration files are not stored here (those are in /etc). --- check i. change the directory cd ~ ii. List all user directors in /home ls /home iii. check the current home directory echo $HOME iv. Navigate the your home directory cd /home/your-username v. sudo userdel -r username -r = recursively(remove) it Deletes user + home directory vi. disk usage of /home du -sh /home -s = summarizes the total size -h = human readable vii. sudo -u alice -s -u = mean user -s = mean open a new shell for that new user viii. sudo userdel username Deletes only user, keeps home directory ix. sudo rm -r /home/username Deletes only the home directory *7. /lib = library * /lib directory contain shared libraries and kernel modules required by system and programs in /bin and /sbin . Detailed information of /lib Stores the shared libraries(.so files ) needed for basic system programs support commands stored in /bin and /sbin . Example shared libraries in /lib => modules/ → Kernel modules (drivers) => systemd/ → System service manager files => firmware/ → Hardware firmware => libcrypt.so → Example shared library => libc.so - standard C library (important of C programm) => libc.so - basic system commands> => libssl.so - provide encrypt secure internet connerction , uded by google chrome,fire fox,vpns. => libGL.so - graphics Library for games ,drones => libusb.so - usb communication library => libm.so -Math functions (used in calculation) => Math functions (used in calculation) => libpthread.so - thread support. => lirobotics.so = drones,robots,Industrila automation. . *purpose of shared libraries:- * *Avoid duplicating the same code in every time *Save disk space and Ram *Allow programs to update without recompiling. *shared libraries (.so shared object files) contain reusable code that helps to multiple program can use reducing duplication. Without /lib, your Linux system won’t boot properly. *used by applications ( firefox,VLX,chrome) in run is user space. example web browser(Chrome,Firefox) All web page needs to display text and i

1. / = Directory is called root directory . head/parent of the all directory.
*2./bin
*
*contains executable/program/commands to achieve the basic tasks that accessible for every system user and root user.
Eg: ls,cat,touch,cp,mv.
=> # = Root user
=> $ = Normal user
3. /sbin
=> *contains /executable/program/command to achieve the system level task or system level settings for Only root user can executable . Not accessible for normal user.
Eg: ifconfig,iptables,fsck,fdisk
*4. /dev = Linux/Unix is treats everything as file including hardware devices *
- /dev is a directory that provides device files acting as interfaces between hardware and user-space programs. These files allow software to communicate with hardware without direct access. *what is mean user space user space - run regular program without direct access of hardware access,like browser and ,text editor, command line tool ls, cat.
/dev paths
/dev/sda - sata disk(primary device)
/dev/hda - IDE hard disk
/dev/sdb - secondary device
/dev/cdrom - CD/DVD drive
/dev/tty - terminal interface.
Two main type of device:-
i. Character device= Transfer the data byte to byte(used for serial communication),perform wise it slower and small data
Example: keyboard ,mouse, serial port,mic
/dev/tty - terminal interface,
/dev/input/mice
ii.Block device = Transfer data block to block, preform wise it faster and large data
example:
storage device:-
ssd ,usb , hhd
*we will see device management detailed info and create device and so on.
*5 . /etc
*
*Sytem directory ,it contains system-wide configuraiton file and installed program settings.it not for user specific ,does not contain binary executable like /bin or /sbin only contain text based configuration files, require root(sudo) access to modifying /etc .
- Linux application and services read the setting from /etc . *etc/ contain ,system and network settings ,serives and boot and startup scripts......etc.
example:
$ sudo vim /etc/hostname
Common files and Directories:-
i./etc/passwd - store the use account information
ii. /etc/shaddow - store encrypted password
iii. /etc/group - define usr gourps
iv. /etc/hosts - map to hostanme to ip address
v. /etc/fstab - contains info on mounted(connected) filesystems
vi. .etc/hostanme - view hostnbame and also u can edit
vii. /etc/reslov.conf - configure of dns settings
viii. /etc/network/interfaces - stores nework configuration files
ix. /etc/ssh/sshd_config - store ssh server settings
x. /etc/systemd/ stores systemd serice configuation
- Be careful when editing, as changes affect the entire system.
*6./home (home = ~)
*
-
/home directory in store user home directories , every user on the system has a personal folder inside of /home , you can view
user related documents , downloads ,file, configuration and settings....etc.- System-wide configuration files are not stored here (those are in /etc). --- check
i. change the directory
cd ~
ii. List all user directors in /home
ls /home
iii. check the current home directory
echo $HOME
iv. Navigate the your home directory
cd /home/your-username
v. sudo userdel -r username
-r = recursively(remove)
it Deletes user + home directory
vi. disk usage of /home
du -sh /home
-s = summarizes the total size
-h = human readable
vii. sudo -u alice -s
-u = mean user
-s = mean open a new shell for that new user
viii. sudo userdel username
Deletes only user, keeps home directory
ix. sudo rm -r /home/username
Deletes only the home directory
*7. /lib = library
*
- /lib directory contain shared libraries and kernel modules required by system and programs in /bin and /sbin .
Detailed information of /lib
- Stores the shared libraries(.so files ) needed for basic system programs support commands stored in /bin and /sbin .
Example shared libraries in /lib
=> modules/ → Kernel modules (drivers)
=> systemd/ → System service manager files
=> firmware/ → Hardware firmware
=> libcrypt.so → Example shared library
=> libc.so - standard C library (important of C programm)
=> libc.so - basic system commands>
=> libssl.so - provide encrypt secure internet connerction , uded by google chrome,fire fox,vpns.
=> libGL.so - graphics Library for games ,drones
=> libusb.so - usb communication library
=> libm.so -Math functions (used in calculation)
=> Math functions (used in calculation)
=> libpthread.so - thread support.
=> lirobotics.so = drones,robots,Industrila automation.
.
*purpose of shared libraries:-
*
*Avoid duplicating the same code in every time
*Save disk space and Ram
*Allow programs to update without recompiling.
*shared libraries (.so shared object files) contain reusable code that helps to multiple program can use reducing duplication.
Without /lib, your Linux system won’t boot properly.
*used by applications ( firefox,VLX,chrome) in run is user space.
example
web browser(Chrome,Firefox)
- All web page needs to display text and image for example you need to diplay the image on you website ,you not need to write your code instead you use to libfreetype.so which provide ready-made functions for text rendering.
Checking Shared Libraries Used by a Program:
=> #ldd /bin/ls
kernel module
*A kernel module is a driver or extension that can be loaded/unload the linux kernel without rebooting the system.
purpose:-
- It allows Linux to support new hardaware feature like wifi , usb , graphics...etc.
- adds new filesystem support (NTFS,ext4,xfx) and help communicate the hardware devise like keyboard ,mouse,printer and also add or remove dynamically without restart the file system.
example:-
when you plug in usb in system ,linux load a kernel usbstorage.ko to access the device then ,unplug usb Linux automatically remove the module.
*used by kernel & Hardware runs in kernel space
Example:-
lsmod | grep Difference Between /lib, /usr/lib, and /lib64 /lib = system libraries for programs in /bin and /sbin for system beet neede *Library files require to not only Linux os apart form Rockets, mobile apps,Autonomous Robots (librrobotics.so used to tesla autopilot,NASA MARS Rover),Ai,web Browser......etc. *8. /media = Auto mount(connect) for External device *.
*/media directory is used to automatically mount external device like usb drives , CDs,DVDs,SD cards.
*when you insert a usb drive, it us usually mounted in /media/username/usb-drive//
example:- *9. /mnt/ manual mounting of device i. mount point directory $ sudo mkdir -p /mydir/externdevice or sudo umount /mydir/externdevice why umount? *10. /opt = optional => *Directory used for store third party application or manually installed software not managed for system package manager
/usr/bin - system wide installed programs by package manager *11. /proc *The directory in linux special folder . which show the live system information and computer hardware ,it does not contain real files but create information on the spot .
Example:-
*when you run a program like firefox & ,kernel created the new process and assign to the pid. process details appear in /proc/PID-of-firefox
practical:-
$firefox & Important directory in /proc:- /proc/cpuinfo = info about the cpu model,core,speed. 12. /root *normal user can not access /root ,if you need to access you can choose sudo.
example *13./tmp (temporary files) *stores temporary files that are automatically delted after restart or some time. Example:- 14. /usr if you read this directory tell me different 15. /var = variable data *contains variable file like log files and printer spools.L
examlple;- example:- 16 . /boot
example
i.ls /boot 17 . /run -runtime data storage
example
18 . /srv - service data storage
Example:-
vim editor after opened press i add the last lines as per below image then double press Esc then :wq ,after restart serives, then type http:
Result:
19 . /sys - system information
/sys directory is a virtual file system that provide the information about hardware device and kernel,it allow to linux kernel to ineract with system hardware in real time.
Example:-
i.liste the storage device ii.detailed hardware device info iv. ls /sys/module - list kernel modules
ii. usb-storage.ko - mange storage device internal and external
iii. btusb.ko - manage Bluetooth device
iv. video.ko - .manage webcam drivers
v. ext4.ko - filesystem handling
/usr/lib = Libraries for user applications (not critical for system boot not need for boot ).
/lib64 64-bit version of libraries (for 64-bit systems).
*lib used for you do not write all code manually it already pre-written for example in your create website project not need calculation code instated of you use libm.so (which provides sin(), cos(), sqrt(), etc.).
ls /media/
*
why mount in a directory?
*you don not access storage devise directly
instead , you attach(connect or mount) to dir ,then you can access the directory. without mounting do not know where to access the usb. if mount usb dirive /mydir/externdevice you can access it inside of folder.
$ sudo mount /mydir/externdevice
ii. verify the mount
mount | grep /mydir/externdevice
df -h
umount -disconnect
*without umount you loss your data or corruption
*
/usr/local/bin - locally installed software by admin
*
$ps aux | grep firefox
show the snapshot firefox pid and other deatils.
$ls /proc/pidofirefox
show the firefox process,memory usage ...etc
when close or kill fire fox using kill command it pid disappear from /proc directroy because it virtual filesytem, only show live session on when run the process.
$pidof firefox
show the more pid, its mean fire fox separate process for ui ,web pages,extension and so on.
/proc/meminfo = system RAM details
/proc/upting = system how long will be running system.
/proc/version = kernel version info.
/proc/mounts = shows mounted fiessystems
/proc/loadavg = system load average.
$sudo ls /root
$sudo cd /root
*
*used by application to store temorarery files, like session data, logs,caches.
$cd /tmp
$touh temp.txt
then restart system after use below command
$ls /tmp
for example :
bin/ vs /usr/bin
lib/ vs /usr/lib
i. /var/log = system log,auth.log,dmesg
ii. /var/spool = Email queues and printer queues.
iii. var/tmp - Longer time temp file it mean still there after reboot.
ls /var/log
cat /var/log/syslog - view system log
ii. ls /boot/vmlinuz* ( show installed kernels)
iii. cat/boot/grub/grub.cfg ( grub config file)
ls /sys/block
cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor
iii. Check total memory in system
cat /sys/devices/system/memory/block_size_bytes