10-10-2020

https://youtu.be/30Wsc3zCWNk

 

 

 

 

 

Edge Data Centers: What Service Providers Should Consider First

 

CLI – Command Line Interface

CLI – Command Line Interface

 

 

What is root

 

root – Administrator – Super user

 

-          Root user has full access

-          Root user cannot be renamed

-          Never share the password with anybody

-          Don’t put in email, chats or text messages, don’t share it

 

 

/root

 

-          Root user home directory or

-          When root user logs in to system this is his landing space

 

/

 

-          Root directory

-          This is the topmost directory

 

 

 

File = file

Directory = Folder

 

For Linux a file and a directory is also file

 

pwd

pwd

 

-          Print working directory

-          Present working directory

 

[root@localhost ~]# pwd

/root

 

 

clear

clear

 

-          Clears the screen

 

input

Input

 

[root@localhost ~]# pwd     < ---input command to OS

 

 

output

Output

 

/root                         < --- Response from OS

 

cd

cd

 

-          allows you to change the directory

 

[root@localhost ~]# cd /

[root@localhost /]#

 

 

 

cd

 

-          Simply type cd and hit enter

-          You jump back to home directory

 

[root@localhost /]# cd

[root@localhost ~]#

 

ls

ls

 

-          this command list the content of the pwd directory

 

[root@localhost ~]# ls

anaconda-ks.cfg

 

ls –l

 

-          long list switch with ls command

-          it provides the details of the list contents

 

 

 

[root@localhost ~]# ls -l

total 4

-rw-------. 1 root root 1407 Oct  4 16:07 anaconda-ks.cfg

 

Ls –a

-          shows you the list of files as well as hidden files/ folder

-          hidden file or folder starts with . (period)

 

.   anaconda-ks.cfg  .bash_logout   .bashrc  .tcshrc

..  .bash_history    .bash_profile  .cshrc

 

ls –la

 

-          this combination of command provides the long list with hidden files

 

 

[root@localhost ~]# ls -la

total 28

dr-xr-x---.  2 root root  135 Oct  4 16:57 .

dr-xr-xr-x. 17 root root  224 Oct  4 15:50 ..

-rw-------.  1 root root 1407 Oct  4 16:07 anaconda-ks.cfg

-rw-------.  1 root root  209 Oct  4 17:54 .bash_history

-rw-r--r--.  1 root root   18 Dec 28  2013 .bash_logout

-rw-r--r--.  1 root root  176 Dec 28  2013 .bash_profile

-rw-r--r--.  1 root root  176 Dec 28  2013 .bashrc

-rw-r--r--.  1 root root  100 Dec 28  2013 .cshrc

-rw-r--r--.  1 root root  129 Dec 28  2013 .tcshrc

 

history

history

 

-          displays the history of commands you been using

 

[root@localhost ~]# history

    1  ip a

    2  cd /etc/sysconfig/network-scripts/

    3  ls

    4  vi ifcfg-enp0s3

    5  clear

    6  ls

    7  vi ifcfg-enp0s3

    8  clear

    9  ls

   10  vi ifcfg-enp0s8

   11  vi ifcfg-enp0s9

   12  vi ifcfg-enp0s3

   13  clear

   14  ls

   15  ls -l

   16  clear

   17  init 6

   18  ip a

   19  init 0

   20  ip a

   21  whoami

   22  ls

   23  lsblk

   24  init 0

   25  clear

   26  pwd

   27  clear

   28  pwd

   29  clear

   30  pwd

   31  cd /

   32  cd

   33  ls

   34  ls -l

   35  ls -a

   36  clear

   37  ls -a

   38  ls -la

   39  clear

   40  history

 

!34

 

-          run the specific command number from the history

 

[root@localhost ~]# !34

ls -l

total 4

-rw-------. 1 root root 1407 Oct  4 16:07 anaconda-ks.cfg

 

Multiple Commands

Run multiple command

;

 

[root@localhost ~]# ls -la;pwd;cd /

 

touch

touch

 

-          it create a file for you

 

[root@localhost ~]# touch file1

[root@localhost ~]# ls

anaconda-ks.cfg  file1

[root@localhost ~]# ls -l

total 4

-rw-r--r--. 1 root root    0 Oct 10 16:20 file1   < --- creates file

 

touch file2 file3 file4

 

-          Create multiple files

 

[root@localhost ~]# touch file2 file3 file4

[root@localhost ~]# ls

anaconda-ks.cfg  file1  file2  file3  file4

[root@localhost ~]# ls -l

total 4

-rw-------. 1 root root 1407 Oct  4 16:07 anaconda-ks.cfg

-rw-r--r--. 1 root root    0 Oct 10 16:20 file1

-rw-r--r--. 1 root root    0 Oct 10 16:26 file2

-rw-r--r--. 1 root root    0 Oct 10 16:26 file3

-rw-r--r--. 1 root root    0 Oct 10 16:26 file4

 

touch .file5

 

-          Creates a hidden file

 

[root@localhost ~]# ls –la

-rw-r--r--.  1 root root    0 Oct 10 16:27 .file5             < --- Hidden file is created

 

mkdir

mkdir folder1

 

-          Creates the folder with specified name in pwd

 

 

[root@localhost ~]# mkdir folder1

 

[root@localhost ~]# ls –l

 

drwxr-xr-x. 2 root root    6 Oct 10 16:29 folder1

 

mkdir folder2 folder3 folder4

 

-          Creates multiple folders

-           

 

drwxr-xr-x. 2 root root    6 Oct 10 16:29 folder1

drwxr-xr-x. 2 root root    6 Oct 10 16:33 folder2

drwxr-xr-x. 2 root root    6 Oct 10 16:33 folder3

drwxr-xr-x. 2 root root    6 Oct 10 16:33 folder4

 

[root@localhost ~]# yum install tree -y

mkdir -p redhat/whitehat/blackhat

 

-          Create directory inside directory

-          -p means parent directory

-          This will also check the existing directory, it ignores it its already there

 

 

[root@localhost ~]# mkdir -p redhat/whitehat/blackhat

[root@localhost ~]# tree

.

── anaconda-ks.cfg

── file1

── file2

── file3

── file4

── folder1

── folder2

── folder3

── folder4

└── redhat

    └── whitehat

        └── blackhat

 

7 directories, 5 files

 

Changing directory using cd

 

-          Changes the directory

 

[root@localhost ~]# cd redhat/whitehat/blackhat/

 

Tab key auto completes the file or directory

 

[root@localhost blackhat]# pwd

/root/redhat/whitehat/blackhat

 

cd

 

[root@localhost blackhat]# cd

[root@localhost ~]# pwd

/root                                              < ---takes you back to home directory

 

 

Jump to previous working directory

 

 

[root@localhost ~]# cd -

/root/redhat/whitehat/blackhat            < ---Takes you back to previous working directory

 

 

[root@localhost blackhat]# ls -la

total 0

drwxr-xr-x. 2 root root  6 Oct 10 16:40 .          < --- Single dot is link to its self

 

drwxr-xr-x. 3 root root 22 Oct 10 16:40 ..       < --- two dots are link to parent directory

 

 

.

-          This is representation of present working directory

-          It is a link to current working directory

-          Hidden

 

 

 

..

-          This the representation of parent directory

-          This will take you back one level up directory

-          Hidden

 

cd ..

 

[root@localhost ~]# cd redhat/whitehat/blackhat/

/root/redhat/whitehat/blackhat

 

[root@localhost blackhat]# cd ..

[root@localhost whitehat]# pwd

/root/redhat/whitehat

 

[root@localhost whitehat]# cd ..

[root@localhost redhat]# pwd

/root/redhat

 

 

[root@localhost redhat]# cd whitehat/blackhat/

[root@localhost blackhat]# pwd

/root/redhat/whitehat/blackhat

 

[root@localhost blackhat]# cd ../../..

[root@localhost ~]# pwd

/root

 

Relative Path

Relative path

 

 

└── redhat

    └── whitehat

        └── blackhat

 

 

[root@localhost ~]# cd redhat/whitehat/blackhat/     < ---used relative to go in the directory ‘blackhat’

[root@localhost blackhat]# pwd

/root/redhat/whitehat/blackhat

 

 

 

Absolute Path

Absolute path

 

/root/redhat/whitehat/blackhat

[root@localhost blackhat]# cd /root/redhat

[root@localhost redhat]# pwd

/root/redhat

 

pwd provides you absolute path of the present working directory

 

 

remove

rm

 

-          Removes the file

 

[root@localhost ~]# rm anaconda-ks.cfg

rm: remove regular file ‘anaconda-ks.cfg’? y

 

rm –rf

 

-          Removes file forcefully without confirmation

 

[root@localhost ~]# rm -rf file1

 

Wild Card *

Wild card

 

[root@localhost ~]# rm -rf fi*

[root@localhost ~]# ls

folder1  folder2  folder3  folder4  redhat

[root@localhost ~]# rm -rf fo*

[root@localhost ~]# ls

Redhat

 

Removing folder

 

[root@localhost ~]# rm folder1

rm: cannot remove ‘folder1’: Is a directory   < --- Folder has delete protection

 

 

[root@localhost ~]# rm -rf folder1/

[root@localhost ~]# ls

 

-rf – recursively and forcefully

 

Remove hidden files and folders

 

 

[root@localhost ~]# ls -a

.   .bash_history  .bash_profile  .cshrc  .tcshrc

..  .bash_logout   .bashrc        .file5

 

[root@localhost ~]# rm -rf .*

rm: refusing to remove ‘.’ or ‘..’ directory: skipping ‘.’          < ---this will not be removed

rm: refusing to remove ‘.’ or ‘..’ directory: skipping ‘..’         < ---this will not be removed

[root@localhost ~]# ls -a

.  ..

 

copy

cp

-          Copy files and folders to specified location

-          You can use absolute and relative path to copy

 

 

 

[root@localhost ~]# mkdir -p redhat/whitehat/blackhat

[root@localhost ~]# tree

.

── file1

── file2

└── redhat

    └── whitehat

        └── blackhat

 

3 directories, 2 files

 

 

[root@localhost ~]# cp file1 redhat/whitehat/blackhat/

[root@localhost ~]# tree

.

── file1

── file2

└── redhat

    └── whitehat

        └── blackhat

            └── file1

 

3 directories, 3 files

 

 

cp file1 redhat/whitehat/blackhat/

 

Command

source

destination

cp

File1

redhat/whitehat/blackhat/

 

 

cp file2 /root/redhat/whitehat/

-          Copy using ablsoute path

 

[root@localhost ~]# cp file2 /root/redhat/whitehat/

 

[root@localhost ~]# tree

.

── file1

── file2

└── redhat

    └── whitehat

        ── blackhat

        │   └── file1

        └── file2

 

 

10-11-2020

https://www.youtube.com/watch?v=kluWB4pAuns

 

 

 

-bash-4.2# cp /etc/skel/.b* /root

 

cp /etc/skel/.b* .

 

[root@localhost ~]# ls -a

.   .bash_history  .bash_profile  file1  redhat

..  .bash_logout   .bashrc        file2

 

 

[root@localhost ~]# tree

.

└── redhat

    └── whitehat

        ── blackhat

        │   └── file1

        └── file2

 

Copy files from foreign directory

 

[root@localhost ~]# cp redhat/whitehat/file2 .                                      < ---using relative path

[root@localhost ~]# ls

file2  redhat

 

[root@localhost ~]# cp /root/redhat/whitehat/blackhat/file1 /root < ---using absolute path

[root@localhost ~]# ls

file1  file2  redhat

 

 

[root@localhost ~]# cd redhat/whitehat/

 

[root@localhost whitehat]# cp file2 ../..                                                  < ---Using relative path

[root@localhost whitehat]# cd

 

[root@localhost ~]# ls

file1  file2  redhat

 

Copy directory

 

[root@localhost ~]# cp -rf redhat ibm                < --- -rf  is needed for directory, recursively, force

 

[root@localhost ~]# ls

file1  file2  ibm  redhat

[root@localhost ~]# tree

.

── file1

── file2

── ibm

│   └── whitehat

│       ── blackhat

│       │   └── file1

│       └── file2

└── redhat

    └── whitehat

        ── blackhat

        │   └── file1

        └── file2

 

6 directories, 6 files

 

Copy directory into another directory

 

[root@localhost ~]# mkdir archive

[root@localhost ~]# cp -rf ibm archive

[root@localhost ~]# ls -l archive/

total 0

drwxr-xr-x. 3 root root 22 Oct 11 15:59 ibm

[root@localhost ~]# ls archive/

ibm

[root@localhost ~]# cd archive/

[root@localhost archive]# ls

Ibm

 

Move

Moving file

 

[root@localhost ~]# ls

archive  file1  file2  ibm  redhat

[root@localhost ~]# mv file1 archive

 

 

Command

Source

Destination

mv

File1

archive

 

 

[root@localhost ~]# ls

archive  file2  ibm  redhat

[root@localhost ~]# cd archive/

[root@localhost archive]# ls

file1  ibm

 

Moving directory

 

[root@localhost archive]# cd

[root@localhost ~]# mv -f redhat archive

 

Command

Source

Destination

mv –f

redhat

archive

 

 

[root@localhost ~]# ls

archive  file2  ibm

 

Rename

Renaming file

 

[root@localhost ~]# mv file2 xfile

 

Command

Old name

New name

mv

file2

xfile

 

 

 

[root@localhost ~]# ls

archive  ibm  xfile

 

 

Renaming directory

 

[root@localhost ~]# mv ibm aws

 

Command

Old name

New name

mv

Ibm

aws

 

 

[root@localhost ~]# ls

archive  aws  xfile

 

man

man

 

[root@localhost ~]# man

What manual page do you want?

 

man  - an interface to the on-line reference manuals

 

echo

echo

 

-          Repeats after the command and displays on screen

 

 

[root@localhost ~]# echo

 

[root@localhost ~]# echo this is linux course

this is linux course

 

[root@localhost ~]# echo this is linux course and I am enjoying this course

this is linux course and I am enjoying this course

 

Redirectors

 

Redirectors

 

 

0<

 

 

Standard input

 

 

1>

 

 

Standard out put

 

echo this is linux course and I am enjoying this course 1> file1

 

 

2>

 

 

Standard error

 

lkskfsl 2> file2

 

 

 

 

 

1>

 

 

[root@localhost ~]# echo this is linux course 1> file1

 

Command

Content

Redirector – output

File name

Echo

this is linux course

 1>

File1

 

 

 

 

0<

 

[root@localhost ~]# cat 0< file1               < --- 0< is a input redirection

this is linux course

 

Command

Redirector – input

File name

Cat

0<

File1

 

 

[root@localhost ~]# cat < file1             < --- < is a input redirection

this is linux course

 

[root@localhost ~]# cat file1                < ---  is a input redirection

this is linux course

 

 

final word: you don’t really need to specify 0< or <, the system will automatically read the file

 

2>

 

-          This will catch only the errors and redirects to the file

-          You can also redirect errors to /dev/null – discarded location, not retrievable 

 

[root@localhost ~]# dfkjlks

-bash: dfkjlks: command not found

 

[root@localhost ~]# dfkjlks 2>/dev/null

 

cat

cat – concatenate

 

-          Most basic use is to read a file

 

 

Read the file

 

[root@localhost ~]# cat file1

this is linux course

 

read multiple files at the same time

 

[root@localhost ~]# cat file1 file2

this is linux course

ls: cannot access nothing: No such file or directory

 

redirect the output another file

[root@localhost ~]# cat file1 file2 > file3                    < --- redirects using >, over writes existing content  also creates new file if does not exits

 

[root@localhost ~]# cat file3

this is linux course

ls: cannot access nothing: No such file or directory

 

Add to

 

[root@localhost ~]# cat file1 file2 >> file3                       < --- user double >> to add to file

[root@localhost ~]# cat file3

this is linux course

ls: cannot access nothing: No such file or directory

this is linux course

ls: cannot access nothing: No such file or directory

 

 

 

Enter into quick edit mode

 

[root@localhost ~]# cat > file4     <--- over rides the content, also create new file if it does not exits

This is line1

this is line2

this is line3

 

[root@localhost ~]# cat file4

This is line1

this is line2

this is line3

 

Add additional lines

 

[root@localhost ~]# cat >> file4             < ---add additional lines

this is line4

this is line5

 

[root@localhost ~]# cat file4

This is line1

this is line2

this is line3

this is line4

this is line5

 

grep

grep

 

-          Filters the line with matching word in it

 

[root@localhost ~]# cat file4

This is line1

this is line2

this is line3

this is line4

this is line5

This is Linux

This is Redhat Linux

This is linux course

this is interesting

 

[root@localhost ~]# cat file4 | grep linux              < ---greps match, case sensitive

This is linux course

 

[root@localhost ~]# cat file4 | grep -i linux         < ---ignores the case

This is Linux

This is Redhat Linux

This is linux course

 

 

You can use grep directly without cat

 

[root@localhost ~]# grep -i linux file4

This is Linux

This is Redhat Linux

This is linux course

 

 

pipe

|

 

-          Pipe is used for running multiple commands

-           

-          Primary command | secondary command | third command

 

 

 

[root@localhost ~]# cat file4

This is line1

this is line2

this is line3

this is line4

this is line5

This is Linux

This is Redhat Linux

This is linux course

this is interesting

 

[root@localhost ~]# cat file4 | grep -i linux

This is Linux

This is Redhat Linux

This is linux course

 

[root@localhost ~]# cat file4 | grep -i linux | grep Red

This is Redhat Linux

 

Multiple word search

 

[root@localhost ~]# cat file4 | grep -i 'linux\|line4'

 

this is line4

This is Linux

This is Redhat Linux

This is linux course

 

wc

wc

-          This is a word count

-           

 

[root@localhost ~]# wc file4

  9  29 146 file4

 

Number of lines

Words

Characters includes spaces

Name of the file

9

29

146

File4

 

[root@localhost ~]# cat file4

This is line1

this is line2

this is line3

this is line4

this is line5

This is Linux

This is Redhat Linux

This is linux course

this is interesting

 

[root@localhost ~]# wc -l file4           < --- -l is for lines

9 file4

 

[root@localhost ~]# wc -c file4        < --- -c is for characters 

146 file4

 

[root@localhost ~]# wc -w file4      < --- -w is for words

29 file4

 

head

Head

-          Read top ten lines of the file

 

 

 

[root@localhost ~]# head file4

This is line1

this is line2

this is line3

this is line4

this is line5

This is Linux

This is Redhat Linux

This is linux course

this is interesting

this is line10

 

 

[root@localhost ~]# head -5 file4

[root@localhost ~]# head -12 file4

[root@localhost ~]# head -100 error.log

 

tail

Tail

 

-          This command reads bottow ten lines

 

 

[root@localhost ~]# tail file4

this is line5

This is Linux

This is Redhat Linux

This is linux course

this is interesting

this is line10

this is line11

this is line12

this is line13

this si line14

 

[root@localhost ~]# tail -5 file4

[root@localhost ~]# tail -12 file4

[root@localhost ~]# tail -100 error.log

 

 

more

more

 

-          Primary use is to read huge file

-          This will load the entire file into memory

-          Use ‘enter’ on keyboard to scroll line by line

-          Use ‘spacebar’ on keyboard to scroll page by page

-          ‘q’ to quit the file

-          Not good when memory is low

 

/var/log

[root@localhost log]# more messages

 

 

 

less

Less

-          This is similar to more command

-          But it will only load the output as needed into memory

-          Use ‘enter’ on keyboard to scroll line by line

-          Use ‘spacebar’ on keyboard to scroll page by page

-          ‘q’ to quit the file

-          good when memory is low

 

/var/log

[root@localhost log]# less messages

 

sort

Sort

 

-          sorts the file alphabetically

 

[root@localhost ~]# sort file5

 

[root@localhost ~]# sort -n file5  < --- sorts using numbers

 

uniq

Uniq

 

-          removes duplicates

-           

[root@localhost ~]# cat > file5

apple

apple

berry

berry

strawberry

pineapple

pineapple

mango

[root@localhost ~]# uniq file5

apple

berry

strawberry

pineapple

mango

 

date

Date

 

[root@localhost ~]# date

Sat Oct 17 15:25:19 EDT 2020

 

cal

Cal

 

[root@localhost ~]# cal

    October 2020

Su Mo Tu We Th Fr Sa

             1  2  3

 4  5  6  7  8  9 10

11 12 13 14 15 16 17

18 19 20 21 22 23 24

25 26 27 28 29 30 31

 

[root@localhost ~]# cal 12 1969

    December 1969

Su Mo Tu We Th Fr Sa

    1  2  3  4  5  6

 7  8  9 10 11 12 13

14 15 16 17 18 19 20

21 22 23 24 25 26 27

28 29 30 31

 

who

who

-          Displays users logged into system

-           

[zafar@assignment01 ~]$ who

zafar    pts/0        2020-10-17 15:29 (73.110.42.133)

adil     pts/1        2020-10-17 15:34 (162-226-246-197.lightspeed.cicril.sbcglobal.net)

zafar    pts/2        2020-10-17 15:34 (73.110.42.133)

 

last

last

 

-          Displays the login and reboot

 

[root@localhost ~]# last

root     tty1                          Sat Oct 17 14:59   sti

root     pts/0        192.168.56.1     Sat Oct 17 14:59   sti

reboot   system boot  3.10.0-1062.el7. Sat Oct 17 14:57 - 15:

 

free

Free –h

 

-          Displays the System RAM and SWAP[virtual memory] information

 

[root@localhost ~]# free -h

              total        used        free      shared  buff/cache   available

Mem:           991M        142M        744M        6.8M        103M        723M

Swap:          1.6G          0B        1.6G

 

 

du

du

 

-          Disk usage information of the file or folder

 

[root@localhost ~]# du -h file4

4.0K    file4

 

top

Top

 

-          Displays the real time information  about the system

-          Cpu, memory, processes

 

top - 15:51:08 up 53 min,  2 users,  load average: 0.00, 0.01, 0.05

Tasks:  99 total,   2 running,  97 sleeping,   0 stopped,   0 zombie

%Cpu(s):  0.3 us,  0.7 sy,  0.0 ni, 99.0 id,  0.0 wa,  0.0 hi,  0.0 si,  0.0 st

KiB Mem :  1014824 total,   761684 free,   146624 used,   106516 buff/cache

KiB Swap:  1679356 total,  1679356 free,        0 used.   740012 avail Mem

 

  PID USER      PR  NI    VIRT    RES    SHR S %CPU %MEM     TIME+ COMMAND

 1868 root      20   0  161888   2172   1544 R  0.7  0.2   0:00.34 top

   25 root      20   0       0      0      0 S  0.3  0.0   0:04.63 kworker/0:1

    1 root      20   0  127964   6536   4108 S  0.0  0.6   0:01.97 systemd

 

lscpu

Lscpu

 

-          List the number of CPU system has

 

[root@assignment01 ~]# lscpu

Architecture:          x86_64

CPU op-mode(s):        32-bit, 64-bit

Byte Order:            Little Endian

CPU(s):                2

 

 

which

Which

-          Displays if the command or package is installed

 

[root@localhost ~]# which tree

/usr/bin/tree

 

 

[root@localhost ~]# which firefox       < ---Not installed

/usr/bin/which: no firefox in (/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/.local/bin:/root/bin)

 

gzip

Gzip

 

-          Zips and compresses the file

-          It adds the extension with .gz

 

[root@localhost ~]# gzip error.log

 

[root@localhost ~]# du -h error.log.gz

4.0K    error.log.gz

 

gunzip

Gunzip

 

-          Unzips and uncompresses the file

 

[root@localhost ~]# gunzip error.log.gz

[root@localhost ~]# ls -l

total 92

-rw-r--r--. 1 root root 72295 Oct 11 17:30 error.log

 

tar

Tar

 

-          It saves the folder to single file

-          It does not compress the tar file

-          It keeps the orginal folder and creates is a new file

 

[root@localhost ~]# mkdir folder1

 

 

[root@localhost folder1]# ls -lh

total 4.6M

-rw-------. 1 root root 4.6M Oct 17 16:12 messages

[root@localhost folder1]# cp messages messages2

[root@localhost folder1]# cp messages messages4

[root@localhost folder1]# cp messages messages3

[root@localhost folder1]# cp messages messages5

 

[root@localhost ~]# du -h folder1/

23M     folder1/

 

[root@localhost ~]# tar -cvf folder1.tar folder1

folder1/

folder1/messages

folder1/messages2

folder1/messages4

folder1/messages3

folder1/messages5

 

-cvf for the folder

 

drwxr-xr-x. 2 root root       90 Oct 17 16:13 folder1

-rw-r--r--. 1 root root 24074240 Oct 17 16:18 folder1.tar

 

 

-          This makes copying or moving folder easy

-          This keeps the data integrity of the content, especially copied over network

 

*** you can used gzip and gunzip to compress and uncompress the folder

 

[root@localhost ~]# gzip folder1.tar

 

[root@localhost ~]# du -h fo*

23M     folder1

1.3M    folder1.tar.gz

 

stat

Stat

 

-          Displays detailed information

 

[root@localhost ~]# stat file1

  File: ‘file1’

  Size: 21              Blocks: 8          IO Block: 4096   regular file

Device: fd00h/64768d    Inode: 16797776    Links: 1

Access: (0644/-rw-r--r--)  Uid: (    0/    root)   Gid: (    0/    root)

Context: unconfined_u:object_r:admin_home_t:s0

Access: 2020-10-17 16:26:24.332018946 -0400

Modify: 2020-10-11 16:37:25.730845836 -0400

Change: 2020-10-11 16:37:25.730845836 -0400

 Birth: -

 

inode

Inode

 

-          It is table on the disk holding the file information

-          Owner of the file

-          Group of the file

-          Type of the file

-          Permissions

-          Date and time of the file modified and accessed

-          Number of links

-          Size of the file

-          Block information

 

To find inode of a file

 

[root@localhost ~]# ls -i file1

16797776 file1

 

Block Information

 

Block information

 

One bit is bit = 1 bit

Eight bit is byte = 1 byte

Kilo bytes = 1024 = 1 kilo byte

4096 bytes = 4kb

 

 

 

4096 = 4kb  minimum useable

 

File Size

Disk Space used 4K

0

4 kb

1 kb

4kb

2 kb

4 kb

4 kb

4 kb

6 kb

8 kb

13 kb

16 kb

21

24 kb

 

 

find

Find

 

-          It fins the files in specified directory

-          You can use absolute or relative path

-          You can use name or inode number

 

Using name

 

[root@localhost ~]# find / -name file1

/root/file1

/root/folder1/file1

 

[root@localhost ~]# find / -inum 16797776   < --- Using inum

/root/file1