Centos 7 – initial setup

Here I am assuming that we started with the minimal installation of Centos 7.
Let’s install some useful packages

yum install wget vim mc ntp net-tools

Now let’s configure the timezone and start the ntp service

timedatectl list-timezones | grep Athens
timedatectl set-timezone Europe/Athens
systemctl start ntpd.service
systemctl enable ntpd.service

Next we will change ssh default port. Edit ssh config file and uncomment Port putting your desired port number.

vim /etc/ssh/ssh_config
systemctl reload sshd.servive

Now let’s disable SElinux changing config file to SELINUX=disabled

vim /etc/sysconfig/selinux

Finally let’s configure firewall

systemctl status firewalld

Show configuration

firewall-cmd --permanent --list-all

Allow port

firewall-cmd --permanent --add-port=4311/tcp

Allow service

firewall-cmd --get-services
firewall-cmd --permanent --add-service=http

Remove service or port

firewall-cmd --permanent --remove-service=http
firewall-cmd --permanent --remove-port=4311/tcp

Reload and start at boot

firewall-cmd --reload
systemctl enable firewalld
Posted in Linux | Leave a comment

Working with mysql CLI

Login

mysql -u username -p

Show databases;

show databases;

Use database;

use db_name;

List tables;

show tables;

Show table fields

describe table_name;

OR

show columns from table_name;

Select fields from table

select column1,column2 from table_name;

Update record

update table_name set column='test1' where column='test2';

Delete record

delete from table_name where column='test';

Backup database (not logged in to mysql)

mysqldump -u username -ppassword db_name > db_backup_file.sql

Backup certain tables from database

mysqldump -u username -ppassword db_name table_name1 table_name2 > db_backup_file.sql

Backup more than one database

mysqldump -u username -ppassword --databases db_name1 db_name2 > db_backup_file.sql

Backup all databases

mysqldump -u username -ppassword --all-databases > db_backup_file.sql

Restore database (if database does not exist)

mysql -u username -p password db_name < db_backup_file.sql

Restore database (existing database)

mysqlimport -u username -p password db_name < db_backup_file.sql

Show Database size

SELECT table_schema "Data Base Name", sum( data_length + index_length ) / 1024 / 1024 "Data Base Size in MB" 
FROM information_schema.TABLES GROUP BY table_schema ;
Posted in Web | Leave a comment

Getting things done from command prompt

Find windows install date

systeminfo | find "Original Install Date"

Find computer name

hostname

Find domain

echo %userdomain%

Restart service

net stop "Print Spooler" && net start "Print Spooler"

Manage firewall
–ON

NetSh Advfirewall set allrprofiles state on

–OFF

NetSh Advfirewall set allrprofiles state off

–Check status

Netsh Advfirewall show allprofiles

Check if Remote Desktop is enabled

nestat -an | find "3389"

Find logged in username

echo %username%

List users

net users 

Details about a user

net users administrator

List network connections and ports

netsat -an

Find logged in username/domain

whoami

Show admin shares

net share
Posted in Windows | Leave a comment

HP MSA P2000 G3 – View live performance statistics in CLI

The HP P2000 G3 MSA Arrays have statistical counters that provide array performance measurements across different levels, such as disks, Vdisks, host ports, controllers, and volumes. Each component supports a list of performance metrics such as IOPS, Queue Depth, and Bytes per second.With the following commands we can get these live performance statistics.

show controller-statistics
show Vdisk-statistics
show disk-statistics
show volume-statistics
show host-port-statistics
Posted in Datacenter | Leave a comment

Useful Windows keyboard shortcuts

Open Task Manager –> ctrl+shift+esc
Quit program –> alt+F4
Right click –> shift+F10
Main window menu(minimize…) –> alt+space
Open menu in a program –> alt
open properties –> alt+enter
create new folder –>ctrl+shift+n
Cursor in address bar –> alt+d
Search –> F3
New tab –> ctrl+t
Use the arrow keys to switch between open items –> alt+tab+arrows(alt pressed)
Go up one level –> alt+up arrow
Move through tabs –> ctrl+tab
move backwards through tabs –> ctrl+shift+tab
System properties –> win+pause
Focus on the taskbar –> win+t
Shutdown menu –> alt+F4
Preview the desktop –> win+space
Maximize window –> win+up arrow
Minimize window –> win+down arrow
Projector –> win+p

Posted in Windows | Leave a comment

VMware – Force shutdown of a stuck VM

Sometimes a VM is stuck and can’t be killed with vSphere Client

Login through ssh to the Esxi server and get a list of running VMs identified by World ID:

esxcli vm process list

Power off one of the virtual machines from the list using this command:

esxcli vm process kill --type=force --world-id=7331933
Posted in Virtualization | Comments Off on VMware – Force shutdown of a stuck VM

Troubleshooting Group Policy update issues

Problem: Logon scripts not running.
Check for event ID 1058 in System Event Log.In the details tab find the sysvol path pointing to the gpt.ini file.Check if the file is accessible.
Check which DC the pc uses to login to AD:
echo %logonserver%
From command prompt run gpupdate to check issues

Posted in Windows | Comments Off on Troubleshooting Group Policy update issues