0% found this document useful (0 votes)
1 views

All-Linux-Commmands

Uploaded by

litaleg220
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
1 views

All-Linux-Commmands

Uploaded by

litaleg220
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 25

All_Commands_of_Linux

[root@localhost ~]# or $
root @ localhost ~ # or $
Username Separater Machine_Name Working_Directory Symbol of
SuperUser
(RootUser)
Symbol of
RegularUser

There are 6 Terminals in Linux known as TTY1 – TTY6. It is known as Teletype.


tty1-tty2-tty3-tty4-tty5-tty6
tty1 tty2 tty3 tty4 tty5 tty6
LoginScreen Terminal 1 CLI CLI CLI CLI
(GUI) (Command (Command (Command (Command
Prompt) Prompt) Prompt) Prompt)

Commands

#tty It is known as Teletype (TTY1-TTY6) and they have unlimited pts.


#chvt1..chvt6
#who This command is help us to know what user or superuser running on
present tty(virtual_machine).
#whoami This command is used to know the name of username of working to
machine.
#w This command is help us to know what user or superuser running on
which tty(virtual_machine).
#ls This command is used to known as short-list.In this command we can see
what present directory has.
#ll This command is used to known as long-list. In this command we can see
everything about folders or files inside the present
directory.(permissions,user_who_created_group_user,date,timing)
#which ls This command help us to know where the command present which folder
is in it.
#pwd This command used to see present workind directory.
#useradd username This command used to create a user just by giving the name.
#passwd username This command used to give password to user which we created.
#useradd --u 1000 username This command to give user_id to user.
#userdel username This command used to delete the user but not their date or home
OR directory.

#userdel –r username To delete user account with their home-directory.


#useradd --comment”Admin” This command used to give comment to user.
username
OR
#usermod –c “Admin” username This cmd used to add comment after create user.
#usermod –m –d /newfolder username To change the home-directory of user.
OR
#usermod –md /marvel username
#usermod –s /sbin/nologin username To change the shell of user. (/sbin/nologin -> now user can not work in
shell)
To correct it.
#usermod –s /bin/bash username
#usermod –L username This command is used to Lock the user to login.
#usermod –S username To check the status of user Lock or not.
#usermod –U username This command is used to UnLock the user to login.
#su – username This command used to switch B/w one user to another_User.
#logout This command used to logout from the user to previous_user.
#exit This command used to exit from the user to previous_user
#mkdir (blue) This command used to create folder.
#mkdir harish ; cd marvel ; = semicolon used to run multiple commands in one line or in one time.
#date This command used to know the [date,week_day,time,year]
#date +%R To know the Time.
#date +%r To know the Time.pm or am
#file filename or foldername This command used to know the type of file or folder type.
#cat /etc/passwd This command used to see content inside the directory or file.
#cat file1 file2 This command used to see content inside multiple the directory or file.
#cat file1 > file2 This command used to transfer file2 content to file1 override
#cat > file1 This command used to enter content inside the file.
To Exit (save) = ctrl + d
#cat file1 >> file2 This command used to append file1 content to file2.`
#echo “This is content” > file1 This command used to add content inside the file.
#echo “second content” >> file1 This commed used to append content inside the file.
#less /etc/passwd This command used to see content inside directory by one by one.
Like:-Click(ENTER_Button=one by one) and q for exit.
#head /etc/passwd This command used to see first 10 lines.
#less /etc/passwd This command used to see last 10 lines.
#head –n 3 /etc/passwd This command used to see first 3 lines.
#tail –n 3 /etc/passwd This command used to see last 3 lines.
#wc /etc/passwd This command used to see how many words,lines,characters has.
#wc /etc/passwd –l This command used to see how many lines.
#wc /etc/passwd –w This command used to see how many words.
#wc /etc/passwd -c This command used to see how many Characters.
#ca tab+tab To see what command starts with ca like cat.
# cat /etc/pa +tab To complete the commands.

#mkdir \ \ backlash used to write command in multiple lines but work as one.
D1 \
D2 \
D3
#mkdir d1 d2 d3 Creating multiple folder in one line of command.
#touch file1.txt file2 file.doc file.dox This command used to create empty file without any content inside it and
its also known as Zero-beta file and also use to change timestamp of
#touch file{1..100} existing file

#touch .hiddenfile.txt This command help you to create files like file1,file2..file100

(.) this dot used to create hidden file.


#ls –la This command help you to see all hidden files inside the directory.
# mkdir d1/d2/d3/d4/d5 -pv This command used to create file or folders inside inside
#ls d1 –R This command used to see inside inside the file or folders called
#tree d1 Recursively.
This command same as recursively.

Folders cd d1/d2/d3/d4/d5 (cd ../) This command used to go backward


d5#cd ../
d4#cd ../
d3#cd ../../
d1# cd ../
~
This command used to go back previous directory.
cd –

cd[ENTER] To go directly on home directory.


cd ~
#cp file copyfolder Cp = this command used to copy files at anylocation.
#cp –r folder copyfolder cp <source of file> <location of copied file>
Cp –r = this command used to copy folders at anylocation.
#mv file1 movefolder Mv = this command used to move files or folders at anylocation.
# mv harish akash this command also used to rename the file or folder name.
mv <source of file or folder> <destination of file or folder>
#rm file This command used to delete files.
#rm –r folder This command used to delete folder.
#rm –rvf folder This command used to delete folder and files without any question asked
(f) and printing message(v)
#rm –rvf * This command used to delete everything file and folders in the directory.
#rmdir emptyfolder This command used to delete only empty folders.
#ln testfile hard_testfile This command used to create hard-link a copy of source file.
Features:-
1 -> both are connected one change other will change
2 -> one delete so other file will be not effected.
3 -> hard-link only creates files not folders
Hard_link not allowed for directory.

1 -> if you want to create soft_link on other location like /tmp you need to
#ln –s testfile soft_testfile use absolute path like(ln –s /root/testfile /tmp/soft2_testfile).
2 -> one delete the other will be effected.
3 -> soft-link can create both file and folder.
# ls a*
alfa
# ls b*
beta
#ls [cd]*
Cat dog

#ls ????
Alfa beta
Variables=values It is used to save variables in a.
a=variables COUNT=10, count=10, first_name=harish, _Id=10
1count = not ok it is not accepted.
echo $a -> to call variable value
-variables
echo ${a}linux echo command used to print anything.
-variableslinux

echo $(hostname)
-harish
echo $(date +%A) echo$() this command used to print only commands.
-Monday

To add local variable to environment


variable
#vim .bashrc
a=variables
(It saves permanently)

To stop expanding commands. This command used to stop expanding the commands.
echo \$date
echo \$home
To change time and date. Before-change time and date.
[MMDDhhmm[[CC]YY][.ss]] Fri May 5 22:42:50 EDT 2023

#date 040422442022.30 After-change time and date by using date command.


Mon Apr 4 22:44:30 EDT 2022 Mon Apr 4 22:44:30 EDT 2022

Another way
#timedatectl set-time 9:00:00
Helping command to check everything
of anycmd.

#mkdir –help To see documentation of cmd.


#man mkdir To See manual pages
#man useradd To see manual pages of useradd cmd.
#mandb Update the database if man cmd not work.
# man –k mkdir To see see pages of manual pages
#man 2 mkdir
#whatis mkdir Same as man cmd.
#whereis mkdir To tell where cmd store in linux.
#which mkdir Same as whereis cmd
#pinfo mkdir To see all detail information about cmd. It is more indepth.

q= Quit
To save error,output or both and null > file 2>&1 = &>
the error in file.
0 = Input, 1=Output, 2=Error >> file 2>&1 = &>>

This cmd to find passwd by name in every etc directories.


$find /etc/ -name passwd
=>error&output

$find /etc/ -name passwd > output.txt (>) this sign used to save output in the file and print error in a terminal.
= error (output save in output.txt)
$cat output.txt
= Output
$wc output.txt
=2
$find /etc/ -name group >> output.txt (>>) this sign used to append output in the file or same file.
=error (output append in output.txt)
$wc output.txt
=2+2
$cat output.txt
/etc/pam.d/passwd
/etc/passwd
/etc/group
/etc/iproute2/group

$find /etc/ -name group 2> error.txt (2>) this sign used to save error in the file and print output in a terminal.
= Output (error save in error.txt)
$cat error.txt
$wc error.txt
$find /etc/ -name passwd 2>> error.txt (2>>) this sign used to append error in the file and print output.
= Output
$cat error.txt
$wc error.txt

$find /etc/ -name shadow 2> /dev/null (2> /dev/null) this sign used to discard or delete errors and print Output.
= Output (error discard or delete in
/dev/null)

$find /etc/ -name shadow &> (&>) this sign used to save both Error & Output in a file.
erroroutput.txt
$cat erroroutput (&>>) this sign used to append both Error & Output in a file.
= Output,Error
$find /etc/ -name passwd &>>
erroroutput.txt

$cat erroroutput.txt

#grep admin /etc/passwd (grep) this cmd used to filter.


#cat /etc/passwd | grep admin | wc –c (|) this is called pipeline. All the cmd written in b/w piplelines are
dependent to each-other.
cat /etc/passwd(Output) |grep admin(Input) |wc –c(Output)
= 41

#ls –l |tee lsOutput.txt | head (tee) this cmd used to save output in a file and then passed on Output to
Terminal.
#ls –l |tee lsOutput.txt
= Output with save output in
lsOutput.txt

#ls -l |tee lsoutput.txt|wc

#ls –l |head –n 5 |tee lsoutput.txt|wc


=5 38 197
(only save 5 lines )
#ls –l |tee /tmp/saved-output |head –n
2
=
Only show 2 lines but save all
Vim = the file editor.
i = insert_mode -> to write the content
inside the file.
ESC = command_mode -> In this mode
you will Delete,Copy,Cut,Paste,Undo
etc.
: = Extended_cmd_mode -> To save
and quite.
First -> command_mode then Press (i or a) to in Insert_mode THEN Press
#vim filename (:) for extended_cmd_mode (:w = save, :q=quite, :!=forcefully, :wq!=all
Cmd_mode thrice)
[i] Insert_mode
[ESC] Cmd_mode
:(:w, :q, :wq, :wq!) –
extended_cmd_mode

I Insert mode – insert text before the cursor

A Insert mode – insert text after the cursor

O Insert a new line


(Command-Mode)

: For extended command line mode

:w save

:q quit

:! forcefully

:wq! Save and quit forcefully

:x Save and quit

Shift+zz Save and quit – command mode

ESC Back from insert mode to command line mode

U Undo
(Cmd_mode)

dd Delete one line


(Cmd_mode)

4dd Delete 4 lines


2dd,3dd……..Ndd

yy Copy / yank one line


(Cmd_mode)

4yy Copy 4 lines


2yy,3yy……..Nyy

P Paste

cc Cut one line (Cmd_mode)

4cc Cut 4 lines


2cc,3cc……..Ncc

gg Move top of the file


(Cmd_mode)

Shift+g Move bottom of the file


(Cmd_mode)

:12 Go to specific line


(Cmd_mode)

0 Go to start of the line


(Cmd_mode)

$ Go to end of the line


(Cmd_mode)

:set number :se nu To set line number in the file


(Cmd_mode)

:set nonumber :se nonu To remove line number from the file
(Cmd_mode)

:%s/old/replaceword/g To search string and replace


(Cmd_mode)

/string To search string (word)


(Cmd_mode)

N Move forward
(Cmd_mode)

N Move reverse
(Cmd_mode)

:nohl To remove highlight


(Cmd_mode)
There are few cmds that cannot run by user01: x: 1000: 1000: User One: /home/user01: /bin/bash
normal_user($) like – useradd, mkdir 1 2 3 4 5 6 7
\folder
User:- /etc/passwd

Username:password:UID:GID:Comment:home-directory:shell
USER -> user information save in those
/sbin/nologin => cannot_Login
directory.
Group:- /etc/group
/etc/passwd => User information
group01: x: 10000: user01,user02,user03
/etc/group => group Information
1 2 3 4
/etc/shadow => Group_password
/etc/shadow => User_password

Sudo -> It is known as SuperUserDo. Sudo This cmd help us to normal user to work as a
$sudo useradd user11 (it can not work because it is Root_User or Super_User.
not in /etc/sudoers file)
admin is not in the sudoers file
Step1:-
#vim /etc/sudoers
:100 Allow root to run any commands anywhere
Press[i] = Insert_mode root ALL=(ALL) ALL
Add username in the sudoers file and ALL-ALL -> admin ALL=(ALL) ALL
Press[ESC] = Cmd_mode (Uname) (Every_cmd) (Every_Location)
:wq! = save,quit,forcefully

Now normal can work as a Superuserdo.

$sudo cat /etc/passwd


$sudo useradd anyuser
$sudo tail /etc/passwd

$mkdir folder
$ll
drwxrwxr-x. 2 admin admin 6 Apr 6 18:05 folder
$sudo mkdir folder
$ll
drwxr-xr-x. 2 root root 6 Apr 6 18:05 newfolder

But after becoming part of sudoers_file it frequently


ask password of the normal user to execute sudo
cmd.
So we use

## Allow root to run any commands anywhere


root ALL=(ALL) ALL
admin ALL=(ALL) ALL
This line helps user to write sudo cmd without ansible ALL=(ALL) ALL
repeating password.
Sudo -> SuperGroupAdding Adding a particular user in a particular group and give
superuser do access to that particular group. So that
we don’t need to give sudo access to all user one by
Step1:- create group one.
#groupadd superusergroup

Step2:- add group in sudoers file


#vim /etc/sudoers ## Allows people in group wheel to run all
:100 commands
Press[i] = Insert_mode %wheel ALL=(ALL) ALL
Add Groupname- in the sudoers file and ALL-ALL -> %superusergroup ALL=(ALL) ALL
Press[ESC] = Cmd_mode
:wq! = save,quit,forcefully

Step3:- Adding users in Group.


#usermod -G superusergroup ravi
#usermod -G superusergroup user011

Alternative way.

$sudo usermod –G superusergroup testuser


$sudo usermod –G superusergroup user22

# tail -n 1 /etc/group
superusergroup:x:10001:ravi,user011,testuser,user22
#groupadd groupname To create group.
#groupadd sales
#groupadd accounts

#useradd salesuser1
#useradd salesuser2

#useradd accountuser1
#useradd accountuser2
To add User in any Group.
#usermod –G sales salesuser1
#usermod –G accounts accountuser1

#tail –n 2 /etc/group sales:x:1000:salesuser1


accounts:x:1001:accountuser1
#id accountuser1
uid=1002(accountuser1) gid=1004(accountuser1)
groups=1004(accountuser1)

#usermod –g accounts accountsuser1 To change primary group.

#id accountuser1
uid=1002(accountuser1) gid=1001(accounts)
groups=1001(accounts)

#usermod –a –G accounts accountuser2 To add multiple user in group.


#usermod –a –G sales salesuser2 sales:x:1000:salesuser2,salesuser1
accounts:x:1001:accountuser2,accountuser1

#groupadd –r nfsgroup To create service accounts its id b/w


#groupadd –r smbgroup (1-999)

#groupmod –n new_accounts accounts To change the name of old-group.


#tail /etc/group new_accounts:x:1001:accountuser2,accountuser1
#groupmod –g 7000 sales To change the id of any group.
Before.
sales:x:1000:salesuser2,salesuser1
After.
sales:x:7000:salesuser2,salesuser1
#groupdel nfsgroup To delete the group.
Chage This cmd used to change the passwords of
configurations of user.
#chage –l operator1 (username) Default:-
Maximum number of days between password change
180

To change maximum days of password change policy.


#chage -M 90 operator1
Maximum number of days between password change
90

To make password change after their first login. (not


#chage –d 0 operator1 by root.)

To check what day, year, month after 45 days till


#date –d “+45 days” +%F present day.
Year-month-date date –d “+n days” +%F

to make expire user_account.


#chage –E 2022-04-25 operator1 [year-month-date]

Alternative
To change password configuration
#vim /etc/login.defs

Permissions:- Read(r),Write(w),Execute(x).
#mkdir /folder d -> Directory or folder.
#ls –ld folder 9 (characters) -> --- --- ---
drwxr-xr-x. 2 root root rwx rwx rwx
(User-group-others) -> Permissions. (user) (group) (Other)
-= normal_file or regular_file.
#touch /file
#ll file -(minus) = to remove permissions.
-rw-r--r--. 1 root root +(plus) = to add permissions.
=(exact or equal) => to override the permissions
a= All (User,Group,Others)
u = user
g = group
o = other

#chmod o-rx /folder(to remove read Chmod -> this cmd used to change permissions of file
permissionofothers) or folder.
#ll file
-rw-r-----
$cd /folder Read => reading file or folder like ls,cat,vim.
Permission denied Write => creating file or folder, deleting file or folder
Execute => get Inside the file or folder (cd)
#chmod o+r /folder (Others == Read)
$ls /folder

#chmod o+x /folder (Others == Execute)


$cd /folder

#chmod o+w /folder (Others == Write)


$touch filees

#ls –ld /folder


drwxr-xrwx. 2 root root

#chmod a=rwx /file or/folder to give full permissions


#ll /file or ls –ld /folder
-rwxrwxrwx.
drwxrwxrwx.

#chmod a=--- /file or folder to remove full permissions


#ll /file or ls –ld /folder
d---------
----------

#chmod u=rwx /folder To give permissions to user (read,write,execute.)


#ls –ld /folder or ll /file
drwx------

#chmod g=rwx /folder or /file To give permissions to Group (read,write,execute.)


#ls –ld /folder or ll /file
drwxrwx---

#chmod o=rwx /folder or /file To give permissions to Others (read,write,execute.)


#ls –ld /folder or ll /file
drwxrwxrwx
-rwxrwxrwx

#chmod o=r /folder or /file (=) to override r


#ls –ld /folder or ll /file
drwxrwxr--
-rwxrwxr—
Numerical-Permissions:- Read – 4, write – 2, execute – 1
Full-Permission = 4+2+1 = 7
0 -> No_Permission
chmod 7(user)7(group)7(other)
<file/folder>

#chmod 000 /file or /folder To remove all permissions from


#ls –ld /folder or ll file User,Group,Others.
---------
d--------

#chmod 750 /file or /folder User = Read,Write,Execute


#ll /file or ls –ld /folder Group=Read, Execute
-rwxr-x---. Others = No Permission
drwxr-x---.

#chmod 757 /file or /folder User = Read,Write,Execute


#ll /file or ls –ld /folder Group=Read, Execute
-rwxr-xrwx. Others = Read,Write,Execute
drwxr-xrwx.

#chmod 700 /file or /folder User = Read,Write,Execute


#ll /file or ls –ld /folder Group= No Permission
-rwx------. Others = No Permission
drwx------.

#chmod 222 /file or /folder User = Write


#ll /file or ls –ld /folder Group= Write
--w--w--w-. Others = Write
d--w--w--w-.

#chmod 7 /file or /folder User = No Permission


#ll /file or ls –ld /folder Group= No Permission
-------rwx. Others = Read,Write,Execute
d-------rwx.

#chmod 77 /file or /folder User = No Permission


#ll /file or ls –ld /folder Group= Read,Write,Execute
----rwxrwx Others = Read,Write,Execute
d----rwxrwx
Chown To change Group_owner of any folder,file.

chown user <folder/file>


chown :group_owner <folder/file>
#ll –ld folder
drwxrwxrwx. 2 root root To change Group_Owner of folder or file.
#chown :operator1 folder
#ll -ld folder
drwxrwxrwx. 2 root operator1

# chown operator1 folder To change User_Owner of folder or file.


#ll -ld folder
drwxrwxrwx. 2 operator1 operator1

#chown user1:user1 folder To change User_owner or Group_Owner.


#ll –ld folder
drwxrwxrwx. 2 user1 user1
Special-Permission:- o+t(Sticky) = Only the owner of the file or folder
can delete their own file or folder not other one
even in their Group_Owner User can not.
#mkdir /specialdata
#useradd specialuser1
#passwd specialuser1 = 123

#useradd specialuser2
#passwd specialuser2 = 123

#useradd specialuser3
#passwd specialuser3 = 123

#groupadd specialgroups

#ll –ld /specialdata


drwxr-xr-x. 2 root root

#chmod 770 /specialdata To give full permission to User and GroupOwner


#ll -ld /specialdata not others.
drwxrwx---. 2 root root

#chgrp specialgroups /specialdata To change GroupOwner of /specialdata


# ls -ld /specialdata
drwxrwx---. 2 root specialgroups
#usermod -G specialgroups specialuser1 To make specialuser1,2,3 to be part of
# usermod -G specialgroups specialuser2 specialgroups.
#usermod -G specialgroups specialuser3
# tail -n 5 /etc/groups
specialgroups:x:7004:specialuser1,specialuser2,specialuser3
Both user can delete the files of eachothers.
specialuser1
$cd /specialdata
$touch specialfileuser1

specialuser2
$cd /specialdata
$touch specialfileuser2 Now Only they can delete only their own files or
folder not each others.
#chmod o+t /specialdata
Using o+t
specialuser1
$rm –vf specialfileuser2
rm: cannot remove 'specialfileuser2': Operation not
permitted To make specialgroups Group-Owner of all files
inside the /specialdata.
#chgrp –R specialgroups /specialdata But it is temporary and only for saved file not a
#cd specialdata new files created.
specialdata# ll
-rw-rw-r--. 1 specialuser1 specialgroups specialfileuser1
-rw-rw-r--. 1 specialuser2 specialgroups specialfileuser2

To make specialgroups Group-Owner permanent.

#chmod g+s /specialdata


Specialuser1
$touch file
$ll
-rw-rw-r--. 1 specialuser1 specialgroups file

Specialuser1
$cat /etc/shadow
cat: /etc/shadow: Permission denied
To any user to work as root_user.
#chmod u+s /usr/sbin/fdisk
To See Processes:-

#ps
#ps aux
#top
To run cmd in a bg(&)
#firefox &
#jobs To see running program process
[1]+ Running firefox &
#fg %1 <processid> To run background cmd in foreground
Ctrl+c (to stop program running)
#sleep 100 (seconds)
Ctrl+z (to stop program)
To Run process in background.
#jobs
#bg 3 <processid>
To see all kill cmd to kill programs and processes.
#kill –l

Operator1
$vim testfile

#ps ao user,tty,pid,command | grep vim


operato+ pts/1 9276 vim testfile
root pts/0 9278 grep --color=auto vim To kill process by processid

#kill 9276 <processid>


#kill -9 9276<processid> To kill process by id with forcefully

To kill all process by name of cmd


#killall vim
To kill process by the name of user.
#pkill –U operator1<username>
#pkill –U 1004 <UID (userid)>
To kill process by terminal
#pkill –t pts/1
System Administration and logs:- To see system average load
#uptime
#lscpu To see cpu utisilization

#systemctl list-unit-files –type service To see all services are disabled or enabled

To see a particular service status.


#systemctl status sshd.service
#systemctl stop sshd To stop the services

#systemctl start sshd To start the service.

#systemctl status sshd To see the status of service.

#systemctl restart sshd.service To restart the service whenever you change some
-thing in configuration file so that change will
work. But it change Process-id of service
#systemctl reload sshd.service
It work same as restart but in this Process-id will
not change. But do not work on everyfile.
#systemctl mask chronyd
To stop the service.
#systemctl unmask chronyd
To start the service again.

SSH-Connecting the systems via ip-addresses

Machine1 Machine2
#nmcli connection add type ethernet #nmcli connection add type ethernet To create device name and
ifname ens160 con-name mycon01 ifname ens160 con-name mycon02 ethernet connection.

#nmcli connection modify mycon01 #nmcli connection modify mycon02 To give ip-addresses to
ipv4.addresses 192.168.10.20/24 ipv4.addresses 192.168.10.30/24 machine.
ipv4.method manual ipv4.method manual

#nmcli connection up mycon01 #nmcli connection up mycon02 To connection-up the machine.

#nmcli connection [2*TAB] #nmcli connection [2*TAB] To check more option like
down the connection or delete
and manymore.

#nmcli connection show #nmcli connection show To show the machine or device
we created

#ping 192.168.10.30 #ping 192.168.10.20 To check connectivity

#ssh 192.168.10.30 #ssh 192.168.10.20 To connection machine to


each-other.

#exit #exit To logout.


Machine1(User-Harish) ip -192.168.10.20 Machine2(User-Akash) ip -192.168.10.30

$ssh [email protected] $ssh [email protected] To getting remote access by


Passwd of Akash :- 456 Passwd of Harish :- 123 user of another machine.

$ls .ssh $ls .ssh To check files.

To create a public key file for


$ssh-keygen $ssh-keygen not using password again and
again.

Now giving the public key file


$ssh-copy-id [email protected] to Another user of other
$ssh-copy-id [email protected] machine
Now no need to use password to login
Now no need to use password to login or or gettting Access remotely
getting Access remotely

To stop Public Key based Authentication

#ssh [email protected] –o #ssh [email protected] –o Now you need password to


PubkeyAuthentication=no PubkeyAuthentication=no get access of system
Password 123 Password 123

File Method for Assigning IP-Address


File-Method-For-Assigning-IpAddress:-

#nmcli connection add type ethernet ifname ens160 con-name con0011

#cd /etc/sysconfig/network-scripts/
Go to the file
/etc/sysconfig/network-scripts/
#ls
ifcfg-con0011 ifcfg-ens160 ifcfg-mycon01

#vim ifcfg-con0011
BOOTPROTO=none

IPADDR=200.200.200.100
PREFIX=24
GATEWAY=200.200.200.1
DNS1=202.56.215.54
DNS2=202.56.215.55

#nmcli connection reload


#nmcli connection up con0011
#nmcli connection show con0011
#ip a
Archive (tar) to store backup Data:- tar –cvf, -tvf, -xvf | .tar extension
must.

#cat > originalfile Creating file with data


Data
CTRL+D

#tar –cvf mytar.tar originalfile Creating tar file(mytar.tar) of


#ls existing file(originalfile)

#tar –tvf mytar.tar To see data inside the file

#rm –rvf tarfile Removing the original file or existing


#ls file

#tar –xvf mytar.tar Extracting the original file from


#ls tar-file

#du –sh tarfile To check the size of file like MB.


#du –sh mytar.tar
Compressing size of file tar –czvf,-cjvf,-cJvf <tar-file> originalfile

Best compressing command.


J>j>z

#tar –czvf mytar.tar.gz originalfile


#du –sh mytar.tar.gz

#tar –cjvf mytar.tar.bz2 originalfile


#du –sh mytar.tar.bz2

#tar –cJvf mytar.tar.xz originalfile


#du –sh mytar.tar.xz

#rm –rvf originalfile


#ls

#tar –xvf mytar.tar.xz


#ls

Machine1 = 192.168.10.20 Machine2 =


192.168.10.30
#ping –c 3 192.168.10.30
#ping –c 2 Check connectivity
#cat > file 192.168.10.20
This is a Testfile
CTRL+D

#scp file1 file2 [email protected]: #ls Sending files Machine2

#scp [email protected]:/root/Desktop/filing /root/Desktop Receiving file(filing) from


Machine2
#ls

#scp [email protected]:/root/Desktop/filing /root/ Receving file(filing) from


#ls Machine2

#scp [email protected]:/root/file1 . Receiving file(file1) from


#ls Machine2 at present directory

#scp –r Folder [email protected]: Sending folder.

#scp -r [email protected]:/root/folder1 .- Receiving folder(folder1)


Machine1 – 192.168.10.20 Machine2 – Sftp -> this cmd used to send
192.168.10.30 or receive data both.

#sftp [email protected] [ENTER] #ls


>get File File folder get -> Getting data (receiving)
>get –r folder put -> Giving data (send)
>put files
>exit
#ls #ls
File folder File folder files

Machine1 – 192.168.10.20 Machine2 – rsync (to synchronising data)


192.168.10.30 Updated Data

#cat > syncfile


This is a testfile #ls
syncfile To send file to Machine2
#rsync syncfile [email protected]: #cat syncfile
This is a testfile
#cat >> syncfile
This is Secondtestfile

#rsync syncfile [email protected]: #ls To send updated data to


#cat syncfile Machine2
This is a testfile
This is
Secondtestfile

#rsync syncfile [email protected]:/root/Desktop #ls To send folder to Machine2


#rsync -r syncfolder [email protected]:

#rsync [email protected]:/root/files /root/ To receiving file from


#ls machine2

#rsync [email protected]:/root/file1 .
#ls
To receiving folder from
#rsync -r [email protected]:/root/folder1 . machine2
Install packages and more details :-

#rpm –q telnet Checking package is install or not.


Package telnet is not installed
#rpm –q openssh
Openssh-7.8p1-4.el8.x86_64

#df Getting to directory where all packages are


#cd /run/media/root/RHEL-8-0-0-BaseOS- already there.
x86_64
#ls
#cd AppStream
#ls
#cd Packages

#ls | grep telnet Filtering the packages by name.


#ls | grep openssh

# rpm -qa openssh * To Query All.

#rpm –qi openssh To Know more details about packages.

#rpm –ql openssh To list.

#rpm –qc openssh To see the configuration files of packages.

#ls | grep telnet To install the package


#rpm -ivh telnet-0.17-73.el8.x86_64.rpm
#rpm –q telnet To check package is installed or not.

#rpm –evh telnet To uninstall the package.


#rpm –q telnet
locate, find -> to locate file or directory
Updating database before using locate
#updatedb cmd.
#locate fstab
#locate file1 locate cmd used to locate file or folder in
#locate folder1 the entire systems and every folder , every
files.

#find / -name file1 find cmd used to find file or folder in the
/root/file1 specific location like ( / , /etc/ ). It gives
/root/syncfolder/file1 more options than locate like search by ->
/root/folder1/file1 -name, -group, -user, -uid, -gid, -perm 000,
/salesdata/joker/file1 -size 20M
/folder/file1
Finding the file or folder which start with
#find / -name ‘*pass*’ *pass* or have.

Finding the file or folder which have .txt


#find / -name ‘*.txt’ extension.

Find the user by username.


#find / -user Harish
Finding file or folder by user and name.
#su - Harish
$touch file{1..5}
$mkdir folder{1..5}

#find / -name 'file*' -user Harish -type f


#find / -name 'folder*' -user Harish -type d
To see data by GroupOwner.

#find / -group Harish


To see by group id and userid
#find / -gid 12
#find / -uid 1008
To see by permissions.
#find / -perm 000
To see by Size.
#find / -size 20M
Starting Webconsole

#rpm –q cockpit
#systemctl status cockpit.socket

#systemctl start cockpit.socket


#systemctl enable cockpit.socket

#firewall-cmd –reload
#firewall-cmd –list-all

#firewall-cmd –add-service=cockpit –
permanent
#firewall-cmd –reload
#firewall-cmd –list-all

#ip a
#firefox

Copy ip address
192.168.10.20
Paste it on firefox browser.
https://192.168.10.20:9090
Using
Username :- root
Password :- 123

You might also like