Linux Fundamentals Tutorial for Beginners: Commands, File System, Permissions, Users, Environment Variables - Textnotes

Linux Fundamentals Tutorial for Beginners: Commands, File System, Permissions, Users, Environment Variables


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:

  1. RHEL / CentOS / Rocky / AlmaLinux – Enterprise servers
  2. Ubuntu / Debian – General use, cloud, development
  3. SUSE / OpenSUSE – Enterprise servers
  4. Kali Linux – Security testing

Package managers:

  1. RHEL-based: yum, dnf
  2. 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:

  1. /bin – Basic commands (ls, cp, mv)
  2. /sbin – System commands (mount, reboot)
  3. /etc – Config files (ssh, cron, network)
  4. /var – Logs, mail, spool
  5. /home – User directories
  6. /root – Root user home
  7. /tmp – Temporary files
  8. /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:

  1. Insert mode → press i
  2. Command mode → press Esc
  3. Save & exit → :wq
  4. Quit without saving → :q!

Examples inside vim

  1. Delete a line: dd
  2. Copy a line: yy
  3. Paste: p
  4. Search text: /word

nano editor


nano notes.txt

Keys:

  1. Save → Ctrl + O
  2. 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:

  1. User: rwx
  2. Group: r-x
  3. Others: r--

Changing permissions

Numeric method


chmod 755 file.txt

Meaning:

  1. User: 7 = rwx
  2. Group: 5 = r-x
  3. 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.