Useful Windows/Linux/Networking Command

List of useful commands for System Engineer. Please comment if you think something needs adding.

LINUX

  • GENERAL

uname -ar – Kernel/Hosthame information

crontab -e  – edit crontab file for current use

grep -rnw ‘/path/to/somewhere/’ -e “pattern” – searching for pattern in files

lspci – List all PCI devices

wbinfo -u – list AD users

wbinfo -g -list AD groups

  • APACHE

openssl req -new -newkey rsa:2048 -nodes -keyout yourdomain.key -out yourdomain.csr – request a csr

openssl pkcs12 -export -out cert.pfx -inkey privateKey.key -in certificate.crt exporting key and crt into pfx file

apachectl -k graceful – reload config without restarting apache server.

apachectl configtest – check configuration files before reload

  • APACHE CONF

RedirectMatch ^/redmine/(.*)$ https://redmine.example.com/$1 – simple redirect from http://redmine.example.com/redmine/ to https://redmine.example.com/

  • SWAP/MEMORY

swapon -s – swap summary

free -m – show memory usage

  • LOCALE/LANGUAGE

dpkg-reconfigure keyboard-configuration – used to reconfigure keyboard layout e.g. from US to GB

locale-gen en_GB.UTF-8 – generate UK locale

  • DNS

named-checkconf example.com example.com.zone – to check zone before reloading

rndc reload example.com – to reload the zone in bind

  • SAMBA

smbclient //servername/shareName -U user – testing share access

testparm -s /etc/samba/smb.conf – test samba configuration

netstat -tulpn | egrep “samba|smbd|nmbd|winbind” – check on which ports samba is listening

smbd reload-config – reload config without restart service

  • POSTFIX

mailq – display email queue

mailq | wc -l – show number of emails

postcat -q 248DEAB – read messages 248

qshape – display statistics

mailq | awk ‘/^[0-9,A-F]/ {print $7}’ | sort | uniq -c | sort -n – display domain send by from in order.

mailq| grep ‘^[A-Z0-9]’|grep @example.com|cut -f1 -d’ ‘ |tr -d \*|postsuper -d – -remove all emails send by example.com from queue

USEFUL FILE LOCATION LINUX

/opt/bitnami/apps/redmine/conf/httpd-vhosts.conf – Bitnami Redmine Configuration

tail -f /var/log/mail.info – display mail log entries on the fly

tail -f /var/log/mail.log  – mail log

tail -f example.log | grep –line-buffered ‘pattern’ – filter tail output using grep

WINDOWS

cmd>dir > list.txt – to export list of files from current directory

cmd>slui 3 – Windows activate windows

cmd>slui 4 – Windows Phone Activation

sfc /scannow – scan and reapair missing or corrupted system files

cmd gpresult /Scope Computer /v – display which gpo has been applied

msinfo32 – view advance computer information remotely

rd /s $RECYCLE.BIN – remove files from recycle bin

pskill \\REMOTE_SERVER_NAME  winlogon – kill winlogon if shutdown hangs

regedit then HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\InstallDate – to check Windows Installation Date in unixtime 🙂

regedit HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileList\ProfileImagePath – Folder to user assignment in Windows.

rsop.msc – result of policy setting

slmgr.vbs (C:\Windows\System32\) – Licencing info

Dism.exe /online /Cleanup-Image /StartComponentCleanup – (W2012) – Removing old superseded updates (https://technet.microsoft.com/en-gb/library/dn251565.aspx)

Powershell

[environment]::Version – check powershell version

Get-PSSnapin -Registered -to display registered snap-in in powershell

Get-Hotfix -computername SEA-SRV-01 | Select HotfixID, Description, InstalledOn | Sort-Object InstalledOn – get a list of Hotfixes installed on the pc

net statistics server or systeminfo | find “System Boot Time:” \ find “Stati” – to check windows uptime.

Run: Get-Process ¦ select ID, name, starttime – get a list of processes

get-executionpolicy / set execution policy unrestricted – allow all script to be run on the pc

Install-WindowsFeature Desktop-Experience – Install cleanmgr on Windows 2012+

EXCHANGE

Test-ReplicationHealth | Select-object Check, Result, Error – to test replication health.

USEFUL FILE LOCATION

\\domainName\sysvol – location of domain polices / logon scripts.

CISCO

show version – to check version and uptime

show ip interface brief – show all ports info

show cdp neighbords – show neighboard config.

show ip bpg summary | include xxx.xxx.xxx.xxx – bgp session info

show interfaces trunk – show vlan to port summary

show mac address-table dynamic vlan 100 – show mac address by

show arp | include 192.168 (filter output) – http://www.cisco.com/c/en/us/td/docs/ios-xml/ios/fundamentals/configuration/15_sy/fundamentals-15-sy-book/cf-cli-search.html

copy flash tftp  – backs up the Cisco IOS to a TFTP server.

MYSQL

SHOW GRANTS FOR ‘root’@’localhost’; – display root rights

GRANT ALL PRIVILEGES ON *.* TO ‘root’@’localhost’ – give root privileges to everything then flush privileges; or use % if it’s listening on everything.

netstat -tap | grep mysql – check on which ports MySQL is running

set password for user = PASSWORD(‘mypass’); – set a password to a user

sudo /opt/bitnami/ctlscript.sh restart mysql – Restart Bitnami MySQL

in my.cnf change bind-address = 0.0.0.0 to allow MySQL to listen on all ports.

C:\Windows\System32\sysprep\sysprep.exe – OOBE/Generalize/Reboot – this will remove all PC settings so the image can be used for many pc.

SQL Server

select @@servername go – server name and instance
select @@version go – version – check version MS SQL 2012 SP1
select serverproperty(‘edition’) go – check edition eg standard

SELECT * FROM sys.configurations WHERE name = ‘clr enabled’ – to check if CLR is enabled. (Allows to run user defined function/stored procedures etc).

SECURITY

arachni http://example.com –report-save-path=/root –checks=active/* –scope-auto-redundant –scope-directory-depth-limit=3 –platforms=windows,mssql,iis,aspx – scanning site with arachni

arachni_reporter /path/to/report.afr –reporter=html:outfile=path/to/report.html.zip – convert arachni report into html.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s