Monday, May 11, 2020

Access file windows from Linux

Linux server
List share file on windows
smbclient --user=windows user -L //IP Address windows server
smbclient --user=U001 -L //172.16.0.xx

Access file on windows server
smbclient //IP Address windows server/File share -U windows user
smbclient //172.16.0.xx/Fileshare -U U0001

Thursday, April 23, 2020

install epel-release on centos 8

install epel-release

Turn on EPEL repo on CentOS 8
Make sure EPEL repo enabled and installed. If not, run:
vivek@centos8-box:$ sudo yum -y install epel-release
vivek@centos8-box:$ sudo yum repolist

Ref: how-to-install-htop-on-centos-linux-8

Monday, April 6, 2020

Linux command check IP public when you connect to internet at that location


1. dig +short myip.opendns.com @resolver1.opendns.com
2. dig TXT +short o-o.myaddr.l.google.com @ns1.google.com | awk -F'"' '{ print $2}'

Ref: debian 10 set up openvpn-server in 5 minutes

Friday, March 13, 2020

ubuntu server 18.04 boot slow more 2 minute

After install ubuntu server 18.04 and found boot more 2 minute and have a error "a start job is running for wait for network to be configured"

How to fix this error check network interface
sudo networkctl
IDX LINK             TYPE               OPERATIONAL SETUP   
  1 lo               loopback           carrier     unmanaged
  2 enp4s5           ether              routable    configured
  3 enp5s0           ether              no-carrier  configuring

sudo networkctl status enp4s5

1. sudo vim /run/systemd/generator/network-online.target.wants/systemd-networkd-wait-online.service

change this line
ExecStart=/lib/systemd/systemd-networkd-wait-online
to
ExecStart=/lib/systemd/systemd-networkd-wait-online --interface=enp4s5 --quiet

------------------edit-----------------------------------

[Service]
Type=oneshot
ExecStart=/lib/systemd/systemd-networkd-wait-online --interface=enp4s5 --quiet
RemainAfterExit=yes
Ô

------------------end------------------------------------

2. reboot

Ref: a-start-job-is-running-for-wait-for-network-to-be-configured-ubuntu-server-17-1

Thursday, March 12, 2020

install and configure x11vnc on ubuntu server 18.04 LTS

sudo apt-get install x11vnc
x11vnc -storepasswd 

Enter VNC password: *********
Verify password: *********  
Write password to /home/rahul/.vnc/passwd?  [y]/n y
Password written to: /home/rahul/.vnc/passwd
sudo x11vnc -auth guess -forever -loop -noxdamage -repeat -rfbauth /home/rahul/.vnc/passwd -rfbport 5900 -shared
script auto start
1. make file x11vnc.service in /etc/systemd/system : sudo mcedit /etc/systemd/system/x11vnc.service (mcedit – my prefered editor , i’m sorry for vi :)))
with text (change RAHUL for you name):
[Unit] Description=x11vnc remote desktop server After=multi-user.target
[Service] Type=simple ExecStart=/usr/bin/x11vnc -auth guess -forever -loop -noxdamage -repeat -rfbauth /home/RAHUL/.vnc/passwd -rfbport 5900 -shared
Restart=on-failure
[Install] WantedBy=multi-user.target
2. sudo systemctl daemon-reload sudo systemctl start x11vnc sudo systemctl status x11vnc
3. if it’s worked sudo systemctl enable x11vnc.service
Ref: setup-x11vnc-server-on-ubuntu-linuxmint

Tuesday, March 10, 2020

install and configure snmp

1. For CentOS 7
install service snmp

yum install net-snmp net-snmp-utils -y

Set configure file /etc/snmp/snmpd.conf
--------------------------------edit------------------------------------------------------------
#       sec.name  source          community
com2sec mynetwork  default       systemsecret

####
# Second, map the security name into a group name:

#       groupName      securityModel securityName
group   notConfigGroup v1           mynetwork
group   notConfigGroup v2c          mynetwork

# Make at least  snmpwalk -v 1 localhost -c public system fast again.
#       name           incl/excl     subtree         mask(optional)
view    systemview    included   .1.3.6.1.2.1.1
view    systemview    included   .1.3.6.1.2.1.25.1.1

####
# Finally, grant the group read-only access to the systemview view.

#       group          context sec.model sec.level prefix read   write  notif
access  notConfigGroup ""      any       noauth    exact  systemview none none
--------------------------------save configure-----------------------------------------------

Enable service
systemctl enable snmpd
systemctl start snmpd
systemctl status snmpd

Check port runing
netstat -tulpn
udp        0      0 0.0.0.0:161             0.0.0.0:*                           21402/snmpd

Test snmpd at local server
snmpwalk -v 1 -c systemsecret -O e 127.0.0.1

Add firewall
firewall-cmd --permanent --add-port=161/udp
firewall-cmd --reload
firewall-cmd --list-all



2. For Debain 9
Install service snmpd

apt install snmpd snmp libsnmp-dev

Edit configure /etc/snmp/snmpd.con
---------------------------------------------------------
AGENT BEHAVIOUR
#
#  Listen for connections from the local system only
agentAddress  udp:127.0.0.1:161,udp:192.168.0.xx:161

ACCESS CONTROL
#
                                                 #  system + hrSystem groups only
view   systemonly  included   .1.3.6.1.2.1.1
view   systemonly  included   .1.3.6.1.2.1.25.1

                                                 #  Full access from the local host
#rocommunity public  localhost
                                                 #  Default access to basic system info
# rocommunity public  default    -V systemonly
 rocommunity serversecret  default    -V systemonly
                                                 #  rocommunity6 is for IPv6
 rocommunity6 public  default   -V systemonly
#rocommunity secret  10.0.0.0/16
                                                 #  Full read-only access for SNMPv3
 rouser   authOnlyUser

SYSTEM INFORMATION
#
#  Note that setting these values here, results in the corresponding MIB objects being 'read-only'
#  See snmpd.conf(5) for more details
sysLocation    Sitting on the Dock of the Bay
sysContact     Me
                                                 # Application + End-to-End layers
sysServices    72
---------------------------------------------------------------------------
Enable service
systemctl enable snmpd
systemctl start snmpd
systemctl status snmpd

Check port runing
netstat -tulpn
udp        0      0 192.168.0.xx:161         0.0.0.0:*                           12142/snmpd         
udp        0      0 127.0.0.1:161           0.0.0.0:*                           12142/snmpd

ss -alnp | grep snmp | grep 161
udp    UNCONN     0      0      192.168.0.xx:161                   *:*                   users:(("snmpd",pid=12142,fd=12))
udp    UNCONN     0      0      127.0.0.1:161                   *:*                   users:(("snmpd",pid=12142,fd=9))

Test snmpd at local server
snmpwalk -v2c -c serversecret localhost

Add firewall
firewall-cmd --permanent --add-port=161/udp
firewall-cmd --reload
firewall-cmd --list-all



Wednesday, January 22, 2020

Configure Master / Slave BIND DNS Server on CentOS 8 / RHEL 8

Configure Master / Slave BIND DNS Server on CentOS 8 / RHEL 8



for check zone file
named-checkzone abc.com /var/named/abc.com.zone
Directory zone = /var/named/

dnstop ens192
dnstop -l 2 ens192
dnstop -l 3 ens192
yum install dnstop

Tuesday, January 7, 2020

How to Add New Disks Using LVM to an Existing Linux System

How to Add New Disks Using LVM to an Existing Linux System


Read on this web site add-new-disks-using-lvm-to-linux

Friday, October 4, 2019

how to change screen login ubuntu 18.04 budgie

1. create file slick-greeter.conf on /etc/lightdm/

sudo vim /etc/lightdm/slick-greeter.conf
------------------------------------------------------
[Greeter]
#background=/usr/share/backgrounds/Definitive_Light_Zen_Orange_by_Pierre_Cante.jpg
background=/usr/share/backgrounds/cat-login.jpg

-----------------------------------------------------
save file

2. bring your screen login to the folder /usr/share/backgrounds/

3. reboot

Ref:
Greeter

Tuesday, September 3, 2019

How to check if port is in use on Linux or Unix

How to check if port is in use on Linux or Unix


sudo lsof -i -P -n | grep LISTEN
sudo netstat -tulpn | grep LISTEN
sudo lsof -i:22 ## see a specific port such as 22 ##
sudo nmap -sTU -O IP-address-Here

Option #1: lsof command
$ sudo lsof -i -P -n
$ sudo lsof -i -P -n | grep LISTEN
$ doas lsof -i -P -n | grep LISTEN ### [OpenBSD] ###

Linux netstat syntax
netstat -tulpn | grep LISTEN
watch netstat -tulpn
sudo ss -tulw
sudo ss -tulwn


netstat -tulpn |grep tcp |grep -v 127.0.0.1 |grep -v 192.168.101.36
-v is invert matching (every thing except 127.0.0.1 and 192.168.101.36)


Where ss command options are as follows:
  • -t : Show only TCP sockets on Linux
  • -u : Display only UDP sockets on Linux
  • -l : Show listening sockets. For example, TCP port 22 is opened by SSHD server.
  • -p : List process name that opened sockets
  • -n : Don’t resolve service names i.e. don’t use DNS

FreeBSD/MacOS X netstat syntax

$ netstat -anp tcp | grep LISTEN
$ netstat -anp udp | grep LISTEN

OpenBSD netstat syntax

$ netstat -na -f inet | grep LISTEN
$ netstat -nat | grep LISTEN

Option #3: nmap command

The syntax is:
$ sudo nmap -sT -O localhost
$ sudo nmap -sU -O 192.168.2.13 ##[ list open UDP ports ]##
$ sudo nmap -sT -O 192.168.2.13 ##[ list open TCP ports ]##
You can combine TCP/UDP scan in a single command:
$ sudo nmap -sTU -O 192.168.2.13

A note about Windows users

You can check port usage from Windows operating system using following command:
netstat -bano | more
netstat -bano | grep LISTENING
netstat -bano | findstr /R /C:"[LISTEING]"

Ref:
unix-linux-check-if-port-is-in-use-command