Professional Documents
Culture Documents
Linux Essential Command
Linux Essential Command
Linux Essential Command
cal display calendar Esc key:q = quit without saving , :q! = force quit without save
man manual page of command :wq = save and exit, :wq! = force save and exit
ls –l all information free = show memory, df = show file system, du = disk usage
ln create link fdisk = show partition table, top = display background process
root – user name or login name -d /user-folder username different home directory
x – encrypted password stored in /etc/shadow -u 999 –g 500 specific user and group ID
/root – home directory for user -e 2021-12-31 –f 45 account expire date, password expire
chmod 751 file/directory – permission change 1. at start up, press “e” to edit mode
Change file/directory permission at end of linux sentence quite rd.break, Press Ctrl+X
0 ---
1 --x
2 -w-
3 -wx
4 r--
5 r-x
6 rw-
7 rwx
2. Symbolic mode Change ownership and group
vi /etc/profile ,folder 7 5 5
run command bash newscript.sh (or) ./newscript.sh echo “Enter Your Name”
#!bin/bash
echo $name
Using if statement with AND logic: If statement: -eq equal
then #!/bin/bash
fi
If..then..elif..elif..else..fi
Using if statement with OR logic:
#!/bin/bash
#!/bin/bash
echo “Enter your lucky number”
echo “Enter any number”
read n
read n
if [ $n –eq 101 ];
if [[ ( $n –eq 15 || $n –eq 45 )]]
then
then
echo “You got 1st prize”
echo “You won the game”
elif [ $n –eq 510 ];
else
then
echo “You lost the game”
nd
echo “You got 2 prize”
fi
else
Case Statement
echo “Sorry, try for the next time”
echo “Enter your lucky number”
fi
read n
statements ;; 510)
statements ;; *)
seac esac
Make Directory:
asd Delete a file:
#!/bin/bash #!/bin/bash
echo “Enter your directory name” Echo “Enter filename to remove”
read d read rf
mkdir $d rm –i $rf
read ndir
if [ -d “$ndir” ]
then
else
mkdir $ndir
=RPM keeps the information of all the installed packages under /var/lib/rpm database
#rpm –evv nx
1) IP address Assign with ifcfg config file
Yum package installation
#ip addr
#yum list installed
#cd /etc/sysconfig/network-scripts
#rpm –qa
#vi ifcfg-enp0s3
List of enabled and disabled yum repositories
#cat /etc/sysconfig/network-scripts/ifcfg-enp0s3
#nmtui
Remote Access with SSH
#vi /etc/sysconfig/network-script/ifcfg-ens160
BOOTPROTO=static
IPADDR=192.168.1.254
NETMASK=255.255.255.0
#vi /etc/ssh/sshd_config
Port 22
#AddressFamily any
#ListenAddress 0.0.0.0
#ListenAddress ::
#LoginGraceTime 2m
PerminRootLogin no
#StrictModes yes
#MaxAuthTries 6
#maxSessions 10
PermitEmptyPassword no
PasswordAuthentication yes
#systemctl enable sshd In client PC, install Putty and give server ip and run.
enabled=1
2. Install createrepo package gpgcheck=0
#yum install createrepo –y baseurl=ftp://192.168.200.1/pub/Local_Repo/BaseOS/
baseurl=ftp://192.168.200.1/pub/Local_Repo/AppStream/
4. createrepo to /var/ftp/pub/Local_Repo/
#firewall-cmd --reload
path = /share/secured
#mkdir iptable
#iptables-save iptables.bk
#iptables-restore iptables.bk
Firewall Zone
Blocking a Service
With service name - #firewall-cmd --add-rich-rule=’rule family=ipv4 source address=1.1.1.1/32 service name=ssh
accept’ --permanent
Time limit - #firewall-cmd --add-rich-rule=’rule family=ipv4 source address=1.1.1.1/32 service name=ssh limit
value=1/m accept’ --permanent
With port number - #firewall-cmd --add-rich-rule=’rule family=ipv4 source address=1.1.1.1/32 port port=22
protocol=tcp accept’ --permanent
With protocol value - #firewall-cmd --add-rich-rule=’rule family=ipv4 source address=1.1.1.1/32 protocol value=imcp
reject’ --permanent