A complete Linux Fundamentals tutorial covering Linux distributions, basic commands, file system structure, text editors, permissions, user management, and environment variables. Ideal for beginners and Linux administration learners.
1) Linux Distributions
Linux has many distributions (distros). The kernel is the same, but packaging, tools, and default behavior differ.
Popular Distros:
- RHEL / CentOS / Rocky / AlmaLinux – Enterprise servers
- Ubuntu / Debian – General use, cloud, development
- SUSE / OpenSUSE – Enterprise servers
- Kali Linux – Security testing
Package managers:
- RHEL-based: yum, dnf
- Debian-based: apt
Example: Checking the Linux distribution
cat /etc/os-release
Sample output:
NAME="Red Hat Enterprise Linux"
VERSION="8.8"
Example: Checking kernel version
uname -r
2) Basic Linux Commands
Navigation
pwd # show current directory
ls # list files
ls -l # detailed view
cd /etc # go to /etc
cd .. # go back
File & Directory Operations
mkdir project # create directory
touch file.txt # create empty file
cp file.txt /tmp/ # copy file
mv file.txt file1.txt # rename file
rm file1.txt # delete file
rm -rf folder/ # delete folder
View Content
cat file.txt
head -n 5 file.txt
tail -n 10 file.txt
more file.txt
less file.txt
Search text inside files
grep "root" /etc/passwd
grep -i "error" logfile.txt
Find files
find / -name file.txt
3) File and Directory Structure
Linux file system starts with root /.
Important directories:
/bin– Basic commands (ls, cp, mv)/sbin– System commands (mount, reboot)/etc– Config files (ssh, cron, network)/var– Logs, mail, spool/home– User directories/root– Root user home/tmp– Temporary files/usr– System libraries, applications
Example: Listing top-level directories
ls /
Example: Checking config file
cat /etc/ssh/sshd_config
4) vim / nano Editors
Opening a file in vim
vim file.txt
Modes:
- Insert mode → press
i - Command mode → press
Esc - Save & exit →
:wq - Quit without saving →
:q!
Examples inside vim
- Delete a line:
dd - Copy a line:
yy - Paste:
p - Search text:
/word
nano editor
nano notes.txt
Keys:
- Save →
Ctrl + O - Exit →
Ctrl + X
5) Permissions and Ownership (chmod, chown)
Linux permissions have 3 parts:
User | Group | Others
r (4) w (2) x (1)
Check permissions
ls -l
Example output:
-rwxr-xr-- 1 muni admin 120 file.txt
Meaning:
- User: rwx
- Group: r-x
- Others: r--
Changing permissions
Numeric method
chmod 755 file.txt
Meaning:
- User: 7 = rwx
- Group: 5 = r-x
- Others: 5 = r-x
Symbolic method
chmod g+w file.txt # add write to group
chmod o-r file.txt # remove read from others
Changing owner & group
chown muni file.txt
chown muni:admin file.txt
6) Users and Groups
Create a user
useradd devuser
passwd devuser
Create a group
groupadd developers
Add user to group
usermod -aG developers devuser
Delete a user
userdel devuser
userdel -r devuser # delete home directory also
Check user info
id devuser
Important files
cat /etc/passwd
cat /etc/shadow
cat /etc/group
Example of /etc/passwd entry:
devuser:x:1001:1001::/home/devuser:/bin/bash
7) PATH and Environment Variables
Check PATH
echo $PATH
Sample output:
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin
Temporary variable
export MYVAR=hello
echo $MYVAR
Make variable permanent (for specific user)
Edit:
vim ~/.bashrc
Add:
export MYVAR=hello
Reload:
source ~/.bashrc
Add a directory to PATH
export PATH=$PATH:/opt/scripts
Permanent:
Add the above line to ~/.bashrc.