-
Notifications
You must be signed in to change notification settings - Fork 0
Basic Linux File system
The Linux filesystem is a tree structure starting from the root / directory. All files and directories branch from here.
Let’s walk through the important directories, what they’re for, and give real examples relevant to data science and system usage.
-
Top-level directory. Everything starts here.
-
Owned by root user (
/rootis not the same as/).
-
Contains essential executable commands needed for basic use.
-
Used during boot and single-user mode.
🔧 Examples:
bashCopyEdit/bin/ls # list files /bin/cp # copy /bin/mkdir # make directory /bin/bash # shell
-
Contains admin commands for system maintenance.
-
Requires
sudoor root privileges.
🔧 Examples:
bashCopyEdit/sbin/ifconfig # view network interfaces (older) /sbin/reboot # restart system /sbin/mkfs # create filesystem
Think of /usr like "user space" apps. It’s usually the largest directory.
-
/usr/bin– non-essential command binaries (installed packages) -
/usr/sbin– admin binaries not needed for basic system -
/usr/lib– libraries for installed programs -
/usr/local– user-installed software
🔧 Examples:
bashCopyEdit/usr/bin/python3 /usr/bin/Rscript /usr/lib/python3/dist-packages/ # Python libraries /usr/local/bin/jupyter # Jupyter Notebook if installed manually
📦 Installations from apt/pip often land here.
-
All system-wide configuration files.
-
Plain text, editable with editors like
nano,vim.
🔧 Examples:
bashCopyEdit/etc/passwd # user account info /etc/hostname # system name /etc/network/interfaces # network config /etc/mysql/my.cnf # MySQL config /etc/jupyter/jupyter_notebook_config.py
🧠 Good place to explore how your system is configured.
-
Each user has a folder:
/home/sree,/home/ubuntu, etc. -
This is where you do your work as a regular user.
🔧 Examples:
bashCopyEdit/home/sree/projects/data-cleaning/ ~/notebooks/eda.ipynb
💡 Usually where:
-
Git repos are cloned
-
Virtual environments live
-
Jupyter notebooks are saved
-
Files that change frequently: logs, caches, spool files.
🔧 Examples:
bashCopyEdit/var/log/syslog # system logs /var/log/jupyter.log # Jupyter logs (if configured) /var/cache/apt/archives # downloaded .deb packages /var/lib/mysql # MySQL databases
🧠 Check logs here for troubleshooting issues.
-
Temporary storage for files.
-
Automatically cleared on reboot.
🔧 Examples:
bashCopyEdit/tmp/tmp1234.csv
💡 Can be used for storing large intermediate files in pipelines.
-
Interface to hardware (not actual files).
-
Devices like USB, disks, GPU appear here.
🔧 Examples:
bashCopyEdit/dev/sda # primary hard disk /dev/nvidia0 # GPU device for CUDA
💡 Useful when working with large data storage devices or GPUs.
-
Not real files — gives a view into the kernel.
-
Contains a folder for each running process, by PID.
🔧 Examples:
bashCopyEdit/proc/cpuinfo # CPU details /proc/meminfo # Memory usage /proc/1234/status # Info about PID 1234
-
Contains dynamic libraries (
.sofiles) used by binaries in/binand/sbin.
🔧 Examples:
bashCopyEdit/lib/x86_64-linux-gnu/libc.so.6
💡 Think of
.sofiles like.dllfiles in Windows.
-
For third-party applications not from package manager.
🔧 Examples:
bashCopyEdit/opt/anaconda/
💡 Often used to install Anaconda, VS Code Server, MATLAB, etc.
-
Home directory for the root user (different from
/). -
Has full privileges; used only for admin work.
🔧 Examples:
bashCopyEdit/root/.bashrc /root/admin-scripts/
When you install python3-pip via APT (the default package manager on Debian/Ubuntu):
bashCopyEditsudo apt update sudo apt install python3-pip
-
Installed at:
bashCopyEdit/usr/bin/pip3
This is the actual pip3 command you run in terminal. You can verify:
bashCopyEditwhich pip3 # Output: /usr/bin/pip3
If you then install a Python package using:
bashCopyEditpip3 install numpy
Depending on the environment, the packages go into:
-
System-wide:
bashCopyEdit/usr/lib/python3/dist-packages/
or
bashCopyEdit/usr/local/lib/python3.X/dist-packages/
Check it with:
bashCopyEditpip3 show numpy
bashCopyEditwhich pip3 pip3 --version pip3 list pip3 show pandas
This gives you both the location and how it’s connected to your Python interpreter.