Cent-OS Practical Command

 CentOS tutorial:

Polylms - Server Name

Ls : to check what is in directory

[root@Polylms ~]# ls

 anaconda-ks.cfg  '[gurukul_backup.sql]'     Pictures

 Desktop           gurukul.polycab.com.csr   Public

 Documents         gurukul.polycab.com.key   Templates

 Downloads         Music                     Videos

Mkdir name : To create folder

[root@Polylms ~]# mkdir demo

[root@Polylms ~]# ls

 anaconda-ks.cfg   Downloads                 Music       Videos

 demo             '[gurukul_backup.sql]'     Pictures

 Desktop           gurukul.polycab.com.csr   Public

 Documents         gurukul.polycab.com.key   Templates

[root@Polylms ~]# cd demo

[root@Polylms demo]# mkdir sample

[root@Polylms demo]# ls

Sample

Cat >test1.txt : To create file and write on this file , to end or finish use ctrl + z

[root@Polylms demo]# cat >test1.txt

This is test folder and is requiresd to create new file in make directory.

Thanks prashant^Z

[1]+  Stopped                 cat > test1.txt

[root@Polylms demo]# cat test1.txt

This is test folder and is requiresd to create new file in make directory.

Touch : this required to create empty file but cant add on this

[root@Polylms demo]# touch 1.txt

[root@Polylms demo]# ls

1.txt  sample  test1.txt

Cp file name ./directoryname : To copy file from one place to another

[root@Polylms demo]# cp 1.txt ./sample

[root@Polylms demo]# ls

1.txt  sample  test1.txt

[root@Polylms demo]# cd sample

[root@Polylms sample]# ls

1.txt

[root@Polylms sample]# cd ..

[root@Polylms demo]# touch 2.txt

[root@Polylms demo]# ls

1.txt  2.txt  sample  test1.txt

Mv filename ./directory name : To move file from one place to another

[root@Polylms demo]# mv 2.txt ./sample

[root@Polylms demo]# ls

1.txt  sample  test1.txt

[root@Polylms demo]# cd sample

[root@Polylms sample]# ls

1.txt  2.txt

Rm filename : To remove or delete filename

[root@Polylms sample]# ls

1.txt  2.txt

[root@Polylms sample]# rm 2.txt

rm: remove regular empty file '2.txt'? y

[root@Polylms sample]# ls

1.txt

Yum : install new package 

[root@Polylms sample]# sudo yum install git

Unable to detect release version (use '--releasever' to specify release version)

Warning: failed loading '/etc/yum.repos.d/old.repo', skipping.

Last metadata expiration check: 1:58:56 ago on Thu 22 Apr 2021 06:56:21 PM IST.

Modular dependency problems:


 Problem 1: conflicting requests

  - nothing provides module(perl:5.30) needed by module perl-FCGI:0.78:8030020200618214557:2fbcbb20-0.x86_64

 Problem 2: conflicting requests

  - nothing provides module(perl:5.30) needed by module perl-YAML:1.24:8030020200723225335:a6d43775-0.x86_64

 Problem 3: module perl-App-cpanminus:1.7044:8030020200723233049:09acf126-0.x86_64 requires module(perl-YAML), but none of the providers can be installed

  - conflicting requests

  - nothing provides module(perl:5.30) needed by module perl-YAML:1.24:8030020200723225335:a6d43775-0.x86_64

Dependencies resolved.

================================================================================

 Package            Arch     Version             Repository                Size

================================================================================

Installing:

 git                x86_64   2.27.0-1.el8        InstallMedia-AppStream   164 k

Installing dependencies:

 emacs-filesystem   noarch   1:26.1-5.el8        InstallMedia-BaseOS       69 k

 git-core           x86_64   2.27.0-1.el8        InstallMedia-AppStream   5.7 M

 git-core-doc       noarch   2.27.0-1.el8        InstallMedia-AppStream   2.5 M

 perl-Error         noarch   1:0.17025-2.el8     InstallMedia-AppStream    46 k

 perl-Git           noarch   2.27.0-1.el8        InstallMedia-AppStream    77 k

 perl-TermReadKey   x86_64   2.37-7.el8          InstallMedia-AppStream    40 k


Transaction Summary

================================================================================

Install  7 Packages


Total size: 8.6 M

Installed size: 45 M

Is this ok [y/N]:

 

[root@Polylms ~]# sudo su

[root@Polylms ~]# man

What manual page do you want?

[root@Polylms ~]# man cp

[root@Polylms ~]#

 

alias cp='cp -i'

alias egrep='egrep --color=auto'

alias fgrep='fgrep --color=auto'

alias grep='grep --color=auto'

alias l.='ls -d .* --color=auto'

alias ll='ls -l --color=auto'

alias ls='ls --color=auto'

alias mv='mv -i'

alias rm='rm -i'

alias which='(alias; declare -f) | /usr/bin/which --tty-only --read-alias --read-functions --show-tilde --show-dot'

alias xzegrep='xzegrep --color=auto'

alias xzfgrep='xzfgrep --color=auto'

alias xzgrep='xzgrep --color=auto'

alias zegrep='zegrep --color=auto'

alias zfgrep='zfgrep --color=auto'

alias zgrep='zgrep --color=auto'

echo

 


Set variable

 


 

 

Arthematic Operation

 

 



[root@Polylms ~]# expr --version

expr (GNU coreutils) 8.30

Copyright (C) 2018 Free Software Foundation, Inc.

License GPLv3+: GNU GPL version 3 or later <https://gnu.org/licenses/gpl.html>.

This is free software: you are free to change and redistribute it.

There is NO WARRANTY, to the extent permitted by law.


Written by Mike Parker, James Youngman, and Paul Eggert.

[root@Polylms ~]# expr 1 + 2

3

[root@Polylms ~]# expr 2 - 1

1

[root@Polylms ~]# expr 4/2

4/2

[root@Polylms ~]# expr 4/*2

4/*2

[root@Polylms ~]# expr 4*2

4*2

[root@Polylms ~]# expr 4 * 2

expr: syntax error: unexpected argument ‘anaconda-ks.cfg’

[root@Polylms ~]# 4 \/ 2

bash: 4: command not found...

[root@Polylms ~]# expr 4 \/ 2

2

[root@Polylms ~]# expr 11 < 10

bash: 10: No such file or directory

[root@Polylms ~]# expr 11 \< 10

0

[root@Polylms ~]#



 

 

 

- I smaill I inser mode

- Press ESC

- Shift + :wq and enter

 


User Permission :

 


User / group /Other Users

Eg -rw-r—r—

 

 


Last login: Thu Apr 22 23:21:32 2021

[root@Polylms ~]# ls

 1.shM-D           Desktop    '[gurukul_backup.sql]'     Music      Templates

 anaconda-ks.cfg   Documents   gurukul.polycab.com.csr   Pictures   Videos

 demo              Downloads   gurukul.polycab.com.key   Public

[root@Polylms ~]# pwd

/root

[root@Polylms ~]# sudo

usage: sudo -h | -K | -k | -V

usage: sudo -v [-AknS] [-g group] [-h host] [-p prompt] [-u user]

usage: sudo -l [-AknS] [-g group] [-h host] [-p prompt] [-U user] [-u user]

            [command]

usage: sudo [-AbEHknPS] [-r role] [-t type] [-C num] [-g group] [-h host] [-p

            prompt] [-T timeout] [-u user] [VAR=value] [-i|-s] [<command>]

usage: sudo -e [-AknS] [-r role] [-t type] [-C num] [-g group] [-h host] [-p

            prompt] [-T timeout] [-u user] file ...

[root@Polylms ~]# sudo useradd prashants

[root@Polylms ~]# ls

 1.shM-D           Desktop    '[gurukul_backup.sql]'     Music      Templates

 anaconda-ks.cfg   Documents   gurukul.polycab.com.csr   Pictures   Videos

 demo              Downloads   gurukul.polycab.com.key   Public

[root@Polylms ~]# cd /home

[root@Polylms home]# ls

administrator  prashant  prashants

[root@Polylms home]# cd prashant

[root@Polylms prashant]# cat /etc/shadow

root:$6$WHVrIB6onyZ8y7I7$n57zm.9IxZWr.h8f6Mb4rJ3QyCJ3RTG3/5GC5P2SGJkx766sWY7YLJyiYVK5lomWzT34qOYhkhpAfZTxlc7dx.::0:99999:7:::

bin:*:18358:0:99999:7:::

daemon:*:18358:0:99999:7:::

adm:*:18358:0:99999:7:::

lp:*:18358:0:99999:7:::

sync:*:18358:0:99999:7:::

shutdown:*:18358:0:99999:7:::

halt:*:18358:0:99999:7:::

mail:*:18358:0:99999:7:::

operator:*:18358:0:99999:7:::

games:*:18358:0:99999:7:::

ftp:*:18358:0:99999:7:::

nobody:*:18358:0:99999:7:::

dbus:!!:18491::::::

systemd-coredump:!!:18491::::::

systemd-resolve:!!:18491::::::

tss:!!:18491::::::

polkitd:!!:18491::::::

geoclue:!!:18491::::::

rtkit:!!:18491::::::

pulse:!!:18491::::::

libstoragemgmt:!!:18491::::::

qemu:!!:18491::::::

usbmuxd:!!:18491::::::

unbound:!!:18491::::::

rpc:!!:18491:0:99999:7:::

gluster:!!:18491::::::

chrony:!!:18491::::::

setroubleshoot:!!:18491::::::

pipewire:!!:18491::::::

saslauth:!!:18491::::::

dnsmasq:!!:18491::::::

radvd:!!:18491::::::

clevis:!!:18491::::::

cockpit-ws:!!:18491::::::

cockpit-wsinstance:!!:18491::::::

sssd:!!:18491::::::

flatpak:!!:18491::::::

colord:!!:18491::::::

gdm:!!:18491::::::

rpcuser:!!:18491::::::

gnome-initial-setup:!!:18491::::::

sshd:!!:18491::::::

avahi:!!:18491::::::

rngd:!!:18491::::::

tcpdump:!!:18491::::::

administrator:$6$QJhM1yRiL6J1G.ur$ViO7pIHTBuSy3dLe6Ie2Tl/UVfhI/iWAbQDQrROJdlhyUzFgNz6c8qNuzwUXv5xd2xcL3/.AosWdncY4NwR330::0:99999:7:::

apache:!!:18493::::::

nginx:!!:18493::::::

mysql:!!:18493::::::

prashant:$6$S8gERBRmG3nI3kMj$KbPaT.lBhwouvVUFp/L7INKcwfwpDUnpRHh/UhgK8K1JLEoC2nzfZ5joI75ReAQcPeINtA30tmMMs7PKnqSKr1:18739:0:99999:7:::

prashants:!!:18740:0:99999:7:::

[root@Polylms prashant]#

[root@Polylms prashant]#

[root@Polylms prashant]#

[root@Polylms prashant]#

[root@Polylms prashant]# cd ..

[root@Polylms home]# cd prashants

[root@Polylms prashants]# cat /etc/shadow

root:$6$WHVrIB6onyZ8y7I7$n57zm.9IxZWr.h8f6Mb4rJ3QyCJ3RTG3/5GC5P2SGJkx766sWY7YLJyiYVK5lomWzT34qOYhkhpAfZTxlc7dx.::0:99999:7:::

bin:*:18358:0:99999:7:::

daemon:*:18358:0:99999:7:::

adm:*:18358:0:99999:7:::

lp:*:18358:0:99999:7:::

sync:*:18358:0:99999:7:::

shutdown:*:18358:0:99999:7:::

halt:*:18358:0:99999:7:::

mail:*:18358:0:99999:7:::

operator:*:18358:0:99999:7:::

games:*:18358:0:99999:7:::

ftp:*:18358:0:99999:7:::

nobody:*:18358:0:99999:7:::

dbus:!!:18491::::::

systemd-coredump:!!:18491::::::

systemd-resolve:!!:18491::::::

tss:!!:18491::::::

polkitd:!!:18491::::::

geoclue:!!:18491::::::

rtkit:!!:18491::::::

pulse:!!:18491::::::

libstoragemgmt:!!:18491::::::

qemu:!!:18491::::::

usbmuxd:!!:18491::::::

unbound:!!:18491::::::

rpc:!!:18491:0:99999:7:::

gluster:!!:18491::::::

chrony:!!:18491::::::

setroubleshoot:!!:18491::::::

pipewire:!!:18491::::::

saslauth:!!:18491::::::

dnsmasq:!!:18491::::::

radvd:!!:18491::::::

clevis:!!:18491::::::

cockpit-ws:!!:18491::::::

cockpit-wsinstance:!!:18491::::::

sssd:!!:18491::::::

flatpak:!!:18491::::::

colord:!!:18491::::::

gdm:!!:18491::::::

rpcuser:!!:18491::::::

gnome-initial-setup:!!:18491::::::

sshd:!!:18491::::::

avahi:!!:18491::::::

rngd:!!:18491::::::

tcpdump:!!:18491::::::

administrator:$6$QJhM1yRiL6J1G.ur$ViO7pIHTBuSy3dLe6Ie2Tl/UVfhI/iWAbQDQrROJdlhyUzFgNz6c8qNuzwUXv5xd2xcL3/.AosWdncY4NwR330::0:99999:7:::

apache:!!:18493::::::

nginx:!!:18493::::::

mysql:!!:18493::::::

prashant:$6$S8gERBRmG3nI3kMj$KbPaT.lBhwouvVUFp/L7INKcwfwpDUnpRHh/UhgK8K1JLEoC2nzfZ5joI75ReAQcPeINtA30tmMMs7PKnqSKr1:18739:0:99999:7:::

prashants:!!:18740:0:99999:7:::

[root@Polylms prashants]# cd ..

[root@Polylms home]# cate /etc/shadow

bash: cate: command not found...

Similar command is: 'cat'

[root@Polylms home]# sudo su

[root@Polylms home]# sudo -s

 

File Structure

 

Chmod and chown

Chmod permission of file or directory

 

 

 

In Above 755 means (7 -all permission given to users, 5 means read and execute permission given to group, again 5 means read and execute permission given to others users)

 

 

[root@Polylms home]# sudo su

[root@Polylms home]# sudo -s

[root@Polylms home]# ^C

[root@Polylms home]# clear

[root@Polylms home]# touch file1.txt

[root@Polylms home]# ls

administrator  file1.txt  prashant  prashants

[root@Polylms home]# ls -l file1.txt

-rw-r--r--. 1 root root 0 Apr 23 12:57 file1.txt

[root@Polylms home]# chmod u+x file1.txt

[root@Polylms home]# ls -l file1.txt

-rwxr--r--. 1 root root 0 Apr 23 12:57 file1.txt

[root@Polylms home]# chmod gg+x file1.txt

[root@Polylms home]# ls -l file1.txt

-rwxr-xr--. 1 root root 0 Apr 23 12:57 file1.txt

[root@Polylms home]# chmod g-w file1.txt

[root@Polylms home]# ls -l file1.txt

-rwxr-xr--. 1 root root 0 Apr 23 12:57 file1.txt

[root@Polylms home]# chmod o-r file1.txt

[root@Polylms home]# ls -l file1.txt

-rwxr-x---. 1 root root 0 Apr 23 12:57 file1.txt

[root@Polylms home]# chmod o+w file1.txt

[root@Polylms home]# ls -l file1.txt

-rwxr-x-w-. 1 root root 0 Apr 23 12:57 file1.txt

[root@Polylms home]# chmod 777 file1.txt

[root@Polylms home]# ls -l file1.txt

-rwxrwxrwx. 1 root root 0 Apr 23 12:57 file1.txt

[root@Polylms home]# chmod 756 file1.txt

[root@Polylms home]# ls -l file1.txt

-rwxr-xrw-. 1 root root 0 Apr 23 12:57 file1.txt

[root@Polylms home]# chmod 556 file1.txt

[root@Polylms home]# ls -l file1.txt

-r-xr-xrw-. 1 root root 0 Apr 23 12:57 file1.txt

[root@Polylms home]# nono file1.txt

bash: nono: command not found...

Failed to search for file: Failed to load /etc/yum.repos.d/old.repo: Error reading file “/etc/yum.repos.d/old.repo”: Is a directory

[root@Polylms home]# nano file1.txt   It reads the file


Add Users in group

[root@Polylms home]# sudo grep dev /etc/group

[root@Polylms home]# sudo grep operation /etc/group

operation:x:1004:

[root@Polylms home]# sudo gpasswd -a prashant operation

Adding user prashant to group operation

[root@Polylms home]# sudo grep operation /etc/group

operation:x:1004:prashant


syntax  chown user:groupname filename   (Add Group permission on file) operation is my groupname


[root@Polylms home]# chown :operation file1.txt

[root@Polylms home]# ls -l file1.txt

-r-xr-xrw-. 1 root operation 0 Apr 23 12:57 file1.txt

[root@Polylms home]#


Another command

[root@Polylms home]# sudo chgrp HR file1.txt

[root@Polylms home]# ls -l file1.txt

-r-xr-xrw-. 1 root HR 0 Apr 23 12:57 file1.txt

[root@Polylms home]# sudo chgrp operation file1.txt

[root@Polylms home]# ls -l file1.txt

-r-xr-xrw-. 1 root operation 0 Apr 23 12:57 file1.txt


Displaying content of File :

 


[root@Polylms home]# touch file2.txt

[root@Polylms home]# cat >file2.txt

This is the test file

i love you prashant

this is only example

wq

^[^Z

[1]+  Stopped                 cat > file2.txt

[root@Polylms home]# cat file2.txt

This is the test file

i love you prashant

this is only example

wq

[root@Polylms home]# head file2.txt

This is the test file

i love you prashant

this is only example

wq

[root@Polylms home]# tail file2.txt

This is the test file

i love you prashant

this is only example

wq

[root@Polylms home]# nano file2.txt

[root@Polylms home]# cat file2.txt

This is the test file

i love you prashant

this is only example

wq

[root@Polylms home]# nano file2.txt

[root@Polylms home]# nano file2.txt

[root@Polylms home]# nano file2.txt

[root@Polylms home]# cat file2.txt

This is the test file

i love you prashant

this is only example

wq

ashdgsadjhksadjklsajckll

sdbkjdnsazkjncskjjncsxkn

dshbhjxcbhjcsbxjsbchjcb

scbjxzckjxcznkjxnczcxklkjinsckmsalk

scbkxzCNkznxCnzcxKnzxnzX

wdqywquheiuwqeuqw


sajkhkjsadkdsajskadjklsad

ascnjasnkjaASKLASKL

ASDHJSADHJSAHKJSA


[root@Polylms home]# head file2.txt

This is the test file

i love you prashant

this is only example

wq

ashdgsadjhksadjklsajckll

sdbkjdnsazkjncskjjncsxkn

dshbhjxcbhjcsbxjsbchjcb

scbjxzckjxcznkjxnczcxklkjinsckmsalk

scbkxzCNkznxCnzcxKnzxnzX

wdqywquheiuwqeuqw

[root@Polylms home]# tail file2.txt

sdbkjdnsazkjncskjjncsxkn

dshbhjxcbhjcsbxjsbchjcb

scbjxzckjxcznkjxnczcxklkjinsckmsalk

scbkxzCNkznxCnzcxKnzxnzX

wdqywquheiuwqeuqw


sajkhkjsadkdsajskadjklsad

ascnjasnkjaASKLASKL

ASDHJSADHJSAHKJSA


[root@Polylms home]# grep asd file2.txt

[root@Polylms home]# grep ash file2.txt

i love you prashant

ashdgsadjhksadjklsajckll

[root@Polylms home]# grep kxz file2.txt

scbkxzCNkznxCnzcxKnzxnzX

[root@Polylms home]#

[root@Polylms home]# tail -n 5 file2.txt


sajkhkjsadkdsajskadjklsad

ascnjasnkjaASKLASKL

ASDHJSADHJSAHKJSA


[root@Polylms home]# tail -n 3 file2.txt

ascnjasnkjaASKLASKL

ASDHJSADHJSAHKJSA


[root@Polylms home]# head -n 2 file2.txt

This is the test file

i love you prashant

[root@Polylms home]# head -n 4 file2.txt

This is the test file

i love you prashant

this is only example

wq

[root@Polylms home]#

Copying a file

 


[root@Polylms home]# touch dem1.txt dem2.txt dem3.txt

[root@Polylms home]# nano dem1.txt

[root@Polylms home]# cat dem1.txt

This is prashant


[root@Polylms home]# nano dem2.txt

[root@Polylms home]# cate dem2.txt

bash: cate: command not found...

Similar command is: 'cat'

[root@Polylms home]# cate dem2.txt

bash: cate: command not found...

Similar command is: 'cat'

[root@Polylms home]# cat dem2.txt

this is lucky.

[root@Polylms home]# nano dem3.txt

[root@Polylms home]# cat dem3.txt

I am at Polycab India limited

109816


[root@Polylms home]# ls

administrator  dem2.txt  file1.txtwq  file.txt  prashants

dem1.txt       dem3.txt  file2.txt    prashant  YES

[root@Polylms home]# cp dem1.txt dem3.txt

cp: overwrite 'dem3.txt'? yes

[root@Polylms home]# cat dem3.txt

This is prashant


[root@Polylms home]# cp dem3.txt Desktop

[root@Polylms home]# ls

administrator  dem2.txt  Desktop      file2.txt  prashant   YES

dem1.txt       dem3.txt  file1.txtwq  file.txt   prashants

[root@Polylms home]# cd Desktop

bash: cd: Desktop: Not a directory

[root@Polylms home]# cd ..

[root@Polylms /]# cd Desktop

bash: cd: Desktop: No such file or directory

[root@Polylms /]# ls

all__db.sql  dev                 home          lost+found  proc  srv  var

all_db.sql   etc                 lib           media       root  sys

bin          gurukul.sql         lib64         mnt         run   tmp

boot         gurukulsqlback.sql  lms_name.sql  opt         sbin  usr

[root@Polylms /]# cd ..

[root@Polylms /]# cd home

[root@Polylms home]# ls

administrator  dem2.txt  Desktop      file2.txt  prashant   YES

dem1.txt       dem3.txt  file1.txtwq  file.txt   prashants

[root@Polylms home]# cd ..

[root@Polylms /]# cd /desktop

bash: cd: /desktop: No such file or directory

[root@Polylms /]# cd /Desktop

bash: cd: /Desktop: No such file or directory


Move File 

 



[root@Polylms home]# mv dem3.txt dem1.txt Document

mv: target 'Document' is not a directory

[root@Polylms home]# mv dem3.txt dem1.txt Download

mv: target 'Download' is not a directory

[root@Polylms home]# mv dem3.txt dem1.txt Documents

mv: target 'Documents' is not a directory

[root@Polylms home]# ls

administrator  dem2.txt  file1.txtwq  file.txt  prashants

dem1.txt       Desktop   file2.txt    prashant  YES

[root@Polylms home]# cd ..

[root@Polylms /]# ls

all__db.sql  dev                 home          lost+found  proc  srv  var

all_db.sql   etc                 lib           media       root  sys

bin          gurukul.sql         lib64         mnt         run   tmp

boot         gurukulsqlback.sql  lms_name.sql  opt         sbin  usr

[root@Polylms /]# sudo root

sudo: root: command not found

[root@Polylms /]# su

[root@Polylms /]# sudo

usage: sudo -h | -K | -k | -V

usage: sudo -v [-AknS] [-g group] [-h host] [-p prompt] [-u user]

usage: sudo -l [-AknS] [-g group] [-h host] [-p prompt] [-U user] [-u user]

            [command]

usage: sudo [-AbEHknPS] [-r role] [-t type] [-C num] [-g group] [-h host] [-p

            prompt] [-T timeout] [-u user] [VAR=value] [-i|-s] [<command>]

usage: sudo -e [-AknS] [-r role] [-t type] [-C num] [-g group] [-h host] [-p

            prompt] [-T timeout] [-u user] file ...

[root@Polylms /]# sudo -s

[root@Polylms /]# ls

all__db.sql  dev                 home          lost+found  proc  srv  var

all_db.sql   etc                 lib           media       root  sys

bin          gurukul.sql         lib64         mnt         run   tmp

boot         gurukulsqlback.sql  lms_name.sql  opt         sbin  usr

[root@Polylms /]# ls

all__db.sql  dev                 home          lost+found  proc  srv  var

all_db.sql   etc                 lib           media       root  sys

bin          gurukul.sql         lib64         mnt         run   tmp

boot         gurukulsqlback.sql  lms_name.sql  opt         sbin  usr

[root@Polylms /]# cd home

[root@Polylms home]# ls

administrator  dem2.txt  file1.txtwq  file.txt  prashants

dem1.txt       Desktop   file2.txt    prashant  YES

[root@Polylms home]# mv dem2.txt dem1.txt Desktop

mv: target 'Desktop' is not a directory

[root@Polylms home]# mv dem2.txt dem1.txt /prashant/Desktop

mv: target '/prashant/Desktop' is not a directory

[root@Polylms home]# exit

exit

[root@Polylms /]# cd home

[root@Polylms home]# ls

administrator  dem2.txt  file1.txtwq  file.txt  prashants

dem1.txt       Desktop   file2.txt    prashant  YES

[root@Polylms home]# mv dem2.txt demo.txt

[root@Polylms home]# ls

administrator  demo.txt  file1.txtwq  file.txt  prashants

dem1.txt       Desktop   file2.txt    prashant  YES

[root@Polylms home]# ls


Rename a file

[root@Polylms /]# cd home

[root@Polylms home]# ls

administrator  dem2.txt  file1.txtwq  file.txt  prashants

dem1.txt       Desktop   file2.txt    prashant  YES

[root@Polylms home]# mv dem2.txt demo.txt

[root@Polylms home]# ls

administrator  demo.txt  file1.txtwq  file.txt  prashants

dem1.txt       Desktop   file2.txt    prashant  YES

[root@Polylms home]# ls^C


Remove a File

[root@Polylms home]# rm file1.txtwq

rm: remove regular file 'file1.txtwq'? y

[root@Polylms home]# ls

administrator  demo.txt  file2.txt  prashant   YES

dem1.txt       Desktop   file.txt   prashants


Find a file and type

[root@Polylms Desktop]# touch one.txt

[root@Polylms Desktop]# find one.txt

one.txt

[root@Polylms Desktop]# file one.txt

one.txt: empty

[root@Polylms Desktop]# nano one.txt

[root@Polylms Desktop]# file one.txt

one.txt: ASCII text


Unix Process Command 

 

 



[root@Polylms Desktop]# pwd

/root/Desktop

[root@Polylms Desktop]# pwd &

[1] 90972

/root/Desktop

[root@Polylms Desktop]#

[root@Polylms Desktop]# pwd

/root/Desktop

[root@Polylms Desktop]# pwd &

[1] 90973

/root/Desktop

[root@Polylms Desktop]# ^C

[1]+  Done                    pwd

[root@Polylms Desktop]#


[root@Polylms Desktop]# ls | pwd &

[1] 90983

/root/Desktop

[root@Polylms Desktop]# ls || pwd &

[2] 90984

[1]   Done                    ls --color=auto | pwd

[root@Polylms Desktop]# gurukulbackup  gurukul.polycab.com  newfile.txt  one.txt  permission  Test.txt

ls && pwd &

[3] 90986

[2]   Done                    ls --color=auto || pwd

[root@Polylms Desktop]# gurukulbackup  gurukul.polycab.com  newfile.txt  one.txt  permission  Test.txt

/root/Desktop


[3]+  Done                    ls --color=auto && pwd

[root@Polylms Desktop]# ls && pwd &

[1] 90988

[root@Polylms Desktop]# gurukulbackup  gurukul.polycab.com  newfile.txt  one.txt  permission  Test.txt

/root/Desktop


[1]+  Done                    ls --color=auto && pwd

[root@Polylms Desktop]#


 


Check System process:

[root@Polylms Desktop]# ps

    PID TTY          TIME CMD

  90710 pts/0    00:00:00 bash

  91027 pts/0    00:00:00 ps

[root@Polylms Desktop]# ps aux

USER         PID %CPU %MEM    VSZ   RSS TTY      STAT START   TIME COMMAND

root           1  0.0  0.1 253688 14388 ?        Ss   Apr21   0:45 /usr/lib/syst

root           2  0.0  0.0      0     0 ?        S    Apr21   0:00 [kthreadd]

root           3  0.0  0.0      0     0 ?        I<   Apr21   0:00 [rcu_gp]

root           4  0.0  0.0      0     0 ?        I<   Apr21   0:00 [rcu_par_gp]

root           6  0.0  0.0      0     0 ?        I<   Apr21   0:00 [kworker/0:0H

root           8  0.0  0.0      0     0 ?        I<   Apr21   0:00 [mm_percpu_wq

root           9  0.0  0.0      0     0 ?        S    Apr21   0:00 [ksoftirqd/0]

root          10  0.0  0.0      0     0 ?        I    Apr21   0:19 [rcu_sched]

root          11  0.0  0.0      0     0 ?        S    Apr21   0:00 [migration/0]

root          12  0.0  0.0      0     0 ?        S    Apr21   0:00 [watchdog/0]

root          13  0.0  0.0      0     0 ?        S    Apr21   0:00 [cpuhp/0]

root          14  0.0  0.0      0     0 ?        S    Apr21   0:00 [cpuhp/1]

root          15  0.0  0.0      0     0 ?        S    Apr21   0:00 [watchdog/1]

root          16  0.0  0.0      0     0 ?        S    Apr21   0:00 [migration/1]

root          17  0.0  0.0      0     0 ?        S    Apr21   0:00 [ksoftirqd/1]

root          19  0.0  0.0      0     0 ?        I<   Apr21   0:00 [kworker/1:0H

root          20  0.0  0.0      0     0 ?        S    Apr21   0:00 [cpuhp/2]

root          21  0.0  0.0      0     0 ?        S    Apr21   0:00 [watchdog/2]

root          22  0.0  0.0      0     0 ?        S    Apr21   0:00 [migration/2]

root          23  0.0  0.0      0     0 ?        S    Apr21   0:00 [ksoftirqd/2]

root          25  0.0  0.0      0     0 ?        I<   Apr21   0:00 [kworker/2:0H

root          26  0.0  0.0      0     0 ?        S    Apr21   0:00 [cpuhp/3]

root          27  0.0  0.0      0     0 ?        S    Apr21   0:00 [watchdog/3]

root          28  0.0  0.0      0     0 ?        S    Apr21   0:00 [migration/3]

root          29  0.0  0.0      0     0 ?        S    Apr21   0:00 [ksoftirqd/3]

root          31  0.0  0.0      0     0 ?        I<   Apr21   0:00 [kworker/3:0H

root          32  0.0  0.0      0     0 ?        S    Apr21   0:00 [cpuhp/4]

root          33  0.0  0.0      0     0 ?        S    Apr21   0:00 [watchdog/4]

root          34  0.0  0.0      0     0 ?        S    Apr21   0:00 [migration/4]

root          35  0.0  0.0      0     0 ?        S    Apr21   0:00 [ksoftirqd/4]

root          37  0.0  0.0      0     0 ?        I<   Apr21   0:00 [kworker/4:0H

root          38  0.0  0.0      0     0 ?        S    Apr21   0:00 [cpuhp/5]

root          39  0.0  0.0      0     0 ?        S    Apr21   0:00 [watchdog/5]

root          40  0.0  0.0      0     0 ?        S    Apr21   0:00 [migration/5]

root          41  0.0  0.0      0     0 ?        S    Apr21   0:00 [ksoftirqd/5]

root          43  0.0  0.0      0     0 ?        I<   Apr21   0:00 [kworker/5:0H

root          44  0.0  0.0      0     0 ?        S    Apr21   0:00 [cpuhp/6]

root          45  0.0  0.0      0     0 ?        S    Apr21   0:00 [watchdog/6]

root          46  0.0  0.0      0     0 ?        S    Apr21   0:00 [migration/6]

root          47  0.0  0.0      0     0 ?        S    Apr21   0:00 [ksoftirqd/6]

root          49  0.0  0.0      0     0 ?        I<   Apr21   0:00 [kworker/6:0H

root          50  0.0  0.0      0     0 ?        S    Apr21   0:00 [cpuhp/7]

root          51  0.0  0.0      0     0 ?        S    Apr21   0:00 [watchdog/7]

root          52  0.0  0.0      0     0 ?        S    Apr21   0:00 [migration/7]

root          53  0.0  0.0      0     0 ?        S    Apr21   0:00 [ksoftirqd/7]

root          55  0.0  0.0      0     0 ?        I<   Apr21   0:00 [kworker/7:0H

root          57  0.0  0.0      0     0 ?        S    Apr21   0:00 [kdevtmpfs]

root          58  0.0  0.0      0     0 ?        I<   Apr21   0:00 [netns]

root          59  0.0  0.0      0     0 ?        S    Apr21   0:00 [kauditd]

root          64  0.0  0.0      0     0 ?        S    Apr21   0:00 [khungtaskd]

root          65  0.0  0.0      0     0 ?        S    Apr21   0:00 [oom_reaper]

root          66  0.0  0.0      0     0 ?        I<   Apr21   0:00 [writeback]

root          67  0.0  0.0      0     0 ?        S    Apr21   0:00 [kcompactd0]

root          68  0.0  0.0      0     0 ?        SN   Apr21   0:00 [ksmd]

root          69  0.0  0.0      0     0 ?        SN   Apr21   0:00 [khugepaged]

root          70  0.0  0.0      0     0 ?        I<   Apr21   0:00 [crypto]

root          71  0.0  0.0      0     0 ?        I<   Apr21   0:00 [kintegrityd]

root          72  0.0  0.0      0     0 ?        I<   Apr21   0:00 [kblockd]

root          73  0.0  0.0      0     0 ?        I<   Apr21   0:00 [tpm_dev_wq]

root          74  0.0  0.0      0     0 ?        I<   Apr21   0:00 [md]

root          75  0.0  0.0      0     0 ?        I<   Apr21   0:00 [edac-poller]

root          76  0.0  0.0      0     0 ?        S    Apr21   0:00 [watchdogd]

root         105  0.0  0.0      0     0 ?        S    Apr21   0:00 [kswapd0]

root         199  0.0  0.0      0     0 ?        I<   Apr21   0:00 [kthrotld]

root         200  0.0  0.0      0     0 ?        I<   Apr21   0:00 [acpi_thermal

root         201  0.0  0.0      0     0 ?        I<   Apr21   0:00 [kmpath_rdacd

root         202  0.0  0.0      0     0 ?        I<   Apr21   0:00 [kaluad]

root         204  0.0  0.0      0     0 ?        I<   Apr21   0:00 [ipv6_addrcon

root         205  0.0  0.0      0     0 ?        I<   Apr21   0:00 [kstrp]

root         503  0.0  0.0      0     0 ?        S    Apr21   0:00 [scsi_eh_0]

root         504  0.0  0.0      0     0 ?        I<   Apr21   0:00 [scsi_tmf_0]

root         508  0.0  0.0      0     0 ?        I<   Apr21   0:00 [ata_sff]

root         513  0.0  0.0      0     0 ?        S    Apr21   0:00 [scsi_eh_1]

root         514  0.0  0.0      0     0 ?        I<   Apr21   0:00 [scsi_tmf_1]

root         516  0.0  0.0      0     0 ?        S    Apr21   0:00 [scsi_eh_2]

root         517  0.0  0.0      0     0 ?        I<   Apr21   0:00 [scsi_tmf_2]

root         529  0.0  0.0      0     0 ?        I<   Apr21   0:00 [kworker/5:1H

root         531  0.0  0.0      0     0 ?        I<   Apr21   0:01 [kworker/6:1H

root         533  0.0  0.0      0     0 ?        I<   Apr21   0:01 [kworker/7:1H

root         534  0.0  0.0      0     0 ?        I<   Apr21   0:02 [kworker/4:1H

root         536  0.0  0.0      0     0 ?        I<   Apr21   0:01 [kworker/1:1H

root         537  0.0  0.0      0     0 ?        I<   Apr21   0:01 [kworker/3:1H

root         538  0.0  0.0      0     0 ?        I<   Apr21   0:01 [kworker/2:1H

root         590  0.0  0.0      0     0 ?        I<   Apr21   0:00 [kdmflush]

root         612  0.0  0.0      0     0 ?        I<   Apr21   0:01 [kworker/0:1H

root         624  0.0  0.0      0     0 ?        S    Apr21   0:02 [jbd2/dm-0-8]

root         625  0.0  0.0      0     0 ?        I<   Apr21   0:00 [ext4-rsv-con

root         725  0.0  0.7 147952 57728 ?        Ss   Apr21   0:12 /usr/lib/syst

root         762  0.0  0.1 120840 14144 ?        Ss   Apr21   0:02 /usr/lib/syst

root         843  0.0  0.0      0     0 ?        I<   Apr21   0:00 [ttm_swap]

root         863  0.0  0.0      0     0 ?        S    Apr21   0:00 [jbd2/sda1-8]

root         864  0.0  0.0      0     0 ?        I<   Apr21   0:00 [ext4-rsv-con

rpc          887  0.0  0.0  67120  5576 ?        Ss   Apr21   0:00 /usr/bin/rpcb

root         890  0.0  0.0      0     0 ?        I<   Apr21   0:00 [rpciod]

root         891  0.0  0.0      0     0 ?        I<   Apr21   0:00 [kworker/u481

root         892  0.0  0.0      0     0 ?        I<   Apr21   0:00 [xprtiod]

root         896  0.0  0.0 149416  2604 ?        S<sl Apr21   0:02 /sbin/auditd

root         898  0.0  0.0  48484  2096 ?        S<   Apr21   0:00 /usr/sbin/sed

root         920  0.0  0.0  26444  4812 ?        Ss   Apr21   0:00 /usr/sbin/sma

root         922  0.0  0.1 212416 13876 ?        Ss   Apr21   0:00 /usr/sbin/sss

libstor+     923  0.0  0.0  18872  2040 ?        Ss   Apr21   0:00 /usr/bin/lsmd

root         924  0.0  0.0  83544  7048 ?        Ss   Apr21   0:04 /usr/lib/syst

root         925  0.0  0.0 124708  4604 ?        Ssl  Apr21   0:08 /usr/sbin/irq

root         926  0.0  0.1 462748 14448 ?        Ssl  Apr21   0:00 /usr/sbin/Mod

polkitd      927  0.0  0.5 2050112 39912 ?       Ssl  Apr21   1:44 /usr/lib/polk

avahi        930  0.0  0.0  82748  5172 ?        Ss   Apr21   0:13 avahi-daemon:

rtkit        932  0.0  0.0 201936  3764 ?        SNsl Apr21   0:02 /usr/libexec/

dbus         933  0.0  0.0  73420  7924 ?        Ssl  Apr21   1:15 /usr/bin/dbus

root         934  0.0  0.2 406232 18984 ?        Ssl  Apr21   2:33 /usr/sbin/Net

root         936  0.0  0.0  16892  2244 ?        Ss   Apr21   0:00 /usr/sbin/mce

root         945  0.0  0.0 101752  3688 ?        Ssl  Apr21   0:00 /usr/sbin/gss

rngd         961  0.0  0.0 160228  6760 ?        Ssl  Apr21   0:13 /sbin/rngd -f

avahi        962  0.0  0.0  82620   428 ?        S    Apr21   0:00 avahi-daemon:

root         965  0.0  0.1 137148 10360 ?        Ss   Apr21   0:00 /usr/sbin/cup

root         967  0.0  0.2 225740 21208 ?        Ss   Apr21   0:09 php-fpm: mast

root         973  0.0  0.0  95088  7668 ?        Ss   Apr21   0:00 /usr/sbin/ssh

root         978  0.0  0.0  41572  2208 ?        Ss   Apr21   0:00 /usr/bin/rhsm

root         980  0.0  0.0  25760  2712 ?        S    Apr21   0:03 /bin/bash /us

root        1022  0.0  0.1 219424 15408 ?        S    Apr21   0:02 /usr/libexec/

mysql       1064  0.0  1.9 1927896 155936 ?      Ssl  Apr21   2:09 /usr/libexec/

root        1066  0.0  0.4 221360 38544 ?        S    Apr21   0:08 /usr/libexec/

root        1084  0.0  0.4 267412 37920 ?        Ssl  Apr21   0:12 /usr/sbin/rsy

root        1090  0.0  0.1 325780  9892 ?        Ssl  Apr21   0:02 /usr/libexec/

root        1091  0.0  0.1  98056 10184 ?        Ss   Apr21   0:12 /usr/lib/syst

root        1106  0.0  0.0  36088  3708 ?        Ss   Apr21   0:02 /usr/sbin/cro

root        1107  0.0  0.1 340220 13344 ?        Ssl  Apr21   0:00 /usr/sbin/gdm

root        1109  0.0  0.0  42624  2544 ?        Ss   Apr21   0:00 /usr/sbin/atd

apache      1325  0.0  0.1 240936 12516 ?        S    Apr21   0:00 php-fpm: pool

apache      1326  0.0  0.1 240936 12516 ?        S    Apr21   0:00 php-fpm: pool

apache      1327  0.0  0.1 240936 12516 ?        S    Apr21   0:00 php-fpm: pool

apache      1328  0.0  0.1 240936 12520 ?        S    Apr21   0:00 php-fpm: pool

apache      1329  0.0  0.1 240936 12520 ?        S    Apr21   0:00 php-fpm: pool

root        1441  0.0  0.5 1828764 43492 ?       Ssl  Apr21   0:00 /usr/sbin/lib

root        1832  0.0  0.1 328292 13712 ?        Sl   Apr21   0:00 gdm-session-w

gdm         1841  0.0  0.1  93992  9928 ?        Ss   Apr21   0:04 /usr/lib/syst

gdm         1844  0.0  0.0 319248  5544 ?        S    Apr21   0:00 (sd-pam)

gdm         1858  0.0  0.1 797436  8528 ?        Ssl  Apr21   0:00 /usr/bin/puls

gdm         1859  0.0  0.0  82996  6208 ?        Ssl  Apr21   0:00 /usr/bin/dbus

gdm         1861  0.0  0.1 340112 13108 tty1     Ssl+ Apr21   0:00 /usr/libexec/

gdm         1867  0.0  0.2 584720 17224 tty1     Sl+  Apr21   0:01 /usr/libexec/

dnsmasq     1972  0.0  0.0  71888  2316 ?        S    Apr21   0:00 /usr/sbin/dns

root        1973  0.0  0.0  71860   432 ?        S    Apr21   0:00 /usr/sbin/dns

gdm         1991  0.0  3.2 4414544 258828 tty1   Sl+  Apr21   1:24 /usr/bin/gnom

gdm         2034  0.0  0.6 1433232 54336 tty1    Sl+  Apr21   0:00 /usr/bin/Xway

gdm         2055  0.0  0.1 372008  8864 ?        Ssl  Apr21   0:00 /usr/libexec/

gdm         2060  0.0  0.0  82620  5868 ?        Sl   Apr21   0:00 /usr/bin/dbus

gdm         2064  0.0  0.1 248440  8684 ?        Sl   Apr21   0:00 /usr/libexec/

gdm         2099  0.0  0.1 387220 10264 tty1     Sl   Apr21   0:00 ibus-daemon -

gdm         2101  0.0  0.8 1559964 68752 tty1    Sl+  Apr21   0:00 /usr/libexec/

gdm         2102  0.0  0.7 1843764 63320 tty1    Sl+  Apr21   0:00 /usr/libexec/

gdm         2104  0.0  0.1 302588  8276 tty1     Sl   Apr21   0:00 /usr/libexec/

gdm         2108  0.0  0.1 301408  8440 tty1     Sl+  Apr21   0:00 /usr/libexec/

gdm         2110  0.0  0.7 1693316 62732 tty1    Sl   Apr21   0:00 /usr/libexec/

gdm         2112  0.0  0.7 1692868 61520 tty1    Sl+  Apr21   0:00 /usr/libexec/

gdm         2116  0.0  0.1 302568 10476 ?        Sl   Apr21   0:00 /usr/libexec/

gdm         2118  0.0  0.3 688896 25124 tty1     Sl+  Apr21   0:01 /usr/libexec/

gdm         2122  0.0  0.2 381724 16200 tty1     Sl+  Apr21   0:00 /usr/libexec/

gdm         2125  0.0  0.1 305720  8164 tty1     Sl+  Apr21   0:00 /usr/libexec/

gdm         2126  0.0  0.3 524984 25800 tty1     Sl+  Apr21   0:00 /usr/libexec/

gdm         2197  0.0  0.3 1121892 27076 tty1    Sl+  Apr21   0:01 /usr/libexec/

gdm         2204  0.0  0.1 225416  9396 tty1     Sl+  Apr21   0:00 /usr/libexec/

gdm         2205  0.0  0.3 549152 26076 tty1     Sl+  Apr21   0:01 /usr/libexec/

gdm         2208  0.0  0.1 277396  9864 tty1     Sl+  Apr21   0:00 /usr/libexec/

gdm         2209  0.0  0.0 230172  7504 tty1     Sl+  Apr21   0:00 /usr/libexec/

gdm         2218  0.0  0.0 299152  7808 tty1     Sl+  Apr21   0:00 /usr/libexec/

gdm         2224  0.0  0.1 307400 11128 tty1     Sl+  Apr21   0:00 /usr/libexec/

gdm         2231  0.0  0.1 473972 14384 tty1     Sl+  Apr21   0:22 /usr/libexec/

gdm         2238  0.0  0.1 366916 11224 tty1     Sl+  Apr21   0:00 /usr/libexec/

gdm         2242  0.0  0.2 509816 23696 tty1     Sl+  Apr21   0:00 /usr/libexec/

root        2255  0.0  0.1 320796  9672 ?        Ssl  Apr21   0:01 /usr/libexec/

colord      2256  0.0  0.1 345272 15772 ?        Ssl  Apr21   0:00 /usr/libexec/

gdm         2285  0.0  0.1 308848  8540 ?        Ssl  Apr21   0:00 /usr/libexec/

root        2303  0.0  0.0  60944  5816 ?        Ss   Apr21   0:00 /usr/sbin/wpa

gdm         2334  0.0  0.1 228904  8336 tty1     Sl   Apr21   0:00 /usr/libexec/

root       13838  0.0  0.2 552368 16448 ?        Ssl  Apr21   0:08 /usr/libexec/

root       14151  0.0  0.4 548228 35024 ?        Ssl  Apr21   0:05 /usr/libexec/

root       14159  0.0  0.1 321992  9936 ?        Ssl  Apr21   0:01 /usr/libexec/

root       86032  0.0  0.0      0     0 ?        I    11:33   0:05 [kworker/2:3-

root       89280  0.0  0.0      0     0 ?        I    13:58   0:01 [kworker/0:2-

root       89665  0.0  0.0      0     0 ?        I    14:16   0:00 [kworker/3:2-

root       89717  0.0  0.0      0     0 ?        I    14:18   0:01 [kworker/4:2-

root       90092  0.0  0.0      0     0 ?        I    14:34   0:00 [kworker/6:2-

root       90133  0.0  0.0      0     0 ?        I    14:36   0:00 [kworker/1:1-

root       90231  0.0  0.0      0     0 ?        I    14:38   0:00 [kworker/u480

root       90352  0.0  0.0      0     0 ?        I    14:44   0:00 [kworker/u480

root       90587  0.0  0.0      0     0 ?        I    14:55   0:00 [kworker/0:0-

root       90588  0.0  0.0      0     0 ?        I    14:55   0:00 [kworker/6:1-

root       90591  0.0  0.0      0     0 ?        I    14:55   0:00 [kworker/3:1-

root       90597  0.1  0.0      0     0 ?        I    14:55   0:01 [kworker/7:2-

root       90603  0.0  0.0      0     0 ?        I    14:55   0:00 [kworker/7:3-

root       90605  0.0  0.0      0     0 ?        I    14:55   0:00 [kworker/5:1-

root       90611  0.0  0.0      0     0 ?        I    14:55   0:00 [kworker/5:3-

root       90671  0.0  0.1 170292 11816 ?        Ss   14:56   0:00 sshd: root [p

root       90676  0.0  0.1  93728  9748 ?        Ss   14:56   0:00 /usr/lib/syst

root       90683  0.0  0.0 314368  5528 ?        S    14:56   0:00 (sd-pam)

root       90701  0.0  0.1 234652  9372 ?        S<sl 14:56   0:00 /usr/bin/puls

root       90702  0.0  0.0 170396  6340 ?        S    14:56   0:00 sshd: root@pt

root       90707  0.0  0.0  82596  5404 ?        Ssl  14:56   0:00 /usr/bin/dbus

root       90710  0.0  0.0  27204  5832 pts/0    Ss   14:56   0:00 -bash

root       90812  0.0  0.0      0     0 ?        I    14:59   0:00 [kworker/2:1-

root       90821  0.0  0.0      0     0 ?        I    15:00   0:00 [kworker/u480

root       90825  0.2  0.0      0     0 ?        I    15:00   0:01 [kworker/4:1-

root       90868  0.0  0.0      0     0 ?        I    15:02   0:00 [kworker/1:2-

root       90917  0.0  0.0      0     0 ?        I    15:04   0:00 [kworker/6:0-

root       90939  0.0  0.0      0     0 ?        I    15:05   0:00 [kworker/2:0-

root       90956  0.0  0.0      0     0 ?        I    15:06   0:00 [kworker/u480

root       90960  0.0  0.0      0     0 ?        I    15:06   0:00 [kworker/0:1-

root       91025  0.0  0.0   7280   792 ?        S    15:08   0:00 sleep 60

root       91028  0.0  0.0  57820  3980 pts/0    R+   15:09   0:00 ps aux



Tracking a Process:

 

[root@Polylms Desktop]# pwd &

[1] 91076

/root/Desktop

[root@Polylms Desktop]# ps

    PID TTY          TIME CMD

  90710 pts/0    00:00:00 bash

  91077 pts/0    00:00:00 ps

[1]+  Done                    pwd

[root@Polylms Desktop]# ping google.com

PING google.com (172.217.26.238) 56(84) bytes of data.

64 bytes from bom05s09-in-f14.1e100.net (172.217.26.238): icmp_seq=1 ttl=117 time=7.70 ms

64 bytes from bom05s09-in-f14.1e100.net (172.217.26.238): icmp_seq=2 ttl=117 time=4.86 ms

64 bytes from bom05s09-in-f14.1e100.net (172.217.26.238): icmp_seq=3 ttl=117 time=3.03 ms

64 bytes from bom05s09-in-f14.1e100.net (172.217.26.238): icmp_seq=4 ttl=117 time=2.60 ms

64 bytes from bom05s09-in-f14.1e100.net (172.217.26.238): icmp_seq=5 ttl=117 time=2.60 ms

^Z

[1]+  Stopped                 ping google.com

[root@Polylms Desktop]# ps

    PID TTY          TIME CMD

  90710 pts/0    00:00:00 bash

  91105 pts/0    00:00:00 ping

  91107 pts/0    00:00:00 ps

[root@Polylms Desktop]#


All running process 


 

[root@Polylms Desktop]# ps -f

UID          PID    PPID  C STIME TTY          TIME CMD

root       90710   90702  0 14:56 pts/0    00:00:00 -bash

root       91105   90710  0 15:12 pts/0    00:00:00 ping google.com

root       91157   90710  0 15:14 pts/0    00:00:00 ps -f

[root@Polylms Desktop]#


Process running from current user

[root@Polylms Desktop]# ps -u

USER         PID %CPU %MEM    VSZ   RSS TTY      STAT START   TIME COMMAND

root       90710  0.0  0.0  27204  5836 pts/0    Ss   14:56   0:00 -bash

root       91105  0.0  0.0  36604  4124 pts/0    T    15:12   0:00 ping google.c

root       91158  0.0  0.0  57820  3924 pts/0    R+   15:15   0:00 ps -u


Stopping a Process :

 


Kill -9 (PID)


[root@Polylms Desktop]# ps

    PID TTY          TIME CMD

  90710 pts/0    00:00:00 bash

  91105 pts/0    00:00:00 ping

  91251 pts/0    00:00:00 ps

[root@Polylms Desktop]# kill -l

 1) SIGHUP       2) SIGINT       3) SIGQUIT      4) SIGILL       5) SIGTRAP

 6) SIGABRT      7) SIGBUS       8) SIGFPE       9) SIGKILL     10) SIGUSR1

11) SIGSEGV     12) SIGUSR2     13) SIGPIPE     14) SIGALRM     15) SIGTERM

16) SIGSTKFLT   17) SIGCHLD     18) SIGCONT     19) SIGSTOP     20) SIGTSTP

21) SIGTTIN     22) SIGTTOU     23) SIGURG      24) SIGXCPU     25) SIGXFSZ

26) SIGVTALRM   27) SIGPROF     28) SIGWINCH    29) SIGIO       30) SIGPWR

31) SIGSYS      34) SIGRTMIN    35) SIGRTMIN+1  36) SIGRTMIN+2  37) SIGRTMIN+3

38) SIGRTMIN+4  39) SIGRTMIN+5  40) SIGRTMIN+6  41) SIGRTMIN+7  42) SIGRTMIN+8

43) SIGRTMIN+9  44) SIGRTMIN+10 45) SIGRTMIN+11 46) SIGRTMIN+12 47) SIGRTMIN+13

48) SIGRTMIN+14 49) SIGRTMIN+15 50) SIGRTMAX-14 51) SIGRTMAX-13 52) SIGRTMAX-12

53) SIGRTMAX-11 54) SIGRTMAX-10 55) SIGRTMAX-9  56) SIGRTMAX-8  57) SIGRTMAX-7

58) SIGRTMAX-6  59) SIGRTMAX-5  60) SIGRTMAX-4  61) SIGRTMAX-3  62) SIGRTMAX-2

63) SIGRTMAX-1  64) SIGRTMAX

[root@Polylms Desktop]# ps

    PID TTY          TIME CMD

  90710 pts/0    00:00:00 bash

  91105 pts/0    00:00:00 ping

  91343 pts/0    00:00:00 ps

[root@Polylms Desktop]# kill -9 91105

[root@Polylms Desktop]# ps

    PID TTY          TIME CMD

  90710 pts/0    00:00:00 bash

  91374 pts/0    00:00:00 ps

[1]+  Killed                  ping google.com

[root@Polylms Desktop]#

 


 

 


 


To Check disk in Linux

 

[root@Polylms Desktop]# top

top - 17:05:03 up 1 day, 22:22,  1 user,  load average: 0.00, 0.00, 0.00

Tasks: 210 total,   1 running, 208 sleeping,   1 stopped,   0 zombie

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

MiB Mem :   7758.8 total,   3365.8 free,    958.5 used,   3434.6 buff/cache

MiB Swap:      0.0 total,      0.0 free,      0.0 used.   6464.8 avail Mem


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

    934 root      20   0  406232  18984  16296 S   0.3   0.2   2:42.39 Network+

  93413 root      20   0       0      0      0 I   0.3   0.0   0:00.17 kworker+

  93471 root      20   0   64612   4924   4032 R   0.3   0.1   0:00.09 top

      1 root      20   0  253688  14388   9124 S   0.0   0.2   0:46.20 systemd

      2 root      20   0       0      0      0 S   0.0   0.0   0:00.35 kthreadd

      3 root       0 -20       0      0      0 I   0.0   0.0   0:00.00 rcu_gp

      4 root       0 -20       0      0      0 I   0.0   0.0   0:00.00 rcu_par+

      6 root       0 -20       0      0      0 I   0.0   0.0   0:00.00 kworker+

      8 root       0 -20       0      0      0 I   0.0   0.0   0:00.00 mm_perc+

      9 root      20   0       0      0      0 S   0.0   0.0   0:00.23 ksoftir+

     10 root      20   0       0      0      0 I   0.0   0.0   0:20.39 rcu_sch+

     11 root      rt   0       0      0      0 S   0.0   0.0   0:00.01 migrati+

     12 root      rt   0       0      0      0 S   0.0   0.0   0:00.08 watchdo+

     13 root      20   0       0      0      0 S   0.0   0.0   0:00.00 cpuhp/0

     14 root      20   0       0      0      0 S   0.0   0.0   0:00.00 cpuhp/1

     15 root      rt   0       0      0      0 S   0.0   0.0   0:00.29 watchdo+

     16 root      rt   0       0      0      0 S   0.0   0.0   0:00.01 migrati+

[root@Polylms Desktop]#


[root@Polylms ~]# cat >1.txt

This is test file

thankyou^Z

[1]+  Stopped                 cat > 1.txt

[root@Polylms ~]# ps -l

F S   UID     PID    PPID  C PRI  NI ADDR SZ WCHAN  TTY          TIME CMD

0 S     0   93646   93634  0  80   0 -  6672 -      pts/0    00:00:00 bash

4 T     0   93672   93646  0  80   0 -  1855 -      pts/0    00:00:00 cat

0 R     0   93673   93646  0  80   0 - 11351 -      pts/0    00:00:00 ps

[root@Polylms ~]# top

top - 17:09:45 up 1 day, 22:27,  1 user,  load average: 0.00, 0.00, 0.00

Tasks: 215 total,   1 running, 213 sleeping,   1 stopped,   0 zombie

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

MiB Mem :   7758.8 total,   3368.4 free,    955.8 used,   3434.6 buff/cache

MiB Swap:      0.0 total,      0.0 free,      0.0 used.   6467.5 avail Mem


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

      1 root      20   0  253688  14388   9124 S   0.0   0.2   0:46.29 systemd

      2 root      20   0       0      0      0 S   0.0   0.0   0:00.35 kthreadd

      3 root       0 -20       0      0      0 I   0.0   0.0   0:00.00 rcu_gp

      4 root       0 -20       0      0      0 I   0.0   0.0   0:00.00 rcu_par+

      6 root       0 -20       0      0      0 I   0.0   0.0   0:00.00 kworker+

      8 root       0 -20       0      0      0 I   0.0   0.0   0:00.00 mm_perc+

      9 root      20   0       0      0      0 S   0.0   0.0   0:00.23 ksoftir+

     10 root      20   0       0      0      0 I   0.0   0.0   0:20.43 rcu_sch+

     11 root      rt   0       0      0      0 S   0.0   0.0   0:00.01 migrati+

     12 root      rt   0       0      0      0 S   0.0   0.0   0:00.08 watchdo+

     13 root      20   0       0      0      0 S   0.0   0.0   0:00.00 cpuhp/0

     14 root      20   0       0      0      0 S   0.0   0.0   0:00.00 cpuhp/1

     15 root      rt   0       0      0      0 S   0.0   0.0   0:00.29 watchdo+

     16 root      rt   0       0      0      0 S   0.0   0.0   0:00.01 migrati+

     17 root      20   0       0      0      0 S   0.0   0.0   0:00.21 ksoftir+

     19 root       0 -20       0      0      0 I   0.0   0.0   0:00.00 kworker+

     20 root      20   0       0      0      0 S   0.0   0.0   0:00.00 cpuhp/2

[2]+  Stopped                 top

[root@Polylms ~]# nice -19 cat

^Z

[3]+  Stopped                 nice -19 cat

[root@Polylms ~]# nice -19 cat &

[5] 93715

[root@Polylms ~]# nice --19 cat &

[6] 93724


[5]+  Stopped                 nice -19 cat

[root@Polylms ~]# ps -l

F S   UID     PID    PPID  C PRI  NI ADDR SZ WCHAN  TTY          TIME CMD

0 S     0   93646   93634  0  80   0 -  6672 -      pts/0    00:00:00 bash

4 T     0   93672   93646  0  80   0 -  1855 -      pts/0    00:00:00 cat

0 T     0   93682   93646  0  80   0 - 16155 -      pts/0    00:00:00 top

0 T     0   93683   93646  0  99  19 -  1855 -      pts/0    00:00:00 cat

0 T     0   93713   93646  0  99  19 -  1855 -      pts/0    00:00:00 cat

0 T     0   93715   93646  0  99  19 -  1855 -      pts/0    00:00:00 cat

4 T     0   93724   93646  0  61 -19 -  1855 -      pts/0    00:00:00 cat

0 R     0   93725   93646  0  80   0 - 11351 -      pts/0    00:00:00 ps


[6]+  Stopped                 nice --19 cat

[root@Polylms ~]# kill -9 93724

[root@Polylms ~]# ps -l

F S   UID     PID    PPID  C PRI  NI ADDR SZ WCHAN  TTY          TIME CMD

0 S     0   93646   93634  0  80   0 -  6672 -      pts/0    00:00:00 bash

4 T     0   93672   93646  0  80   0 -  1855 -      pts/0    00:00:00 cat

0 T     0   93682   93646  0  80   0 - 16155 -      pts/0    00:00:00 top

0 T     0   93683   93646  0  99  19 -  1855 -      pts/0    00:00:00 cat

0 T     0   93713   93646  0  99  19 -  1855 -      pts/0    00:00:00 cat

0 T     0   93715   93646  0  99  19 -  1855 -      pts/0    00:00:00 cat

0 R     0   93726   93646  0  80   0 - 11351 -      pts/0    00:00:00 ps

[6]+  Killed                  nice --19 cat

[root@Polylms ~]#

[root@Polylms ~]# renice -6 93715

93715 (process ID) old priority 19, new priority -6

[root@Polylms ~]# ps -l

F S   UID     PID    PPID  C PRI  NI ADDR SZ WCHAN  TTY          TIME CMD

0 S     0   93646   93634  0  80   0 -  6801 -      pts/0    00:00:00 bash

4 T     0   93672   93646  0  80   0 -  1855 -      pts/0    00:00:00 cat

0 T     0   93682   93646  0  80   0 - 16155 -      pts/0    00:00:00 top

0 T     0   93683   93646  0  99  19 -  1855 -      pts/0    00:00:00 cat

0 T     0   93713   93646  0  99  19 -  1855 -      pts/0    00:00:00 cat

0 T     0   93715   93646  0  74  -6 -  1855 -      pts/0    00:00:00 cat

0 R     0   93766   93646  0  80   0 - 11351 -      pts/0    00:00:00 ps


[root@Polylms ~]# df

Filesystem          1K-blocks     Used Available Use% Mounted on

devtmpfs              3943904        0   3943904   0% /dev

tmpfs                 3972524        0   3972524   0% /dev/shm

tmpfs                 3972524    33892   3938632   1% /run

tmpfs                 3972524        0   3972524   0% /sys/fs/cgroup

/dev/mapper/cl-root 100619320 16230812  79234308  18% /

/dev/sda1             1998672   198200   1679232  11% /boot

tmpfs                  794504     4296    790208   1% /run/user/42

/dev/sr0              8037456  8037456         0 100% /run/media/root/CentOS-8-2-2004-x86_64-dvd

tmpfs                  794504        4    794500   1% /run/user/0

[root@Polylms ~]#



[root@Polylms ~]# df -l

Filesystem          1K-blocks     Used Available Use% Mounted on

devtmpfs              3943904        0   3943904   0% /dev

tmpfs                 3972524        0   3972524   0% /dev/shm

tmpfs                 3972524    33892   3938632   1% /run

tmpfs                 3972524        0   3972524   0% /sys/fs/cgroup

/dev/mapper/cl-root 100619320 16230812  79234308  18% /

/dev/sda1             1998672   198200   1679232  11% /boot

tmpfs                  794504     4296    790208   1% /run/user/42

/dev/sr0              8037456  8037456         0 100% /run/media/root/CentOS-8-2-2004-x86_64-dvd

tmpfs                  794504        4    794500   1% /run/user/0

[root@Polylms ~]#



Shell Script

[root@Polylms ~]# cat /etc/redhat-release

CentOS Linux release 8.2.2004 (Core)

[root@Polylms ~]#


VIM : To insert in vim , first press I then after writing use esc key and Press Shift:wq to save and quit

Shell Script :

 

 

#!/bin/bash   This is bash

# This is a Sample Script to check purpose of script

#author : prashant, Polycab India Limited


echo "Hi World, i am New Learner Prashant in Linux World”.

echo "..........Linux admin"

echo "This is my first script”. 

[root@Polylms ~]# touch 1.sh

[root@Polylms ~]# vim 1.sh

[root@Polylms ~]# ls

 1.sh              demo       '[gurukul_backup.sql]'     Pictures      Videos

 1.shM-D           Desktop     gurukul.polycab.com.csr   Public

 1.txt             Documents   gurukul.polycab.com.key   shellsample

 anaconda-ks.cfg   Downloads   Music                     Templates

[root@Polylms ~]# df

Filesystem          1K-blocks     Used Available Use% Mounted on

devtmpfs              3943904        0   3943904   0% /dev

tmpfs                 3972524        0   3972524   0% /dev/shm

tmpfs                 3972524    33900   3938624   1% /run

tmpfs                 3972524        0   3972524   0% /sys/fs/cgroup

/dev/mapper/cl-root 100619320 16231220  79233900  18% /

/dev/sda1             1998672   198200   1679232  11% /boot

tmpfs                  794504     4296    790208   1% /run/user/42

/dev/sr0              8037456  8037456         0 100% /run/media/root/CentOS-8-2-2004-x86_64-dvd

tmpfs                  794504        4    794500   1% /run/user/0

[root@Polylms ~]# ls -l

total 64

-rw-r--r--. 1 root root   79 Apr 23 22:12  1.sh

-rw-r--r--. 1 root root   24 Apr 23 00:06  1.shM-D

-rw-r--r--. 1 root root   18 Apr 23 17:09  1.txt

-rw-------. 1 root root 1721 Aug 17  2020  anaconda-ks.cfg

drwxr-xr-x. 3 root root 4096 Apr 22 20:07  demo

drwxr-xr-x. 5 root root 4096 Apr 23 15:02  Desktop

drwxr-xr-x. 2 root root 4096 Aug 18  2020  Documents

drwxr-xr-x. 2 root root 4096 Apr 23 14:58  Downloads

-rw-r--r--. 1 root root    0 Apr 22 09:58 '[gurukul_backup.sql]'

-rw-r--r--. 1 root root 1127 Aug 28  2020  gurukul.polycab.com.csr

-rw-------. 1 root root 1704 Aug 28  2020  gurukul.polycab.com.key

drwxr-xr-x. 2 root root 4096 Aug 18  2020  Music

drwxr-xr-x. 2 root root 4096 Aug 18  2020  Pictures

drwxr-xr-x. 2 root root 4096 Aug 18  2020  Public

drwxr-xr-x. 2 root root 4096 Apr 23 20:21  shellsample

drwxr-xr-x. 2 root root 4096 Aug 18  2020  Templates

drwxr-xr-x. 2 root root 4096 Aug 18  2020  Videos

[root@Polylms ~]# chmod 755 1.sh

[root@Polylms ~]# ls -l

total 64

-rwxr-xr-x. 1 root root   79 Apr 23 22:12  1.sh

-rw-r--r--. 1 root root   24 Apr 23 00:06  1.shM-D

-rw-r--r--. 1 root root   18 Apr 23 17:09  1.txt

-rw-------. 1 root root 1721 Aug 17  2020  anaconda-ks.cfg

drwxr-xr-x. 3 root root 4096 Apr 22 20:07  demo

drwxr-xr-x. 5 root root 4096 Apr 23 15:02  Desktop

drwxr-xr-x. 2 root root 4096 Aug 18  2020  Documents

drwxr-xr-x. 2 root root 4096 Apr 23 14:58  Downloads

-rw-r--r--. 1 root root    0 Apr 22 09:58 '[gurukul_backup.sql]'

-rw-r--r--. 1 root root 1127 Aug 28  2020  gurukul.polycab.com.csr

-rw-------. 1 root root 1704 Aug 28  2020  gurukul.polycab.com.key

drwxr-xr-x. 2 root root 4096 Aug 18  2020  Music

drwxr-xr-x. 2 root root 4096 Aug 18  2020  Pictures

drwxr-xr-x. 2 root root 4096 Aug 18  2020  Public

drwxr-xr-x. 2 root root 4096 Apr 23 20:21  shellsample

drwxr-xr-x. 2 root root 4096 Aug 18  2020  Templates

drwxr-xr-x. 2 root root 4096 Aug 18  2020  Videos

[root@Polylms ~]# cd 1.sh

-bash: cd: 1.sh: Not a directory

[root@Polylms ~]# vim 1.sh

[root@Polylms ~]# ./1.sh

./1.sh: line 2: Author: command not found

HI Prashant

You are great learner


[root@Polylms ~]# bash 1.sh

1.sh: line 2: Author: command not found

HI Prashant

You are great learner


[root@Polylms ~]# ll

total 64

eg2.


[root@Polylms shellsample]# touch 2.sh

[root@Polylms shellsample]# vim 2.sh

[root@Polylms shellsample]# ll

total 8

-rw-r--r--. 1 root root  76 Apr 23 22:23 2.sh

-rwxr-xr-x. 1 root root 226 Apr 23 18:00 hello-world.bash

[root@Polylms shellsample]# chmod 755 2.sh

[root@Polylms shellsample]# ll

total 8

-rwxr-xr-x. 1 root root  76 Apr 23 22:23 2.sh

-rwxr-xr-x. 1 root root 226 Apr 23 18:00 hello-world.bash

[root@Polylms shellsample]# bash 2.sh

/root/shellsample

2.sh  hello-world.bash

[root@Polylms shellsample]# ./2.sh

/root/shellsample

2.sh  hello-world.bash


Eg,3

#!/bin/bash

#author :lucky

#copyright @ Ps

#Script follows here

pwd

echo "______________"


ls

echo "....................."

date

echo "..............."

ls -l /boot

exit

~


Output of above will be :

[root@Polylms shellsample]# ./2.sh

/root/shellsample

______________

2.sh  hello-world.bash

.....................

Fri Apr 23 22:27:21 IST 2021

...............

total 186456

-rw-r--r--. 1 root root   187648 May  8  2020 config-4.18.0-193.el8.x86_64

drwxr-xr-x. 3 root root     4096 Aug 17  2020 efi

drwx------. 4 root root     4096 Aug 18  2020 grub2

-rw-------. 1 root root 98497222 Aug 17  2020 initramfs-0-rescue-4e84ba0d27694c87bdf06115e59f947b.img

-rw-------. 1 root root 51733708 Aug 17  2020 initramfs-4.18.0-193.el8.x86_64.img

-rw-------. 1 root root 18730198 Aug 18  2020 initramfs-4.18.0-193.el8.x86_64kdump.img

drwxr-xr-x. 3 root root     4096 Aug 17  2020 loader

drwx------. 2 root root    16384 Aug 17  2020 lost+found

-rw-------. 1 root root  3909996 May  8  2020 System.map-4.18.0-193.el8.x86_64

-rwxr-xr-x. 1 root root  8913656 Aug 17  2020 vmlinuz-0-rescue-4e84ba0d27694c87bdf06115e59f947b

-rwxr-xr-x. 1 root root  8913656 May  8  2020 vmlinuz-4.18.0-193.el8.x86_64


 


Eg:

[root@Polylms shellsample]# touch 3.sh

[root@Polylms shellsample]# vim 3.sh

[root@Polylms shellsample]# chmod 755 3.sh

[root@Polylms shellsample]# chmod 755 3.sh

[root@Polylms shellsample]# ll

total 12

-rwxr-xr-x. 1 root root 169 Apr 23 22:27 2.sh

-rwxr-xr-x. 1 root root 218 Apr 23 23:04 3.sh

-rwxr-xr-x. 1 root root 226 Apr 23 18:00 hello-world.bash

[root@Polylms shellsample]# vim 3.sh

  #!/bin/bash

 #I am creating new file

 touch file1 file2 file3

 echo -n "Enter name of file to delete: "

 read file

 echo Type 'y' to remove it,'n' to change your mind...

 rm -i $file

 echo That was your decision!

[root@Polylms shellsample]# vim 3.sh

[root@Polylms shellsample]# ./3.sh

Enter name of file to delete:  file1

Type y to remove it,n to change your mind...

rm: remove regular empty file 'file1'? y

That was your decision!

[root@Polylms shellsample]#


Comments

Popular posts from this blog

CCNA Router and Catalyst Switch IOS Command Reference

Network Technologies

About myself