Linux

 

6-9-22

  •        MSDOS – CLI
  •         MSWIN (GUI)
  •      UNIX – first cooperate Operating System

o   Powerfull operating system

o   Command line interface (CLI)

-        Linux (CLI & GUI)

o   Open source OS

o   Unix’s clone

-        Unix like family

o   AIX – IBM

o   HP.UX – HP

o   Text User Interface (TUI)

-        .exe – windows

-        .rpm – linux – Red hat package management

-        DBN – Kali linux, Ubuntu

-        Red hat – Rhel, CentOS, Rocky Linux

-        Types of OS – 3:

o   Single User – Single Tasking

§  MSDOS

o   Single User – Multi Tasking

§  MSWIN

o   Multiuser – Multi Tasking

§  Unix, linux

-        RHEL – 7.0, 8.0

o   Bourne Again Shell (BASH)

o   Shell – SH, KSH, CSH

o   Kernel – Core Os

§  Mono – linux – uname -a (or) – r

§  Micro – Windows – Systeminfo

o   Kernel – Device info

§  Multitasking

§  File system info

7-9-22

-          

24-8-22

-        DvD, Pen Drive and

-        ISO.img (win10)

-        System (pc)

-        Reboot

-        Bios F1 –  F12, del, esc

-        Boot

-        First boot Pen Drive

-        F10 – to Save

-        Reboot

-        _

-        A – Z

-        A, B Floppy

-        C HDD

-        _

-        C:\ win 10 OS

-        _

-         

Linux – file system Hierarchy

-        / - top level directory, Parent Directory

-        /root – Home directory for root user

-        _

-        Admin → root - #

-        Guest → normal - $

-        /home → for normal user, - 60,000 users can be created in Guest mode

-        /home → is for normal user, default home directory

-        /boot → contains bootable files

-        Grub2 → Grant unified boot loader. – latest version. – RHEL 7.0, 8.0

-        Grub → RHEL 6.0

-        LILO → Linux loaded, 5.0, 4.0, 3.0, 2.0.

-        /etc → Configuration files. – Http server configuration files, Shh

-        /bin → binary Executable Commands

-        /Sbin → Super user bin

-        /usr → Unix sharable Resources. – Program files

-        /opt → Option for USR. – Third Party


25/aug/22

-        /Dev → Contain device files

-        /proc → Process. – Contain virtual information. – Background running tasks (Task Manager). – file name “ CPU info” – Properties. - $cat/proc/cpuinfo. - $cat/proc /meminfo -memory information. – Ram, Swap

-        /Run → New Directory – 7.0 version. – Data, Running services, Login ingo last boot information. - /run/media – contain removable media (pendrive).

-        /var → /var/log – login informations

-        /mnt → Empty directory. – to create a mount point for any partition in Linux

-        /lib → Contain Library Files

-        /temp → Junk files

-        /bin → /usr/bin

-        /sbin → /usr/sbin

-        /lib → /usr/lib

-        /lib 64 → /usr /lib64

-        Srv → service

Terminal – Linux

-        Right click – terminal

-        RHEL 6.0, 5.0, 4.0, 3.0, 2.0

o   CTRL + alt + T – terminal

-        RHEL 7.0, 8.0

o   Window key (super key) + terminal (search terminal)

-        Ctrl + Shift + ‘+’ → to zoom text in terminal

-        Ctrl + ‘-‘ → to zoom out.

-        Prompt – Commands exequted in Prompt

-        [student@localhost ~]$   

o   Username, machine name, current home direct, normal user      

-        ~ - tilde

-        […~]$ su – root → [root@localhost~]#

-        [username@hostname ~]$ or #

26/8/22

PWD – print working directory (Absolute path)

-        Present working directory

o   Ex: [student@localhost -]$ pwd

o   /home/sudent

-        Su → switch user

o   [student….]$ su-root

o   Password:

o   [root@localhost -]# pwd

o   /root

o   [root@localhost -]# exit

o   Logout

o   [student@localhost -]$ su root

o   Password:

o   [root@localhost student]# pwd

o   /home/student

o   [root@localhost student]# exit

o   Exit

o   [student@localhost -]$ su-

o   Password

o   Last login: ____________

o   [root@localhost]

Char

-        [student@localhost -]$ char

o   Ctrl + l = char

-        Echo → Print variable & string value

o   […]$ echo hi

§  Hi

o   […]$ echo hello

§  Hello

o   […]$ echo $ HOME

§  /home/student

-        Cd → change directory

o   […]$ cd desktop

o   [… Desktop]$ echo $Home

§  /home/student

o   [… Desktop]$ pwd

§  /home/student/Desktop

o   [student@localhost Desktop]$echo$0

§  Bash

o   […]$echo$BASH

§  /user/bin/bash

o   […]$echo$SHELL

§  /bin/bash

o   […]$sh

§  Sh -4.2$echo$0

§  Sh

§  Sh-4.2$exit

·        Exit

§  […]$echo$0

·        Bash

-        Env - environment

-        [student@localhost Desktop]$

o   Name=imran

-        […]$ echo $NAME

o   Imran

Version Kernell

-        […]$ uname -a

-        […]$ uname -r

Cal – Calendar print

-        […]$ cal

-        Opt – change the behavior

-        $command opt org

o   Cal -y 29 03 2023

o   […]$ cal -y → year calender

o   […]$ cal -y  29 03 2023

o   […]$ cal –help → help guide

o   […]$ cal -1 → month current

o   $ cal - - one

o   $ cal -3 → 3 months calendar

o   $ cal -s → Sunday as first day of week

o   $cal -m → Monday as the first day of week

o   $cal -j → day’s count in year

o   $ cal -v → cal command version

o   $ cal -h → help

o   $ cal -j -m, $cal -jm

o   $ date →  system date

o   $ date + %T → print’s only time

o   $ date + %B → month

o   $ date - -help → help option

o   $date -s “yyyy-mm-dd hh:mm:ss”

-          -s → set

-        Shift + Insert → select text & command


27/8/22

#timedatectl

-        Only  in 7.0 version and more

-        #Timedatectl set-time “2023-01-01 11:22:44”

o   (time changed)

-         #Timedatectl list-timezones

o   List of time zones

o   ‘Q’- key to exit

-        #timedatectl set – timezone “Africa/lagos”

o   Change time zone

-        #timedatectl set-timezone “Asia/Kolkata”

-        #timedatectl set-ntp true

-        $tty – (Teletypewriter) prints terminal number

-        $su- 

-        #timedatectl - - help

$ id → print the identification of user

-        $ id student

-        $ id root

-        $ id ul

o   No user found

-        $ whoami → login user name

-        $ su –

-        $ who am i

-        $ who

-        $ w -f → user’s list

-        $ history

$ cat → concatenation

o   To merge files

-        $ cat > file1 → to create a file

o   Hello

o   Ctrl + D → to save file context

-        $ cat >> file1 → to append the file

o   How

o   Ctrl + D → to save the file

-        $ cat < file1 → to print the file

o   Hello

o   How

-        $ cat file → to print to file

-        $ cat > file2

o   Hi

o   Ctrl + D – Save

-        $ ls – l →  list out file names

o   file1

o   file2

-        $ cat file1 file2>file3

o   $ ls – l

o   $ cat file 3 → print file context

-        $ cd Desktop

-        $ PWD

-        $ cat<file1 – print file context

-        $touch – change file timestamps

-        $touch f1 f2 f3 f4 (f1, f2, f3, f4 are the created file names)

-        $touch k{1…4} → to create file k1, k2, k3, k4

-        $touch-d “yyyy-mm-dd hh:mm:ss” – file name

-        $touch-d “2022-01-01 11:22:44” file1

29/8/22

MKDIR – make directory

-        $mkdir dir1 dir2 dir3 dir4

-        $mkdir d{1..4}

-        $mkdir -p li/l2/l3/l4 → (parent & child directory)

-        ls -R l1

-        $tree l1 → works only in 8.0 version

-        $mkdir -p NIT/{linux/{Rhcsa, Rhce}, Windows/{mcsa, mcsc}, oracle/{sql, plsql}}

-        $ ls -R NIT

-        $ tree NIT

$ cp → copy command

-        $ cp file1 file2

-        $ cat file2

-        $ cp file1 new1 → new file creation

-        $ cp file1 dir1

-        $ cd dir1

-        $ ls -l

-        $ ls -l dir1

-        $cp -rvf dir1 dir2

o   Copy directory to another directory

§  - rvf → move force fully -r   vf

o   $ cd (cd..) (cd../..) (cd ~)

$ pswd

$ mv → (move or cut paste)

·        It is used to rename file

·        $ mv file1 file2

·        $ mv file2 new2 → file2 becomes new2

·        $ mv new2 dir2

·        $ mv dir2 dir4

·        $ mv dir3 demo → change directory name – rename

$ rm – to delete files

·        Rm file3

·        Rm o* → delete all ‘o’ named files

§  ‘ * ‘ → Wild card character

§  rm – remove

·        run f*

·        $ rmdir dir1 → Empty the directory first

·        $ rmdir demo

·        $ rm -rvf dir1 → delete forcefully ‘r’ is mandatory option

·        $ rm -rvf* → delete all directories

30/8/22

·        ‘-‘ = normal file

·        ‘d’ = directory

·        ‘c’ = character file (keyboard, mouse)

·        ‘b’ = block file (HDD, pen drive, DvD, CD)

·        ‘l’ = link files

·        $ ls -l

o   ‘d'rwx rwxr → directory

o   ‘-‘rw -rw -r-- → normal file

·        $ div

o   ‘c’rw – rw – rw → character file

·        $ ls – l |grep ^b

·        ‘b’rw – rw-- → block file

$ cd/

·        $ ls – l

·        ‘l’rwr rwr → link file

$ file ‘file name’ → to know the file type

·        $ file dir1

·        $ file file1

·        $ file /dev/sda

·        $ file /etc/password

Symbolic links: Soft links, Hard links

·        […]$ cat>soft

o   This is a soft link

o   $ ls – l

o   $ cd Desktop

o   $ln – s/ home/student/soft

o   $ ls – l

o   $ cat s1

§  This is a soft link

o   $ cat >> s1

§  This is a linux class

o   $ cat s1

o   $ ls -l

·        du – h → Disk Usage

o   h – human readable file

o   $ du – h s1

·        $ inode → identification number contain properties of the file apart from file

·        $ ls – i s1 → inode number of s1

·        $ ls – i /home/student/soft

·        $ rm – rf /home /student /soft

o   $cat s1

o   $ cat > soft

o   $ cd Desktop

o   $ cat s1

Hard Link

·        $ cd

·        $ pwd

·        $ cat > hard

·        $ cat hard

·        $ cd Desktop

·        $ pwd

·        $ ln /home/student/hard h1

·        $ cat h1

·        $ cat > h1

 

·        $ cat /home/student/hard

·        $ du – h h1

·        $ du – h /home /student /hard

·        $ ls – i h1

·        $ ls – i /home/student/hard

·        $ rm -rf /home/student/hard

·        $ cat h1

 

·        $ ls → list

·        $ ls - l → long list

·        $ l l → long list

·        $ ls – al → all including hidden files

 

·        $ touch .l1 → hidden file

·        $ ls – l

·        $ mkdir .dl  → hidden directories

 

·        $ ls – l f* - finding files with starting letter ‘f’.

·        $ ls – l i*

·        $ ls – l [FI]*

·        $ ls  - l file1 → file details

·        $ ls – ld dir* → directories

o   $ ls – ld d*

·        $ touch cat bat mat fat hat rat tat

o   $ ls – l *at

o   $ ls – l ?at

·        $ ls – l ?? → two character files

o   $ ls – l ???

o   $ ls – l ????

o   $ ls – l [a – g]*

·        $ touch abcd

o   ls – l [a-c]*

·        $ ls – l+r

·        $ ls – l [a-c]* [1-10]*

§  l – long

§  t – time

§  r – reverse

§  R – recursive

2/9/22

·        GUIE – Graphical User Interface Editor

o   $ gedit

o   $ gvim → installation needed

·        CLI Editors

o   $vi → visual display editor (rhel 6)

o   $ vim → visual display editor improve (rhel 7)

    •        VIM - Vi IMproved
    •        version 7.4.160 by Bram Moolenaar et al. Modified by <bugzilla@redhat.com>. Vim is open source and freely distributable.
    •        <:q> - to exit
    •        <:help> or <f1> for on-line help
    •        <:help version7> - for version info

·        Command prompt

o   Rhel 7.0

§  Ctrl + Alt + F2

§  Ctrl + Alt + F2

·        Cli to Gui

o   Rhel 8.0

§  Ctrl + Alt + F3

§  Ctrl + Alt + F2

·        $ vi file1

·        # vi /etc /passwd

·        # vim /etc /passwd

·        Vim file

o   i – key

§  command

·        v

·        v

§  : (:wq)

o   Esc

·        # vim file 1

o   Command – i – insert

§  - - Text - -

§  - Esc – Exit

§  - V – Visual mode

§   :

·         :wq – save file & exit

·         :q – exit

·        :x – save & quit

·        Shortcuts - Insert

o   A – End of the line – insert

o   i  – insert mode

o   I – starting of the line

o   a – next letter

o   o – adding line below curser

o   O – adding line above the curser

o    

o   Command mode options

§  gg – starting of page

§  G – end of the page

§  ‘Number’w – word by word curser forward

§  ‘number’b – word by word curser back

§  w – forward direction

§  b – backward direction

§  ndd – to cut the line

§  p – to paste

§  dd –

§  U – undo – u

§  Ctrl + r – redo

§  nyy – copy

§  x – delete

o   Extended Command mode

§  :wq! – save the context forcefully

§  :x – save & quit

§  / - search the word in the context

§  n – navigate in search result

§  :s/linux/windows – Replace word

§  :s/windows/linux

§  :sc nu – serial number

§  :+ number – number on line

§  :se nonu – remove the line

§  :x – password – vim

·        Vim – o file1 file2

o   Ctrl + w – navigate b/w files

o   :wqa – save & quit all

o   $vim tutor


Filter commands: grep, gels

  •  Login as a root user
  •  grep: global regular expression print
    •  log in as root user to perform grep command
    • to find words form context
    •  to find ‘root’ or any word from file
    • cat /etc/password
    • file contain huge block content

    • # grep /etc/passwd
    • # grep root/etc/passwd

  • Search word from context
    • For with line number
    •  grep -n student/etc/passwd
    • # grep -n (line no) root (search root word) /etc/passwd
    •  # grep student/etc/passwd
    • # grep -n (line no) student (search student word) /etc/passwd
    • # grep -v root /etc/passwd (excluding root word)
    • # grep -i 'hello' (search word) 'xyz' (file name)

    • # grep -nB4 wheel /etc/group
      • B - Before, 4 - lines
    • # grep -nA4 wheel /etc/group
    • #grep -nA6 wheel /etc/group
    • #grep --help
    • # ls -l | grep ^b
      • first letter 'b' files
      • ^ - Caret
    • # ls -l | grep t$
      • last letter from word
    • # ls -l | grep sda
      • 'sda' word search

    • systemctl
    • systemctl | grep sshd

    • less /etc/passwd
      • navigation keys
        • 'D', 'P' - previous page, next page
    •  less command
      • V - vim edit
      • Q - quit
    • pstrhel less
    • in file navigate context of file
    •   ]# less /etc/passwd
    •  ] # cat etc/passwd
    • Using navigation keys in the laptop works, right, left, up, down.
    •  d – next page
    •  b – previous page
    •  few words from file to search from file /bin
    • v – vi editor
    • i – insert mode
    • escape :wq to quit from list
    •  ]# more /etc/passwd
    •  Less or more both are same context of file in % more (53%) use enter / to search the word
    •  ]# head /etc /passwd
    • By default starting 10 lines from context
    •  ]# head -n4 /etc /passwd
    • Any numerical value case gt starting 4 lines
    • ] # tail /etc/passwd → last 10 lines

    • more
    • head /etc/passwd
      • head -n4 /etc/passwd
    • short

    • sed
      • man sed
    • find
      • find/-name
    • ls -i
      • find /- inum 53558113
      • find /- type b
      • find /- size 10k
      • find /-size +10k
      • find /- size -10k
      • find /- user student
      • find /- group student

    •  ] # grep hello file1
      •  Hello

    •   # grep Hello file1
      • Hello case sensitive

    •  cat > file1
      • hello
      •  Hello
      • Hello
      • hello

    •  ] # grep – I HELLO file1
      •  Print → all hello’

    • nB6 – before 6lines it will print
      • ] # grep – nB4 wheel / etc/ group
      • First open the /etc/group
      •  ] $ cat /etc/group

    • #grep – nA4 before 4 lines print
      •  ] # grep – nA4 wheel/etc/group
      •  After 4 lines it will print next

    •  ] # cd/dev
      •  ls – l

    • ] # grep
      • ls – l1 grep ^b
      • ls – l1 grep t$ - last letter from output
      • ls – l1 grep sda – consider as a file name
        • sda
        • sda1
        • sda2
        • sda3

  • 5/9/22
  • man = manual page
    • # man man
    • #man ls
    • #man -k xfs
    • xfs: nothing appropriate
    • #mandb - installation the software
    • #man -k xfs
    • #man xfs -growts
    • #man passwd
    • #man -k passwd
    • #man -t password> passwd.ps
    • evice = ps document viewer
    • #evice passwd.ps
    • #lp passwd.ps -p 2-3 pages
      • non graphical mode

  • File Descriptors or Number channels

  • 6/9/22 - 4:00

  • MSDOS - CLI
  • MSWIN (GUI)
  • UNIX - First cooperate operating system
    • Powerful Operation system
    • Command line Interface (CLI)
  • Linux (CLI & GUI)
    • Open-source OS
    • Unix's Clone
  • Unix like family
    • AIX - IBM
    • HP.UX - HP
  • Text user interface (TUI)
  • .exe - windows
  • .rpm - linux - Red hat package management
  • DBN - Kali linux, Ubuntu 
  • Red Hat - Rhel, Centos, Rocky linux

  • Types of OS - 3:
    • Single user - single tasking - MSDOS
    • Single user - Multi tasking - MSWIN
    • Multi user - Multi tasking - Unix/Linux
  • RHEL - 7.0, 8.0
    • Born Again Shell (BASH)
    • Shell - SH, KSH, CSH.
    • Kernel - Core OS
      • Mono - Linux - uname - a (or) - r
      • Micro - windows - systeminfo, msinfo32
    • Kernel Device info
      •  Multitasking
      • file system info
7/9/22 - 4:00 PM
  • VM care
    • create new virtual machine
      • typical
      • install the O.S later
      • Linux
      • Red hat Enterprises 7 64 bit
      • Virtual
      • Virtual Machine name
        • client
      • Location
      • Minimum disk size = 40 GB
      • Share Virtual disk as a Single file
      • Customize hardware
        • Memory - 2 GB
        • Processor - 1 core
          • 2 core
        • New CD / DvD (SATA)
          • use image file
        • Network Adapter
          • Bridge: Connected
        • Printers - Remove Printer
        • developer.redhat.com
        • 7.9
        • DvD.Iso
8/9/22 - 4:00 PM
  • Localization
  • installation source
  • software selection
    • server with GUI
  • System
    • Installation Destination
      • 40 GB drive
      • configure partitioning
        • manual partitioning
          • new mount point will
            • LVM
            • +
            • /
            • 12 GB
              • Add mount point
            • +
              • /boot
              • 400 mb
            • +
              • swap
              • 10 GB
            • +
              • /home
              • 8 GB
            • Done
              • Accept Changes
    • Network & Host
      • Ethernet
        • on
    • Hostname
      • Done
    • Begin Installation
      • Root user
      • user account (normal user)














20/9/22
  • File Decription 
    • to manage the open files
        • file 4                    Kernal
        •                            0 - stdin <             - Keyboard
        •                            1 - stdout >>>       - monitor
        •                            2 - stderr 2>          - monitor

    • #ls -l > /home/student /Desktop /file1
        • save data in file
    • #cat /home/student/Desktop/file1
    • #ln -l 2> /home/student/Desktop/file2
                        • 2> = error redirector
    • #ls -al
    • #ls -al >> /home/student/Desktop/file1
    • #file /-name file1
    • #file /-name file
    • #find /- type b
    • #find /-type b2> /dev/null
          • error free output

    • #find /-type b
    • #find /- type b > /home/student/Desktop/f1 2> /home/student/fi2

    • #find /-name file2
    • #find /-name file2 &> /home/student/Desktop/outfile

    • #find/-type b
    • #find/-type b &>> /home/student/Desktop/outfile

              • &>> - appending the output & error
  • User & Group Management System:
    • User Management:
      • #Useradd
        • to create a user
                    • users
                      • root
                      • system
                      • normal
      • #usermod
        • to modify a user
      • #userdel
        • to delete a user
      • #passwd
        • to assign a password for user.
    • username, passwd, uid, gid, comments, home-dir, shell
      • root, x, 0, 0, root, /root, /bin/bash
      • system user - apache, vsftpd
        • apache, x, 1-499 RHEL 6.0, apache, /var/www/html/sbin/nologin
        • vsftpd, x, 1-999 RHEL 7.0, 8.0, 1-999 , vsftpd, /var/ftp/pub/sbin/nologin
    • Normal User
      • student, x, 500 - 60,000 RHEL 6.0, 500 - 60,000 RHEL 6.0, student, /home/student, /bin/bash
      • U1, x, 1000 - 60,000 RHEL 7.0, 8.0, 1000 - 60,000 RHEL 7.0, 8.0.
    • /etc/passwd 
      • contain local users properties
    • /etc/shadow
      • file contain local user passwords
                      • c/win/sys32/sam/
                        • file for win passwords
    • -l
      • modify command user with user mod
    • -u
      • modify the user id & user mod
    • -g
      • modify group id
    • - c
      • to assign the comments
    • -d, -m
      • modify home directory
    • -s
      • to change the shall environment
    • -L 
      • to lock the user
    • - U
      • to unlock the user


21/09/22
  • #useradd u1
  • #id u1
  • #less /etc/passwd
  • #tail /etc/passwd

  • #useradd u2 -u 2002 -c Hr -d /home/dir2 
    • -s /sbin/nologin
      • - c = assign comments
      • - u = assign user id
      • - g = print group id
      • - d = modify the home directory
      • - s = to modify the shell environment
    • #usermod -m -d (-md)
      • to modify user directory
    • #usermod -l "test - user" "u2"
    •  -----" user nam-nw" "user name old"
      • change user name
    • # usermod -m -d /home/test-user test-user
      • change directory
    • # tail /etc/passwd
  • use the password to the user
    • #passwd u1
      • to create a password

                      • ctrl + c - terminate command
    • #usermod -L u1
      • lock user
    • $su - u1
      • pass:_____
      • authetication failure
    • # passwd -s u1
    • #usermod -U u1 (unlock)
    • #passwd -s u1
    • #tail /etc/passwd
    • #userdel test-user
      • to delete the user
    • #tail /etc/passwd

    • #userdel -r u1
      • to delete the user & directory
  • user passwd management
    • #tail etc/shadow
  • username, passwd, date, min-age, max-age, passwd-ex-wr, passwd-ex-date, acc-ex-date, black.
  • #change: to modify the password properties
    • #change -l il
      • details of the user password
    • #change il
      • min: 2, 30, 1, 4, 1
      • expiry: 2022 - 10 - 24
    • #tail /etc/shadow
    • #chage -E 2022 - 10 -22 il
      • change expiry date
    • #chage - w 2 il
    • #chage -l il
    • #chage -h (help)
    • #chage -d o il
    • #chage -l il
    • # su -il
    • $ chage -l il

22/09/22
  • Group Management
    • #groupadd
      • to create a group
    • #groupmod
      • to modify a group
    • #groupdel
      • to delete a group
    • #gpasswd
      • to assign the passwd to the group
  • Group name, Passwd, gid
    • redhat , x, 1001
  • /etc/gshadow 
    • passwd properties of group
  • /etc/group
    • local group properties
  • #groupadd redhat
    • #tail /etc/group
  • #groupadd -g 2002 rhel
    • #tail /etc/group
  • #groupmod -n linux rhel
    • tail /etc/group
  • #groupmod -og 2002 redhat
      • same uid of group
    • #tail /etc/group
  • #groupmod -p "1234" linux
    • #tail /etc/gshadow
  • groupname, password, group admin
    • #gpasswd linu
      • tail /etc/gshadow
  • #gpasswd -r linux
      • to remove password
    • #tail /etc/gshadow
  • groupdel linux
      • to delete a group
    • #tail /etc/group
  • groupdel redhat
    • #tail /etc/group
  • #useradd u1
  • #useradd u2
  • #useradd u3
  • #useradd u4
  • #groupadd redhat

  • #usermod -aG redhat u1
  • # tail /etc/group
    • adding user to group
  • #id u1

  • #usermod -aG redhat u2
      • a = append
      • G = secondary group id
      • g =  primary group id
    • # tail /etc/group
  • #gpasswd -m u3, u4 redhat
    • #tail etc/group
      • to add multiple users in group by overwriting the present group users
  • #gpasswd - A u1 redhat
    • #tail /etc/gshadow
      • to make u1 the group admin
  • #su - u1
    • $ usermod - aG redhat u2 - denied
    • $ gpasswd - a u2 redhat
    • $ exit
  • #tail /etc/gshadow

  • #gpasswd - d u3 redhat
    • to remove a user
  • #vim /etc/login.defs
    • to modify the system defaults of users & groups
      • password max days - 99
      • password min days - 2
      • password min length - 5
      • password  age - 4

      • UID_Min 4000

      • system accounts
      • system UID Max - 201
      • system UID Max - 999

      • #useradd l1
      • #tail /etc/passwd

      • #tail /etc/shadow

  • #lid -g redhat
    • to know group details
  • #lid -g redhat | we -l
    • to know no.of users
  • #wc /etc/passwd
    • word, charector counts
      • wc -c /etc/passwd
      • wc -w /etc/passwd

23/09/22

  • $ sudo - su
                          • snapshot - old OS
  • #visudo
      • sudo - superuser do
      • :97 - to end up in the line 97
    • student ALL = (ALL) ALL
    • :wq - save & quit
  • $sudo su -

  • $sudo useradd u1
  • $tail /etc/passwd

  • #visudo
    • :97
    • student ALL = (ALL) /sbin/useradd, /sbin/usermod, /sbin/groupadd, /sbin/groupmod, /sbin/fdisk
    • limited access to student user
    • $ sudo useradd i2

    • #which fdisk
      • to know the command place (or) located
    • #which useradd

    • #whichis fdisk

    • #visudo
      • :97
      • Edit: student ALL=(ALL) ALL !/sbin/userdel 
        • to not give Delete User acces to the user
    • $sudo userdel -r l1
        •  no accepted command
    • #visudo
    • #storage
      • remove "#" hash
      • # student All = (All) storage
        • student All = (All) storage
    • #visudo
      • cmnd - Alias COMM = /sbin/useradd, /sbin/usermod, /sbin/fdisk, /sbin/groupadd
      • student ALL = (ALL) COMM
    • $ sudo useradd i3
    • $ sudo useradd i4
    • $ sudo userdel

    • #visudo
      • %wheel ALL=(ALL) ALL
      • %redhat ALL =(ALL) NOPASSWD:ALL
        • redhat = groupname
        • giving group permission 
    • $ su - i2
    • $ sudo userdel -r u1
    • $ tail /etc/passwd
    • # %wheel ALL (ALL)
    • # usermod -aG wheel i4
    • # passwd i4

    • #useradd rani
    • # tail/etc/passwd

    • #vim /etc/sudoer.d/rani
      • rani ALL=(ALL) NOPASSWD:ALL
      • :wq
                    • sudoer.d = sudoesr directory
    • #su - rani
    • #fdisk


24/09/22
  • #mkdir pepsi
  • #ls - ld pepsi - directory details
    • drwx r-x r-x 2 root root
      • rwx - permittion for user root
      • r-x - group owner root
      • r-x - other user's permissions
      • r - 4 - read
      • w - 2 - write
      • x - 1 - execute
  • # umask 0022
  • $umask 0002
  • umask = user file creation mask
    •       - user - group - other
    •       -  7     -    7     -    7
    • 0    -  0     -    2    -     2
    • 0    -  7 (rwd) - 5(r-x) - 5(r-x)
  • #mkdir dir1
    • /s -|d dir1
  • #su - 
  • # umask
  • # umask 0020
  • # umask

  • #mkdir redbull
  • #ls - l
    • closing terminal will change the umask value
  • #su
  • #umask
  • #touch file1
  • #ls - l file1
  • #ls - ld pepsi
  • file umask value
    •          U  -      G        -    O
    •           6          6              6
    • 0        0          2              2
    • 0   -   6(rw-)  4(r-1)      4(r-)
  • #touch file1
  • #ls -l file1
    • -rw -r - r --1 root root 0 sep 24 16:50 file1
  • # ls - ld pepsi
    • drwx r-x r-x 2 root root 6 sep 24 16:18 pepsi
  • # vim /etc/bashrc  (normal user umask user)
    • 002 = 000 (1) value
  • $ umask
    • 0000
  • # su - 
  • # vim /etc/profile
    • 020 (2) value
  • #source /etc/profile
  • #umask
    • 0020
  • #vim /etc/login.defs

  • #useraddd u1
  • #cd /home/
  • ls - l

  • #vim /etc/login.defs
    • umask = 070 
      • to give permissions to create other user permission to "u2" user

  • #useradd u2
  • #ls -l

  • #cd

  • #chmod 
    • to change the existing files umask
  • #chmod u+, -, = rwx, g+, -, =rwx, o+, -, =rwx filename

  • #chmod u-x, g+w, o=r pepsi
  • #ls - l
  • # chmod - R u-x

  • #chmod -R a+, -, =rwx filename
    • #chmod -R u-x, g+w, o=r pepsi
    • #chmod a = rwx pepsi
    • #ls -ld pepsi
  • #chmod -R 755 filename
                        • df - th
                        • yum install httpd -y
  • Naming standards


26/9/22

  • #chown 
      • to change the ownership
    • #chown ' username ' ' directory ' or ' filename '
  • #mkdir pepsi
    • #ls - ld pepsi
    • #chown student pepsi
    • #ls - ld pepsi

    • #chown -R student pepsi
        • to change ownership with recursive (means giving ownership of every directory & files ownership in the directory)
    • #chgrp - group name file name
      • #chgrp - change group ownership
      • #useradd u1
      • #useradd u2
      • #groupadd redhat
      • #usermod -aG redhat u1
      • #usermod -aG redhat u2
      • #id u1
      • #id u2
      • #chgrp redhat pepsi
      • #ls -ld pepsi
        • drw r-x r-x, 2 student redhat 6 sep 26 16:24 pepsi
      • #cd pepsi
      • #su u1
      • $touch abcd
      • $exit
      • #cd
      • #chmod g+w pepsi
      • #ls - ld pepsi
      • #cd pepsi
      • #su u1
      • $touch xyz
      • $ls -l
      • $exit
                    • #chown student:redhat redbull
    • #mkdir redbull
      • ls - ld redbull


  • special permissions:
      • s - special & executive permittion
      • S - 
      • S s x 0022
    • User: 
      • setuid
        • suid
      • #chmod u+s filename (or) #chmod 4755 filename (only for executable files)
    • Group:
      • setgid
        • sgid
      • #chmod g + s dir name (or) #chmod 2775 dir name
    • other users (sticky permissions)
      • #chmod o + t dirname (or) #chmod 1757 dir name (only for dirs)

    • #fdisk - l (normal user cannot access it)
    • $ su - 
    • # which fdisk
    • # ls - l /sbin/fdisk
    • # chmod u + s /sbin/fdisk


    • $ ls - l /usr/bin/passwd
    • $ su - 

    • #mkdir 7up
    • #ls -ld 7up
    • #useradd il
    • #useradd i2
    • #groupadd rhel
    • #usermod -aG rhel il
    • #usermod -aG rhel i2
    • #id i1
    • #id i2
    • #chgrp rhel 7up

27/9/22

  • ACL: Access Control List
      • user's - root directory
      • group - user1, user2
      • root - Directory
    • #getfacl filename
      • to list the acls
    • #setfacl -m u (or) user: 'username' :rwx,g (or) group: 'groupname' :rwx, o::r -- filename


      • #useradd Jani
      • #useradd Das
      • #useradd Mahesh
      • #useradd Rani
      • #useradd Vani
      • #groupadd NIT
      • #usermod -aG NIT Rani
      • #usermod -aG NIT Vani
      • #mkdir oppo
      • #ls - ld oppo
        • drwxr-xr-x. 2 root root 6 sep 27 16:31 oppo
          • . (or) +, acl function
          • 2 - directory count
      • #getfacl oppo
      • #setfacl -m u:jani:rwx, g:NIT:rwx, o::r-- oppo
      • #ls - ld oppo
        • drwx rwx r-- + 2 root root
      • #getfacl oppo

      • #cd oppo
      • #su Jani
      • $touch j1
      • $ls -l
      • #su Rani
      • $touch R1
      • $ls -l
      • $exit
      • #su Vani
      • $touch v1
      • $ls - l1
      • $exit



      • #getfacl oppo
        • -
        • -
        • -
        • mask::rwx
        • -
      • #setfacl -m m::r -- oppo
      • #getfacl oppo
        • to restrict user's & groups to access this directory
                            • m = mask
      • #cd oppo
      • #su Rani
      • $ touch r2
      • $ exit
      • # cd
      • # setfacl -m m::rwx oppo
      • # getfacl oppo

      • #cd oppo
      • #ls -l
      • #mkdir dir1
      • #ls -l
    • Default ACL Permittion:
      • #setfacl -R -m m::r -filename
      • #setfacl -m d:u:username :rwx oppo

      • #cd
      • #setfacl -m d:u:Das:rwx oppo
      • #getfacl oppo
      • #cd oppo
      • #su Das
      • $touch D1
        • denied
      • $mkdir dir2
      • $ls - l

      • $getfacl dir2
      • $exit
      • #cd
      • #cd oppo/dir2
      • #su Das
      • $touch l1
      • $ls -l
      • $pwd

      • #getfacl oppo
      • #mkdir redmi
      • #getfacl redmi
      • #ls -ld redmi

      • #getfacl oppo | setfacl -- set - file = - redmi
                  • copy rules of one directory to another directory
      • #getfacl redmi
      • #ls -ld redmi

      • #setfacl -x u:Jani oppo
            • to remove permissions
      • #getfacl oppo

      • #setfacl -x g: NIT oppo
      • #getfacl oppo

      • #setfacl -b oppo
          • -b = to remove acl from oppo directory
      • #getfacl oppo




28/09/22
  • Process mangement:
    • a process is a running instance of a launched, executable program
    • Rhel 7.0, 8.0 - SystemD - PID - 1
    • Rhel 6.0, 5.0, 4.0, 3.0, 2.0 initd - PID - 1

    • #ls - l
    • #gedit file1
      • [1]+ stopped - stop foreground task
    • #jobs 
      • to know status of other working directories
    • #fg %1 
      • foreground task
                      • ctrl + c - to terinated gidit
                      • ctrl + z - to stopped gidit
    • Sleeping command
        • S - process intruptable
        • D - process unintruptable
        • K - process killable
      • #sleep 10000
          • ctrl + z
          • stopped
        • #jobs
        • #bg %1
        • #jobs
        • #ls - l
    • #gedit file1 &
        • & - to run the process in the background
      • #jobs
      • #fg %2
      • #jobs

29/9/22
  • S - Intruptable process
  • T - process stop
  • C - zomic
            • + - present process
  • #ps aux | less
  • #ps aux | less
  • #jobs
  • #fg %1
      • ctrl + z 
        • to stop
  • jobs
    • #fg %2
  • #ps ef
  • #ps if
  • #kill -l  (signal)
  • #jobs
    • [1]+
  • #kill -18 %1  (start)
  • #jobs
  • #kill -19 3909   (stop)
  • #kill -15 3909
  • #gedit file1 &

  • #jobs
  • #kill -1 %1
  • #jobs
  • #systemctl status sshd.service

  • $ipaddr

  • #systemctl restart network

  • #ip addr show eno16777736

  • #exit

  • $ssh root@192.168.1.17
    • #exit
    • $su - root
    • #exit
    • #vim /etc/ssh/sshd - config
      • #permit Root login - no
    • #exit
    • $ssh root@192.168.1.17
    • #exit
    • $su -
    • #systemctl status sshd.service
    • #kill -1 1967
    • #exit
    • $ssh root@192.168.1.17
    • $su-
    • #jobs
    • #sleep 10000 &
    • #jobs
    • #kill -9 %1
    • #jobs
    • #sleep 10000 &
    • #sleep 20000 &
    • #jobs
    • #killall -19 sleep
      • 19 - stopped
    • #jobs
    • #killall - 18 sleep
      • 18 - running
    • #jobs
    • #killall -15 sleep
      • 15 - terminate

    • #Pkill -t pts/1 -19 sleep
        • pts/1 - terminal number
    • #pkill -t pts/1 -18 sleep

    • D - uniterruptable sleep
    • R - running or runnable
    • S - interruptable sleep
    • T - Stopped
    • t - stopped tracing
    • x - dead
    • < - high priority

  • How to know the CPU load Average?
    • #uptime
  • #lscpu or cat proc/cpuinfo
  • #grep "model name" /proc/cpuinfo
  • #grep "model name" /proc/cpuinfo | wc
  • #grep "model name" /proc/cpuinfo /wc - l

  • #uptime - to know the system load average
30/9/22
  • top - options
  • process
  • 1 to 19 - low priority
  • 0 - Normal priority
  • -1 to -20 - high priority

  • #nice
  • #renice

  • #sleep 20000 &
  • #jobs
  • #ps aux pid, comm
  • #gnome - system - monitor

  • #su
  • #man ps

  • uptime 
    • grep "model name" /proc/cpuinfo 
    • top 
    • ps aux 
    • ps axo pid,comm,nice --sort=nice 
    • ps ao pid,comm,nice --sort=nice 
    • sleep 10000 & 
    • ps ao pid,comm,nice --sort=nice 
    • nice -n 19 gedit file1 & 
    • jobs 
    • ps ao pid,comm,nice --sort=nice 
    • renice -n -20 4394 
    • ps ao pid,comm,nice --sort=nice 
    • ps aux 
    • ps ao pid,comm,nice --sort=nice 
    • renice -n 19 4375 
    • ps aux 
    • ps ao pid,ppid,sid,gid 
    • kill -15 3774 
    • kill -9 3774
    • ps ao sid,ppid,pid
    • ps ao sid,ppid,pid,comm  


1/10/22
  • How to manage System demon & init demon
    • Rhel 6.0 - initd - PID1
    • Rhel 7.0 - systemd - PID1

  • #systemctl
  • #systemctl -l
        • Q - to quit
  • #systemctl --type = service
  • #systemctl --type = target
  • #systemctl status sshd.service
  • #systemctl restart sshd.service
  • #systemctl status sshd.service
  • #systemctl is - active sshd.service
  • #systemctl is - enabled sshd. service
  • #systemctl disable sshd. service
  • #systemctl status sshd
  • #systemctl status sshd.service
  • #systemctl status firewalld.service
  • #systemctl mask firewalld. service
  • #systemctl stop firewalld.service
  • #systemctl status firewalld.service
  • #systemctl unmask firewalld.service
  • #systemctl status firewalld.service






  • systemctl 
    • systemctl --type=service 
    • systemctl --type=service --all 
    • systemctl --all 
    • systemctl 
    • systemctl --type=target 
    • systemctl --type=service 
    • systemctl --type=service --all 
    • systemctl list-unit-files 
    • systemctl | grep sshd 
    • systemctl status sshd.service 
    • systemctl stop sshd.service 
    • systemctl status sshd.service 
    • systemctl start sshd.service 
    • systemctl status sshd.service 
    • systemctl restart sshd.service 
    • systemctl status sshd.service 
    • systemctl reload sshd.service 
    • systemctl status sshd.service 
    • systemctl is-active sshd.service 
    • systemctl is-enabled sshd.service 
    • systemctl stop sshd.service 
    • systemctl status sshd.service 
    • reboot 
    • systemctl status sshd.service 
    • systemctl disable sshd.service 
    • systemctl status sshd.service 
    • reboot 
    • systemctl status sshd 
    • systemctl enable sshd
    • reboot 
    • systemctl status sshd.service 
    • systemctl status firewalld.service 
    • systemctl mask firewalld.service 
    • systemctl status firewalld.service 
    • systemctl stop firewalld.service 
    • systemctl status firewalld.service 
    • systemctl start firewalld.service 
    • reboot
    • systemctl status firewalld.service 
    • systemctl unmask firewalld.service 
    • systemctl status firewalld.service 
    • reboot 
    • systemctl status firewalld.service 
    • systemctl list-dependencies sshd.service 
    • service sshd status 
    • service sshd start 
    • service sshd stop 

3/10/22
  • Packages
    • #rpm -qi tree 
      • to query package info
    • #rpm -qd tree 
      • to query doc to package
    • #rpm -ql tree
      • to query list the package
    • #rpm -qc vsftpd
      • to query the config files
    • #rpm -Uvh vsftpd 
      • to update the package
    • #rpm -e vsftpd
      • to uninstall the package
    • #cd /etc/yum.repos.d/
      • root@localhost packages
    • #ls -l
    • #vim rhel.repo
      • [rhel]
      • name = redhatx64
      • baseurl = 'file://run/media/student/RHEL - 7.0 server.x86_64
      • gpgcheck = 0
      • enable = 1
          • :wq
    • #yum clean all
    • #cd
    • #yum install httpd -y

    • #yum list vsftpd
    • #yum list bind
    • #yum list all
    • #yum list
    • #yum provides
    • #yum search all
    • #yum search all "dns server"

    • #yum group list
    • #yum group install "Development

    • #yum info httpd
    • #yum update httpd* -y
    • #yum history

    • #yum history undo 4 




  • cd /run/media/student/RHEL-7.0\ Server.x86_64/
    •  pwd
    • ls 
    • cd Packages 
    • cd .. 
    • cd Packages 
    • ls -l 
    • tree 
    • ls -l tree-1.6.0-10.el7.x86_64.rpm 
    • rpm -ivh tree-1.6.0-10.el7.x86_64.rpm 
    • tree 
    • rpm -q tree 
    • rpm -q vsftpd
    • rpm -qa 
    • rpm -qa | grep tree 
    • rpm -qd tree 
    • rpm -ql tree 
    • rpm -qi tree 
    • rpm -qc tree 
    • rpm -ivh vsftpd-3.0.2-9.el7.x86_64.rpm 
    • rpm -q vsftpd 
    • rpm -qc vsftpd
    • rpm -Uvh vsftpd-3.0.2-9.el7.x86_64.rpm 
    • tree 
    • rpm -e tree 
    • tree 
    • rpm -q tree 
    • rpm -ivh httpd* 
    • yum repolist all 
    • yum install httpd* 
    • cd /etc/yum.repos.d/
    • ls -l 
    • vim rhel.repo 
    • yum clean all 
    • yum repolist all 
    • yum install httpd* -y 
    • yum list httpd 
    • yum list tree
    • yum list all 
    • yum search all "web server" 
    • yum provides /var/www/html 
    • yum info httpd
    • yum install tree.x86_64 
    • yum install tree.x86_64 -y 
    • yum grouplist 
    • yum groupinstall "Development Tools" -y 
    • yum remove httpd* -y 
    • yum update tree 
    • yum history 
    • yum history undo 5 
    • yum history 






7/10/22
  • Disk Partition theory

8/10/22
  • Disk Partition 
    • command 'm' for help
    • #fdisk -l
    • #fdisk /dev/sda
      • command (m for help): p
      • command: n 
        • to create partition
      • select: p
      • partition number: 3
      • first sector:
      • last sector: +2G
        • 2gb memory
    • command: p

    • command: n
      • partition type:
      • select: p
      • last sector: +2g
      • command: p
      • command: n
    • command: d
      • delete partition
    • command: p
    • command: n
    • select: e

    • command: p
    • command: n
    • command: p
      • print partition table
  • logical driver & Primary Partition
    • command: w
  • #partprobe /dev/sda
  • #kpratx /dev/sda

  • fdisk -l

  • part

  • #mkfs.xfs
  • #mkfs -t xfs /dev/sda3

  • #blkid /dev/sda3

  • #df

  • #cd /mnt
  • #touch abcd xyz file1 file2
  • #mkdir dir {1...4}
  • #ls -l

  • #df -Th
  • #mkdir /home/student/Desktop/dir1
  • #mount /dev/sda3/home/student/desktop/dir1
  • #cd

  • Permanent Mount Point
  • #vim/etc/
    • /dev/sda3    /home/student/
    • Desktop/dir1     xfs
    • defaults             0  0

    • :wq
  • #mount -a
  • #cd /home/student/Desktop

  • #ummount /dev/sda3
  • #vim/etc/

  • partprdx/dev/sda

  • Swap Partition:
    • #free -m
    • #command:p

    • #mkswap /dev/sda3

    • #blkid /dev/sda3
    • #swapon /dev/sda3
    • #free -m
    • #swapon -s
    • #reboot
      • to reboot system
    • #free -m
    • #swapoff /dev/sda3
    • #free
    • #vim /etc/fstab
    • #partprobe /dev/sda



10/10/22
  • LVM 
    • logical volume management
    • #lsblk
      • to know partition details
    • #fdisk /dev/sda
      • :n
      • :t
      • :8e
      • :w (save)
    • #pvcreate
      • Physical Volume Create
    • #vgcreate
      • Volume Create
    • #pvs
    • #pvdisplay /dev/sda3
    • #vgs
    • #vgdisplay

    • #lvcreate -L 400m -n my_lv my_vg
    • #lvs
    • #lvdisplay
    • #lvscan
    • #mkfs -t ext4 /dev/my-vg
    • #blkid /dev/my-vg/my-lv
    • #mount/dev/my-vg/my-lv/mnt
    • #mount
    • #df-Th
    • #cd /mnt/
    • #touch abcd xyz file1 file2
    • #mkdir

  • Permanent Mount Point
    • #df -Th
    • #mkdir /home/student/Desktop/dir1
    • #vim/etc/fstab/dev/mg-vg/my-lv/home/student/Desktop/dir1
    • #mount -a
  • How to increase size of a LVM disk
    • #lvextend -L +200M /dev/my-vg/my-lv
    • #df-Th
    • #resize 2fs /dev/my-vg/my-lv
    • #df-Th
    • #lvscan
  • To Decrease size of Lvm disk
    • #unmount /dev/my-vg/my-lv
    • #e2fsck -f /dev/my-vg/my-lv/400m
    • #lvreduce -L -200m /dev/my-vg/mg-lv
    • #mount -a
  • #
  • #vgextend my-vg /dev/sda5
  • #vgs
  • #pvs

  • Transfer file
    • #pvmove /dev/sda3   /dev/sda5
    • #pvs
  • Remove vg
    • #vgreduce my-vg/dev/sda3
  • Delete LVM
    • #lvremove /dev/my-vg/my-lv
    • #unmount /dev/my-vg/my-lv
    • #vim /etc/fstab
    • #mount -a
    • #lv remove /dev/my-vg/
  • Create vg called 'red hat' with 16PE and create LV called fedora with 15LE assign exth file system mount on/test dir
      • 16 * 15 = 240
    • #fdisk /dev/sda
    • :n
    • :p
11/10/22
  • Network

  • NIC
  • MAC 
    • Media Access Control
    • 'getmac' - command
    • 'ipconfig /all' - command

  • Ethernet & Internet
    • stp or utp cable
    • cat6 cable
    • fiber cable
    • radio frequency
    • infrared
  • HUB
    • it is not an intelligent device
    • it will work with bits (0,1)
    • use broadcast for communication
    • it will share the Bandwidth
    • it is having half duplex communication
  • Switches
    • it is an intelligent device
    • it maintains the mac address
    • using floating & unicast for communication
    • Each port of the switch has fixed bandwidth
    • having full duplex communication
  • Router
    • enable communication between two different devices

Comments

Popular posts from this blog

Daily Motivation | Quotes

Google Digital Unlocked | Free Online Courses by Google | Free Certification