List of Linux command and most cases

This is work in progress.

Modules:

apt-get install package_name – debian based package manager
cat _file_ – display file content
dmesg – print or control the kernel ring buffer
ifconfig – tool for configure network card 
ls – list current directory
lsmod – list modules inserted into the kernel
pwd – display current path
yum – package manager for RedHat based system
vi _file_ – Vim editor 

Advertisements

Full Linux directory explanations

/bin/ -> (usr/bin) – executable programs
/dev/
/etc/ – config files
/etc/modules – file containing modules at boot time
/etc/modprobe.d/ – confg files for modules
/home/ – user folder directories
/lib/
/lib64/
/media/
/mnt/ – mount points for file systems
/opt/
/proc/
/root/ – root home directory
/run/
/sbin/
/srv/
/sys/
/tmp/
/usr/
/var/

Yii2 how to setup form conditional validation for form input

Case:

You want to validate one form input based on the result of of the form.

In case I want to make comments to be necessary only if time is larger than 0. 

This can be achieved in the following way.

On Model add validation to public function rules()

[‘reply_time_comment’,’required’,
‘when’=>function ($model){
return $model->reply_timespent >0;
},
‘whenClient’=>”function (attribute, value) {
return $(‘#tickets-reply_timespent’).val() > ‘0’;
}”,’message’=>’Comment can\’t be empty when time is set’],
This is taken from your view while doing show source.
 
Name of form + attribute
tickets-reply_timespent
class=”input-group“>class=”input-group-addon“>Time:id=”tickets-reply_timespentclass=”form-controlname=”Tickets[reply_timespent]“>
 
 
then in your view row class are used so the form are inline instead one after another.
 
 
field($model, ‘reply_timespent’,[‘addon’=> [‘prepend’=> [‘content’=>’Time:’]]])->dropDownList(array_combine($addTimeFilter,$addTimeFilter))->label(false) ?>
 
 
field($model, ‘reply_time_comment’ ,[‘addon’=> [‘prepend’=> [‘content’=>’Time Comments:’]]])->textInput()->label(false) ?>
 
</div>

Configuring Hyper.io terminal on Windows

  1. Install Hyper.io terminal

choco install hyper

choco install npm

Once installed

hyper i hyper-pane

hyper i hyper-search

hyper i hypercw

If you use babun/cygwin then it might worht adding it to windows path

Under system variable add C:\Users\raf.zdziech\.babun\cygwin\bin

This will make all linux command available under comman line such as dig ls etc

once hyper terminal is started

using ctr+shift+g to split screen

ctr+shift+t – to create a new tab

ctr+number(1) to change to a tab

ctr+shift+g to search

 

 

 

 

 

 

How to Add a custom check to Zabbix Agent to check Folder Size under Windows

Edit your zabbix_agentd.conf

Add this to the section

UserParameter=website.size.path[*],powershell -noprofile -command “(ls -r “D:\yourpath\$1″|measure -s Length| select sum| ft -hide|Out-string).trim()”

The above will allow to use one key-item value to check for multiple directories in the same folder. This is because you can’t pass ‘\’ as parameter in Zabbix

or

UserParameter=website.size.myfolder],powershell -noprofile -command “(ls -r “D:\yourpath\testfolder”|measure -s Length| select sum| ft -hide|Out-string).trim()”

You can also replace the powershell command with the one below. This seems to be a lot faster

powershell -command “((cmd /c dir D:\folder\$1 /-C /S /A:-D-L)[-2] -split ‘\s+’)[3]”

Once added restart your Zabbix Agent service under services.msc

Then in Zabbix go into the Configuration->Host-Item and Create New Item

Make sure that you also select Zabbix Active check for this item as otherwise it will not report the data

Under the Key use the same name

for Example:

To check one folder user

website.size.myfolder

to check for multiple use

website.size.path[MyfolderToCheck]

If the check take longer than 3s then increase the timeout in the zabbix_agentd.conf

Option: Timeout
# Spend no more than Timeout seconds on processing
#
# Mandatory: no
# Range: 1-30
# Default:
Timeout=30

 

Yii2 – How to create URL to index with posting data to search

You need to find out what you are looking for in your Controller and then use the following.
LogSearch is SearchModel of Logs and we posting attribute ticket_id
Url::to([‘logs/index’,‘LogsSearch[ticket_id]’=> $model->ticket_id]) ),
This will create to index and post date under ticket_id same as navigating to url typing ticket_id then pressing enter to search.
Real example from Detail View
[
‘attribute’=>’ticket_id’,
‘value’=>Html::a($model->ticket_id,Url::to([‘logs/index’,’LogsSearch[ticket_id]’=> $model->ticket_id]) ),
‘format’=>’raw’,
‘labelColOptions’=>[‘style’=>’width:10%’],
‘valueColOptions’=>[‘style’=>’width:15%’],
],