How to use wget to test user agents blocking

You need to use the following syntax

Testing if the site is blocking empty user agent

{ ~ } » wget –user-agent=”” http://www.exampple.co.uk ~ 8
HTTP request sent, awaiting response… 403 Forbidden: Access is denied.
2017-09-26 12:21:36 ERROR 403: Forbidden: Access is denied..

Specific user agent

» wget –user-agent=”PriceDrone-Bot+(http://www.pricedrone.co.uk/index.php/pricedrone-bot/)” http://www.example.co.uk

Advertisements

List of useful Linux commands – tips and tricks

Linux is a powerful system with many commands available and I found the below to be quite useful in my daily work.

ls -l –block-size=M – List size in MB instead of bytes.

:w !sudo tee % – save buffer to current file with ‘root’ permission

scp -redmine_subtask_list_columns-master.zip domain\\username@server:/home/DOMAIN/username/ – copy files using scp while using AD logins

tail -f /var/log/logfile.txt – display/refresh changes on last 10 lines of a file

 

How to save a current file opened with vim when ‘root’ access is required

Sometimes when editing a configuration you may find out that the file you opened was opened as ‘sudo’ hence you won’t be able to save it.

There is a solution to it so you don’t have to lose the configuration you have already done.

:w !sudo tee %

% means the current file

:w is saving the buffer not a current file, so if you type type in :w !sudo tee test2.txt ,this would save the buffer in the new test2.txt file instead of the current opened file.

How to change a default gateway on Debian Stretch

First type in

ip route 

this will display a line with ‘default‘ this is your current default gateway

to change it type in as route

ip route change default  via 192.168.1.1 ethX

where ethX is the network interface you want to traffic to go through.

How to fix XenServer Updating issue

Login to your XenServer using SSH then run

xe patch-list

and take uuid

uuid ( RO) : 32e5c75c-29ce-4826-a971-bd92f5615caa
name-label ( RO): XS70E017
name-description ( RO): Public Availability: fixes to Toolstack
size ( RO): 24075528
hosts (SRO): bfcc59b8-322f-4e91-8493-9dee7dec04dc
after-apply-guidance (SRO): restartXAPI

then navigate to

cd /opt/xensource/patch-backup/

ls

and remove the folder based on UUID above which can’t update.

Once this is done you will be able to install problematic update.

How to change server name using ILO with no OS

This cannot be easily changed using GUI apparently ILO is taking this form OS host name but how to changed if there is no OS installed on the server?

ssh to ILO first

Then

cd system1

set oemhp_server_name= YourNewServerName

once done you can check if it has been changed

show oemhp_server_name

and your set sername should be displayed

How to make MSSQL Offline

Open up MSSQL Management Studio

Then Select Database -> your Database -> right click -> Task -> Take Offline.

If the database does not make offline then you can do the following

ALTER DATABASE <dbname> SET OFFLINE WITH ROLLBACK IMMEDIATE

If this is not working then use the following to find spid

USE master SELECT * FROM sys.sysprocesses WHERE dbid = DB_ID('MyDB')

or

EXEC sp_who2

then use

kill spidNumber

To force disconnections, use

ROLLBACK IMMEDIATE USE master ALTER DATABASE MyDB SET SINGLE_USER WITH ROLLBACK IMMEDIATE