tag:blogger.com,1999:blog-70734274151791910532024-03-13T14:42:35.942-07:00Andy's linux notesandyhttp://www.blogger.com/profile/08921286377175955589noreply@blogger.comBlogger67125tag:blogger.com,1999:blog-7073427415179191053.post-22077860432396917092021-07-20T07:18:00.005-07:002021-07-20T07:18:35.269-07:00List of tools I should remember to use<p> </p><p>ripGrep - duh!</p><p> <br /></p><p><a href="https://httpie.io/">http </a>- curl alternative</p><p><a href="https://github.com/sharkdp/bat">bat</a> - cat</p><p><a href="https://github.com/sharkdp/fd">fd</a> - find</p><p><a href="https://github.com/lotabout/skim">sk</a> - 'skim' fuzzy finder</p><p><br /></p><p><br /></p>andyhttp://www.blogger.com/profile/08921286377175955589noreply@blogger.com0tag:blogger.com,1999:blog-7073427415179191053.post-13147954754888323872021-05-18T14:16:00.003-07:002021-06-07T00:13:10.171-07:00 Controlling Fan speed on your laptop<p><b>For DELL Fan speed:</b></p><p> </p><p>Use i8kutils:<br /></p><p>* sudo apt-get install i8kutils </p><p><br /></p><p><a href="https://wiki.archlinux.org/title/Fan_speed_control#Dell_laptops">i8kfan</a></p><p>Try and run:</p><p>* /usr/bin/i8kfan </p><p>to see what the fans are set at (0/1/2) </p><p><br /></p><p>To edit i8kconfig:</p><p>* sudo vim /etc/i8kmon.conf </p><p> </p><p>To view CPU temps :</p><p>* sensors<br /></p><p><br /></p>andyhttp://www.blogger.com/profile/08921286377175955589noreply@blogger.com0tag:blogger.com,1999:blog-7073427415179191053.post-44269365996272485072021-05-06T07:58:00.006-07:002021-05-06T07:58:59.376-07:00Mysteries of strace<p><a href="https://mysteries.wizardzines.com/50ms-request.html">From this nice puzzle</a><br /><br /> <span style="background-color: white; color: #111111; font-family: Helmet, Freesans, sans-serif; font-size: 16px;">To figure it out, you can use the</span><span style="background-color: white; color: #111111; font-family: Helmet, Freesans, sans-serif; font-size: 16px;"> </span><code style="color: #2222cc; font-family: monospace, monospace; font-size: 1em;">-T</code><span style="background-color: white; color: #111111; font-family: Helmet, Freesans, sans-serif; font-size: 16px;"> </span><span style="background-color: white; color: #111111; font-family: Helmet, Freesans, sans-serif; font-size: 16px;">flag to strace which tells us how long each system call takes. The number in angle brackets (</span><code style="color: #2222cc; font-family: monospace, monospace; font-size: 1em;"><......></code><span style="background-color: white; color: #111111; font-family: Helmet, Freesans, sans-serif; font-size: 16px;">) at the end of each line is how long that system call took, in seconds. Here's what that looks like:</span></p><pre style="background-color: #f1f5f9; border: 1px solid rgb(0, 85, 187); color: #111111; font-family: monospace, monospace; font-size: 16px; overflow: auto; padding: 0.5em;"> $ strace -tt -T -f -p $(pgrep python)
<pre style="border: 1px solid rgb(0, 85, 187); font-family: monospace, monospace; overflow: auto; padding: 0.5em;">15:56:15.517327 accept4(3, {sa_family=AF_INET, sin_port=htons(48564), sin_addr=inet_addr("5.6.7.8")}, [16], SOCK_CLOEXEC) = 4 <1.889267> <br />15:56:17.407185 getsockname(4, {sa_family=AF_INET, sin_port=htons(8000), sin_addr=inet_addr("1.2.3.4")}, [128->16]) = 0 <0.000018> <br /> </pre>
</pre>andyhttp://www.blogger.com/profile/08921286377175955589noreply@blogger.com0tag:blogger.com,1999:blog-7073427415179191053.post-88428675277099482472020-10-10T08:03:00.005-07:002020-10-10T08:03:46.692-07:00Trouble logging in:<p> </p><p>Check these files for login history & reason for login fails: <br /></p><pre class="code-pre "><code>/var/log/auth.log
/var/log/secure</code></pre><pre class="code-pre "><code> </code></pre><pre class="code-pre "><code>Useful guide on setting up an SFTP server </code></pre><pre class="code-pre "><code>https://www.techrepublic.com/article/how-to-set-up-an-sftp-server-on-linux/</code></pre><pre class="code-pre "><code><br /></code></pre>andyhttp://www.blogger.com/profile/08921286377175955589noreply@blogger.com0tag:blogger.com,1999:blog-7073427415179191053.post-17948532214239246412019-09-23T09:09:00.003-07:002019-09-23T09:27:50.323-07:00 Slicing giant files<div dir="ltr" style="text-align: left;" trbidi="on">
<br />
<br />
Use 'dd' to copy (in this case 3) blocks of data from the giant file to the output:<br />
<br />
<blockquote class="tr_bq">
dd if=giant.json count=3 of=output.json</blockquote>
<br />
trucate could also work.<br />
<br />
For JSON <a href="https://stedolan.github.io/jq/">jq is a great tool:</a><br />
<br />
Here we are catting json and selecting entries with messages length > 0 <br />
<blockquote class="tr_bq">
cat ~/giant.json | jq -cn --stream 'fromstream(1|truncate_stream(inputs))' | jq 'select((.messages | length) > 0) </blockquote>
</div>
andyhttp://www.blogger.com/profile/08921286377175955589noreply@blogger.com0tag:blogger.com,1999:blog-7073427415179191053.post-50719571023558480612019-07-30T04:22:00.002-07:002019-07-30T04:22:53.098-07:00Use of * in bash<div dir="ltr" style="text-align: left;" trbidi="on">
Bash will parse and expand special args <b>before</b> your commands.<br />
<br />
Hence <b>echo *</b> will list files in your dir like <b>ls</b>.<br />
<br />
<br />
Consider the following<a href="https://superuser.com/questions/901183/who-deals-with-the-star-in-echo"> interresting case copied from SO</a>.
A directory has these contents:<br />
<ul>
<li>test (regular file)</li>
<li>test1 (directory)</li>
<li>test2 (directory)</li>
<li>test3 (directory)</li>
</ul>
If you then type `<b><code>mv *</code></b>` something seemingly weird happens: <b><code>test3</code></b> is there, but the rest is gone. While weird at first, it makes sense once you understand what bash actually passes to `<code><b>mv</b>`</code>. Because of the asterisk, bash interprets <code><b>mv *</b></code> as <b><code>mv test test1 test2 test3</code></b>,
and when mv gets that list, it'll assume that the last arguement is the
destination, which is where all of the files would've been moved.<br />
</div>
andyhttp://www.blogger.com/profile/08921286377175955589noreply@blogger.com0tag:blogger.com,1999:blog-7073427415179191053.post-32397026967586474872019-06-20T02:17:00.000-07:002019-06-20T02:17:17.416-07:00Clear up space, remove old ubuntu packages:<div dir="ltr" style="text-align: left;" trbidi="on">
Clear up space, remove old ubuntu packages:<br />
<br />
sudo apt-get update && sudo apt-get autoclean && sudo apt-get clean && sudo apt-get autoremove<br /></div>
andyhttp://www.blogger.com/profile/08921286377175955589noreply@blogger.com0tag:blogger.com,1999:blog-7073427415179191053.post-29983390371968574962018-12-28T11:44:00.002-08:002018-12-29T10:11:01.530-08:00Simple systemd / systemctl<div dir="ltr" style="text-align: left;" trbidi="on">
A basic systemd file:<br />
<br />
<blockquote>
[Unit]<br />
Description=test<br />
<br />
[Service]<br />
User=andy<br />
Type=simple<br />
ExecStart=/home/andy/test<br />
<br />
[Install]<br />
WantedBy=multi-user.target</blockquote>
<br />
The file /home/andy/test <b>must</b> begin with: <br />
<blockquote class="tr_bq">
#!/bin/sh -</blockquote>
The core systemd commands: Not type <b>systemctl not systemd</b> <br />
<ul style="text-align: left;">
<li>sudo systemctl status test </li>
<li>sudo systemctl restart test</li>
<li>sudo systemctl stop test</li>
</ul>
For when you add something to:<b> /etc/systemd/system</b> <br />
<div>
<ul style="text-align: left;">
<li>sudo systemctl daemon-reload </li>
</ul>
Sending logs to syslog from services started by systemd:</div>
<div>
Taken from here: </div>
<div>
https://stackoverflow.com/questions/37585758/how-to-redirect-output-of-systemd-service-to-a-file</div>
<div>
</div>
<div>
Use the following properties in your systemd service unit file:<br />
<blockquote class="tr_bq">
<pre><code>StandardOutput=syslog
StandardError=syslog
SyslogIdentifier=<your identifier="" program=""> # without any quote
</your></code></pre>
</blockquote>
Then, assuming your distribution is using rsyslog to manage syslogs, create a file in <code>/etc/rsyslog.d/<new_file>.conf</new_file></code> with the following content:<br />
<pre><code>if $programname == '<your identifier="" program="">' then /path/to/log/file.log
& stop
</your></code></pre>
restart rsyslog (<code>sudo systemctl restart rsyslog</code>) <ul style="text-align: left;">
</ul>
</div>
</div>
andyhttp://www.blogger.com/profile/08921286377175955589noreply@blogger.com0tag:blogger.com,1999:blog-7073427415179191053.post-61033203058096164132018-03-05T16:36:00.000-08:002018-03-05T16:36:00.056-08:00CTF notes<div dir="ltr" style="text-align: left;" trbidi="on">
Notes on doing some CTFs:<br />
<br />
<h3 style="text-align: left;">
How to setup Vbox:</h3>
<div>
Grab an ubuntu image from osboxes.org</div>
<div>
user: osboxes </div>
<div>
pass: osboxes.org</div>
<div>
<br /></div>
Inside your vmm, Install open ssh on your slave:<br />
<blockquote class="tr_bq" style="background-color: #eff0f1; border: 0px; box-sizing: inherit; color: #393318; font-family: consolas, menlo, monaco, "lucida console", "liberation mono", "dejavu sans mono", "bitstream vera sans mono", "courier new", monospace, sans-serif; font-size: 13px; font-stretch: inherit; line-height: inherit; margin-bottom: 1em; max-height: 600px; overflow: auto; padding: 5px; vertical-align: baseline; width: auto; word-wrap: normal;">
<code style="border: 0px; box-sizing: inherit; font-family: Consolas, Menlo, Monaco, "Lucida Console", "Liberation Mono", "DejaVu Sans Mono", "Bitstream Vera Sans Mono", "Courier New", monospace, sans-serif; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline; white-space: inherit;"><span class="pln" style="border: 0px; box-sizing: inherit; color: #303336; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">sudo apt</span><span class="pun" style="border: 0px; box-sizing: inherit; color: #303336; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">-</span><span class="pln" style="border: 0px; box-sizing: inherit; color: #303336; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">get install openssh</span><span class="pun" style="border: 0px; box-sizing: inherit; color: #303336; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">-</span><span class="pln" style="border: 0px; box-sizing: inherit; color: #303336; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">server</span></code></blockquote>
<div>
<code style="border: 0px; box-sizing: inherit; font-family: Consolas, Menlo, Monaco, "Lucida Console", "Liberation Mono", "DejaVu Sans Mono", "Bitstream Vera Sans Mono", "Courier New", monospace, sans-serif; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline; white-space: inherit;"><span class="pln" style="border: 0px; box-sizing: inherit; color: #303336; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;"><br /></span></code></div>
Open the right ports on host:<br />
<blockquote class="tr_bq">
VBoxManage modifyvm asdf --natpf1 "ssh,tcp,,3022,,22"</blockquote>
ssh/sftp in:<br />
<blockquote class="tr_bq">
ssh -p 3022 osboxes@127.0.0.1</blockquote>
<blockquote class="tr_bq">
sftp -P 3022 osboxes@127.0.0.1</blockquote>
<h3 style="text-align: left;">
How to wget / curl:</h3>
curl url<br />
<h4 style="text-align: left;">
wget posting data and saving/loading data to/from cookie</h4>
wget url --post-data="password=ee&user=hr" --save-cookies sc.txt<br />
wget url --load-cookies=sc.txt<br />
<br />
Also don't forget simple developer mode and google chrome.<br />
<br />
<h3 style="text-align: left;">
Vulnerabilities check:</h3>
<h4 style="text-align: left;">
File Loading:</h4>
* Look for files that load other files or data<br />
* Look for string replacing that can be bypassed<br />
<h4 style="text-align: left;">
Login:</h4>
<div>
* Check for session state not being cleared properly.</div>
<div>
<br /></div>
<h4 style="text-align: left;">
File Execution:</h4>
<div>
* Check the execution path: Add things to the path.</div>
<div>
<br /></div>
<br />
<div>
</div>
<br />
<div style="-webkit-text-stroke-width: 0px; color: black; font-family: Times; font-size: medium; font-style: normal; font-variant-caps: normal; font-variant-ligatures: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: left; text-decoration-color: initial; text-decoration-style: initial; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px;">
<h4 style="text-align: left;">
Disassemble files:</h4>
<div style="margin: 0px;">
* objdump -d file > raw</div>
<div style="margin: 0px;">
* gdb file</div>
<pre style="background-color: #eff0f1; border: 0px; box-sizing: inherit; color: #242729; font-family: consolas, menlo, monaco, "lucida console", "liberation mono", "dejavu sans mono", "bitstream vera sans mono", "courier new", monospace, sans-serif; font-size: 13px; font-stretch: inherit; line-height: inherit; margin: 0px 0px 1em; max-height: 600px; overflow: auto; padding: 5px; vertical-align: baseline; width: auto; word-wrap: normal;"><ul style="text-align: left;">
<li>r (run)</li>
<li>c (contine)</li>
<li>b X (breakpoint at function X)</li>
<li>si (step one place forwards)</li>
<li>info registers (what is in my registers</li>
</ul>
</pre>
</div>
</div>
andyhttp://www.blogger.com/profile/08921286377175955589noreply@blogger.com0tag:blogger.com,1999:blog-7073427415179191053.post-72693387274322244032018-03-05T16:34:00.003-08:002018-03-05T16:34:39.706-08:00nginx configuration<div dir="ltr" style="text-align: left;" trbidi="on">
<blockquote class="tr_bq">
server {<br /> listen 80;<br /> server_name nuclearcarrot.co.uk www.nuclearcarrot.co.uk;<br /> server_name_in_redirect off;<br /> root /srv/www/nuclearcarrot.com/nuclearcarrot/;<br /> access_log /srv/www/nuclearcarrot.com/logs/access.log;<br /> error_log /srv/www/nuclearcarrot.com/logs/error.log;<br /> rewrite ^/$ /andyboot.html permanent;<br /> rewrite ^/favicon.ico$ /img/favicon.ico last;<br /> <br /> # Dont expose hidden files to the web<br /> location ~ /\. {<br /> return 404;<br /> } </blockquote>
<blockquote class="tr_bq">
} </blockquote>
<div>
I want to talk about my old nginx config file.</div>
<div>
<ul style="text-align: left;">
<li><b>server_name</b> = What urls it should listen to</li>
<li><b>root</b> = where to serve static files from</li>
<li><b>rewrite</b> = These are interesting - if a client asks for X we redirect them to Y instead. - Here it was used in a desperate attempt to get more SEO juice by redirecting / to my name.</li>
</ul>
</div>
<div>
<br /></div>
</div>
andyhttp://www.blogger.com/profile/08921286377175955589noreply@blogger.com0tag:blogger.com,1999:blog-7073427415179191053.post-31715532265849547242018-02-07T06:42:00.001-08:002019-04-11T13:31:42.279-07:00How to make things start automatically upstart<div dir="ltr" style="text-align: left;" trbidi="on">
<div dir="ltr" style="text-align: left;" trbidi="on">
To run things on boot with <b>upstart</b> add a conf file to<b> /etc/init</b><b>/</b><br />
Here is my windowfunctions conf file on my linode:<br />
<b><br /></b>
<br />
<pre>start on runlevel [2345]
stop on runlevel [!2345]
script
<span style="white-space: pre;"> </span>chdir /home/andy/window_funcs/
<span style="white-space: pre;"> </span>export PATH="/root/.cargo/bin:$PATH"
<span style="white-space: pre;"> </span>export ROCKET_ENV="prod"
<span style="white-space: pre;"> </span>echo "path is: $PATH"
<span style="white-space: pre;"> </span>exec cargo +nightly run --release .
end script</pre>
</div>
<br />
To <b>view the logs</b> for upstart, all logs are stored in <b>/var/log/upstart/</b>:<br />
<br />
cat /var/log/upstart/windowfunctions.log<br />
<br />
Try adding to:<br />
/etc/rc0.local</div>
andyhttp://www.blogger.com/profile/08921286377175955589noreply@blogger.com0tag:blogger.com,1999:blog-7073427415179191053.post-4086682987729019672018-01-19T06:59:00.001-08:002018-01-19T07:00:00.056-08:00track read & writes of a grep<div dir="ltr" style="text-align: left;" trbidi="on">
listen to read & write calls mac:<br />
<blockquote class="tr_bq">
sudo rwsnoop -n grep</blockquote>
listen to read & write calls linux:<br />
<blockquote class="tr_bq">
sudo strace -n grep</blockquote>
</div>
andyhttp://www.blogger.com/profile/08921286377175955589noreply@blogger.com0tag:blogger.com,1999:blog-7073427415179191053.post-70069521143061308472017-03-08T03:42:00.002-08:002017-03-23T09:39:00.205-07:00sysdig<div dir="ltr" style="text-align: left;" trbidi="on">
To see system calls. <br />
<br />
Primary resource for sysdig examples:<br />
<a href="http://www.sysdig.org/wiki/sysdig-examples/">http://www.sysdig.org/wiki/sysdig-examples/</a><br />
<br />
Get 5 seconds of system calls:<br />
<ul style="text-align: left;">
<li>sudo timeout 5s sysdig -w hi.cap</li>
</ul>
<br />
Analise the file [use tab completion there are loads of functions]:<br />
<ul style="text-align: left;">
<li> IO reads & No. reads that failed: </li>
<ul>
<li>sysdig -r hi.cap evt.type=read</li>
<li>sysdig -r hi.cap evt.type=read and evt.failed = true | wc -l </li>
</ul>
</ul>
<ul style="text-align: left;">
<li>Calls to IP:</li>
<ul>
<li>sysdig -r hi.cap fd.ip=IP</li>
</ul>
<li> Top sys calls:</li>
<ul>
<li>sysdig -r hi.cap -c topscalls</li>
</ul>
<li>Speed of sys calls:</li>
<ul>
<li>sysdig -c spectrogram</li>
</ul>
</ul>
Or call sysdig directly without the snapshot file: <br />
<div>
<ul style="text-align: left;">
<li>See http calls:</li>
<ul>
<li>sudo sysdig -c httplog </li>
</ul>
<li>See busy containers</li>
<ul>
<li> sudo sysdig -c topcontainers_cpu </li>
</ul>
<li>
See the top processes in terms of network bandwidth usage<code> </code><br />
<ul>
<li><code>sysdig -c topprocs_net</code></li>
</ul>
<code></code></li>
<li>View the list of containers running on the machine and their resource usage
</li>
<ul>
<li><pre><code>sudo csysdig -vcontainers</code></pre>
</li>
</ul>
</ul>
</div>
<ul style="text-align: left;">
</ul>
<h2 style="text-align: left;">
Alternative:</h2>
* sudo strace<br />
eg: to see calls made by a command:<br />
* sudo strace touch foo <br />
</div>
andyhttp://www.blogger.com/profile/08921286377175955589noreply@blogger.com0tag:blogger.com,1999:blog-7073427415179191053.post-74360193543204018202017-02-06T03:01:00.001-08:002017-02-06T03:01:35.190-08:00a hard crash / kernal panic<div dir="ltr" style="text-align: left;" trbidi="on">
<br />
Many 0s in a log file show like this: <br />
^@^@^@^@^@^@^@^@^@^@<br />
<br />
.. Indicate a massive failure when writing the log. Probably kernal panic.<br />
<br />
Check system level things<br />
* /var/log/syslog (all logs)<br />
* /var/log/kern.log (kernal logs)<br />
* dmesg (logs of kernal ring buffer - The IO for the kernal)</div>
andyhttp://www.blogger.com/profile/08921286377175955589noreply@blogger.com0tag:blogger.com,1999:blog-7073427415179191053.post-34476914917385653852016-10-26T03:23:00.001-07:002016-10-26T03:23:53.148-07:00How 2 add new volume (disk) on AWS<div dir="ltr" style="text-align: left;" trbidi="on">
<br />
<br />
<h4 style="text-align: left;">
AWS:</h4>
<ul style="text-align: left;">
<li>Search for correct instance. </li>
<li>Copy instance ID</li>
<li>Note zone.</li>
</ul>
<h4 style="text-align: left;">
SSH to box:</h4>
<ul style="text-align: left;">
<li>Look at current mounted volumes:</li>
<ul>
<li>ls /dev/xcd*</li>
</ul>
</ul>
<h4 style="text-align: left;">
AWS:</h4>
<ul style="text-align: left;">
<li>Create a volume</li>
<ul>
<li>In same zone as the instance</li>
</ul>
<li>Attach volume to instance</li>
<ul>
<li>Choose VOL_NAME that doesn't clash with above mounted vols (just increment the letter by one).</li>
</ul>
</ul>
<h4 style="text-align: left;">
SSH to box and mount drive:</h4>
<div>
<ul style="text-align: left;">
<li>sudo fdisk /dev/VOL_NAME</li>
<li># h -> for help</li>
<li># p -> view existing partitioning scheme</li>
<li># default whole volume partitioning steps:</li>
<li># 1) n</li>
<li># 2) p</li>
<li># 3) enter, enter, enter</li>
<li># 4) w</li>
</ul>
</div>
<br />
<br />
<h4 style="text-align: left;">
Format disk</h4>
<div>
<br />
<ul style="text-align: left;">
<li>Note: now VOL_NAME is partitioned the usable name will probably end in a 1</li>
<ul>
<li>mke2fs -t ext4 /dev/VOL_NAME1</li>
</ul>
</ul>
<br />
<br />
<h4 style="text-align: left;">
Attach new disk:</h4>
<ul style="text-align: left;"><ul>
<li>mkdir /NEWDIR</li>
<li>mount /dev/VOL_NAME1 /NEWDIR</li>
</ul>
</ul>
<h4 style="text-align: left;">
Now add disk to fstab:</h4>
<ul style="text-align: left;">
<li>We will create another line mapping the new disk</li>
<ul>
<li>cat <a class="file" href="file:///etc/fstab" title="/etc/fstab">/etc/fstab</a></li>
</ul>
<li>To see the UUID of the disk</li>
<ul>
<li>ls -l /dev/disk/by-uuid | grep VOL_NAME</li>
</ul>
<li>The above is done in one command like this:</li>
<ul>
<li>echo "UUID=$(ls -l /dev/disk/by-uuid/ | grep VOL_NAME | awk '{print $9}') /NEWDIR ext4 defaults 0 2" >> <a class="file" href="file:///etc/fstab" title="/etc/fstab">/etc/fstab</a></li>
</ul>
</ul>
</div>
</div>
andyhttp://www.blogger.com/profile/08921286377175955589noreply@blogger.com0tag:blogger.com,1999:blog-7073427415179191053.post-48147379598927484992016-10-13T10:59:00.000-07:002019-05-12T01:49:24.746-07:00Files<div dir="ltr" style="text-align: left;" trbidi="on">
<br />
Data about a file:<br />
<br />
<ul style="text-align: left;">
<li>stat <file></file></li>
</ul>
<div>
Inode definition from wikipedia:</div>
<div>
<ul style="text-align: left;">
<li><span style="background-color: white; color: #252525; font-family: sans-serif; font-size: 14px; line-height: 22.4px;"> </span><b style="background-color: white; color: #252525; font-family: sans-serif; font-size: 14px; line-height: 22.4px;">inode</b><span style="background-color: white; color: #252525; font-family: sans-serif; font-size: 14px; line-height: 22.4px;"> is a </span><a href="https://en.wikipedia.org/wiki/Data_structure" style="background: none rgb(255, 255, 255); color: #0b0080; font-family: sans-serif; font-size: 14px; line-height: 22.4px; text-decoration: none;" title="Data structure">data structure</a><span style="background-color: white; color: #252525; font-family: sans-serif; font-size: 14px; line-height: 22.4px;"> used to represent a </span><a class="mw-redirect" href="https://en.wikipedia.org/wiki/Filesystem" style="background: none rgb(255, 255, 255); color: #0b0080; font-family: sans-serif; font-size: 14px; line-height: 22.4px; text-decoration: none;" title="Filesystem">filesystem</a><span style="background-color: white; color: #252525; font-family: sans-serif; font-size: 14px; line-height: 22.4px;"> object</span></li>
<li><span style="background-color: white; color: #252525; font-family: sans-serif; font-size: 14px; line-height: 22.4px;"><span style="line-height: 22.4px;"> Each <b>inode</b> stores the attributes and disk block location(s) of the filesystem object's data</span></span></li>
</ul>
<span style="color: #252525; font-family: sans-serif;"><span style="font-size: 14px; line-height: 22.4px;">How much load a disk is under: </span></span><br />
<span style="color: #252525; font-family: sans-serif;"><span style="font-size: 14px; line-height: 22.4px;"> * df -h</span></span><br />
<span style="color: #252525; font-family: sans-serif;"><span style="font-size: 14px; line-height: 22.4px;"> * iostat <filesystem><br /></filesystem></span></span></div>
</div>
andyhttp://www.blogger.com/profile/08921286377175955589noreply@blogger.com0tag:blogger.com,1999:blog-7073427415179191053.post-87385994401542465192016-06-01T08:22:00.004-07:002016-11-22T04:03:37.476-08:00Curl with auth username / password<div dir="ltr" style="text-align: left;" trbidi="on">
<div dir="ltr" style="text-align: left;" trbidi="on">
We can use curl even if it requires you to be logged in. Example<br />
<br />
<ul style="text-align: left;">
<li>curl 'https://api.pinnaclesports.com/v1/sports' -x 1.1.2.9:8888 -H "Authorization: Basic `echo -n 'user:password' | base64`"</li>
</ul>
<br />
<ul style="text-align: left;"><ul>
<li>-x = Proxy to use</li>
<li>-H = headers - we put the username and password in here</li>
</ul>
</ul>
<br />
Curl to view a certificate<br />
<ul style="text-align: left;">
<li>curl -v https://www.google.com </li>
</ul>
View more certificate details:<br />
<ul style="text-align: left;">
<li>openssl s_client -showcerts -connect www.google.com:443 </li>
</ul>
</div>
If this isn't good enough fire up <a href="http://bootandy-linux.blogspot.co.uk/2014/09/tcpdump-wireshark-sudo-tcpdump-n-i.html">tcpdump and wireshark</a> <br />
<br /></div>
andyhttp://www.blogger.com/profile/08921286377175955589noreply@blogger.com0tag:blogger.com,1999:blog-7073427415179191053.post-46391530879019569402016-04-08T11:09:00.002-07:002016-04-08T11:13:42.503-07:00Memory leaks beyond Htop<div dir="ltr" style="text-align: left;" trbidi="on">
<br />
slabtop:<br />
Like top for kernal<br />
display kernel slab cache information in real time<br />
<br />
Where is my memory used [if htop no good]:<br />
sudo cat /proc/meminfo<br />
<div>
<br /></div>
<div>
Interesting info on linux file system: http://unix.stackexchange.com/questions/4402/what-is-a-superblock-inode-dentry-and-a-file</div>
</div>
andyhttp://www.blogger.com/profile/08921286377175955589noreply@blogger.com0tag:blogger.com,1999:blog-7073427415179191053.post-60988593416768156852016-03-11T10:19:00.000-08:002016-04-08T09:09:20.324-07:00DNS mysteries<div dir="ltr" style="text-align: left;" trbidi="on">
<br style="background-color: white; color: #222222; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 13.2px; line-height: 18.48px;" />
<span style="background-color: white; color: #222222; font-family: "arial" , "tahoma" , "helvetica" , "freesans" , sans-serif; font-size: 13.2px; line-height: 18.48px;">Check your </span><b style="background-color: white; color: #222222; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 13.2px; line-height: 18.48px;">/etc/resolv.conf </b><span style="background-color: white; color: #222222; font-family: "arial" , "tahoma" , "helvetica" , "freesans" , sans-serif; font-size: 13.2px; line-height: 18.48px;">for which DNS server you are using</span><br />
<span style="background-color: white; color: #222222; font-family: "arial" , "tahoma" , "helvetica" , "freesans" , sans-serif; font-size: 13.2px; line-height: 18.48px;"><br /></span>
<span style="background-color: white; color: #222222; font-family: "arial" , "tahoma" , "helvetica" , "freesans" , sans-serif; font-size: 13.2px; line-height: 18.48px;">Use dig to query if your DNS is working:</span><br />
<span style="background-color: white; color: #222222; font-family: "arial" , "tahoma" , "helvetica" , "freesans" , sans-serif; font-size: 13.2px; line-height: 18.48px;">dig git.myserver.com</span><br />
<span style="background-color: white; color: #222222; font-family: "arial" , "tahoma" , "helvetica" , "freesans" , sans-serif; font-size: 13.2px; line-height: 18.48px;"><span style="font-size: 13.2px; line-height: 18.48px;">dig git.myserver.com @ip_for_my_dns</span></span><br />
<br />
<span style="background-color: white; color: #222222; font-family: "arial" , "tahoma" , "helvetica" , "freesans" , sans-serif;"><span style="font-size: 13.2px; line-height: 18.48px;"><br /></span></span>
<span style="color: #222222; font-family: "arial" , "tahoma" , "helvetica" , "freesans" , sans-serif;"><span style="background-color: white; font-size: 13.2px; line-height: 18.48px;">DNS Servers:</span></span><br />
<span style="color: #222222; font-family: "arial" , "tahoma" , "helvetica" , "freesans" , sans-serif;"><span style="background-color: white; font-size: 13.2px; line-height: 18.48px;">Have serial number which must be incremented to show DNS entries were changed. </span></span><br />
<span style="color: #222222; font-family: "arial" , "tahoma" , "helvetica" , "freesans" , sans-serif;"><span style="background-color: white; font-size: 13.2px; line-height: 18.48px;"><br /></span></span>
<span style="color: #222222; font-family: "arial" , "tahoma" , "helvetica" , "freesans" , sans-serif;"><span style="background-color: white; font-size: 13.2px; line-height: 18.48px;">(Remember dns name layouts are backwards)</span></span><br />
<span style="color: #222222; font-family: "arial" , "tahoma" , "helvetica" , "freesans" , sans-serif;"><span style="background-color: white; font-size: 13.2px; line-height: 18.48px;"><br /></span></span>
<span style="color: #222222; font-family: "arial" , "tahoma" , "helvetica" , "freesans" , sans-serif;"><span style="background-color: white; font-size: 13.2px; line-height: 18.48px;">A vs CNAME</span></span><br />
<span style="color: #222222; font-family: "arial" , "tahoma" , "helvetica" , "freesans" , sans-serif;"><span style="background-color: white; font-size: 13.2px; line-height: 18.48px;">A points to ip</span></span><br />
<span style="color: #222222; font-family: "arial" , "tahoma" , "helvetica" , "freesans" , sans-serif;"><span style="background-color: white; font-size: 13.2px; line-height: 18.48px;">CNAME points to an A or CNAME entry by name</span></span><br />
<span style="background-color: white; font-size: 13.2px; line-height: 18.48px;"><span style="color: #222222; font-family: "arial" , "tahoma" , "helvetica" , "freesans" , sans-serif;">https://support.dnsimple.com/articles/differences-a-cname-records/</span></span><br />
<span style="background-color: white; font-size: 13.2px; line-height: 18.48px;"><span style="color: #222222; font-family: "arial" , "tahoma" , "helvetica" , "freesans" , sans-serif;"><br /></span></span></div>
andyhttp://www.blogger.com/profile/08921286377175955589noreply@blogger.com0tag:blogger.com,1999:blog-7073427415179191053.post-80247825191255937982016-02-12T07:07:00.002-08:002016-02-12T07:07:32.300-08:00apt-get install<div dir="ltr" style="text-align: left;" trbidi="on">
<br />
<h3 style="box-sizing: border-box; color: #333333; font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace; font-size: 15px; font-stretch: normal; overflow: auto; text-align: left; white-space: pre-wrap;">
<span style="color: black; font-family: "times new roman"; font-size: small; white-space: normal;">rlwrap </span></h3>
<div style="box-sizing: border-box; color: #333333; font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace; font-size: 15px; font-stretch: normal; overflow: auto; text-align: left; white-space: pre-wrap;">
readline wrapper / command history even inside a shitty program that doesn't support it</div>
<br />
<a href="https://github.com/hanslub42/rlwrap">https://github.com/hanslub42/rlwrap</a><br />
<br />
rlwrap nc localhost 80<br />
<br />
<br /></div>
andyhttp://www.blogger.com/profile/08921286377175955589noreply@blogger.com0tag:blogger.com,1999:blog-7073427415179191053.post-72764058007819566562016-01-17T05:07:00.003-08:002016-01-17T05:07:57.292-08:00connect to wireless<div dir="ltr" style="text-align: left;" trbidi="on">
<div style="text-align: left;">
<span style="font-family: inherit;">List networks:</span></div>
<ul style="text-align: left;">
<li><span style="font-family: inherit;">sudo iwlist scan</span></li>
</ul>
<code style="border: 0px; margin: 0px; padding: 0px; white-space: inherit;"><span style="font-family: inherit;"><br /></span></code><code style="border: 0px; margin: 0px; padding: 0px; white-space: inherit;"><span style="font-family: inherit;">Connect to network:</span></code><br />
<ul style="text-align: left;">
<li><span style="font-family: inherit;">nmcli d wifi connect <ssid> password <pass> </pass></ssid></span></li>
</ul>
<span style="font-family: inherit;">To restart networking:</span><br />
<ul style="text-align: left;">
<li><span style="font-family: inherit;">sudo /etc/init.d/networking restart</span></li>
</ul>
<span style="font-family: inherit;"><br /></span><span style="font-family: inherit;">Useful SO posts:</span><br />
<ul style="text-align: left;">
<li><span style="font-family: inherit;">http://askubuntu.com/questions/461825/connect-to-wifi-from-command-line</span></li>
</ul>
<ul style="text-align: left;">
<li><span style="font-family: inherit;">http://askubuntu.com/questions/398581/is-there-a-terminal-command-to-verify-if-wifi-is-enabled</span></li>
</ul>
<ul style="text-align: left;">
<li><span style="font-family: inherit;">http://askubuntu.com/questions/330026/configure-connect-wireless-network-through-the-command-line-in-ubuntu-12-04</span></li>
</ul>
<br />
<br />
<br />
<div>
<br /></div>
</div>
andyhttp://www.blogger.com/profile/08921286377175955589noreply@blogger.com0tag:blogger.com,1999:blog-7073427415179191053.post-85274275637339709942015-12-21T07:54:00.001-08:002015-12-21T07:54:55.438-08:00How do I do anything?.....<div dir="ltr" style="text-align: left;" trbidi="on">
apropos searches the manual page names and descriptions.<br />
<div>
<br /></div>
apropos <search term=""></search><br />
man <command></command><br />
<br /></div>
andyhttp://www.blogger.com/profile/08921286377175955589noreply@blogger.com0tag:blogger.com,1999:blog-7073427415179191053.post-6303720818108489782015-06-04T13:26:00.000-07:002015-06-04T13:26:12.538-07:00How to mount a network disk/NAS via NFS:<div dir="ltr" style="text-align: left;" trbidi="on">
<span style="background-color: white; color: #333333; font-family: Georgia, Century, Times, serif; font-size: 15px; line-height: 21px;">Ensure you have esentials:</span><br />
<br />
<ul style="text-align: left;">
<li><span style="background-color: white; color: #333333; font-family: Georgia, Century, Times, serif; font-size: 15px; line-height: 21px;">sudo apt-get install nfs-common, </span><span style="color: #333333; font-family: Georgia, Century, Times, serif;"><span style="font-size: 15px; line-height: 21px;">nfs-kernel-server</span></span></li>
</ul>
<span style="background-color: white; color: #333333; font-family: Georgia, Century, Times, serif; font-size: 15px; line-height: 21px;">To mount drive:</span><br />
<br />
<ul style="text-align: left;">
<li><span style="background-color: white; color: #333333; font-family: Georgia, Century, Times, serif; font-size: 15px; line-height: 21px;">showmount -e</span><span style="background-color: white; color: #333333; font-family: Georgia, Century, Times, serif; font-size: 15px; line-height: 21px;"> </span></li>
<li><span style="background-color: white; color: #333333; font-family: Georgia, Century, Times, serif; font-size: 15px; line-height: 21px;">sudo mount -o soft,intr,rsize=8192,wsize=8192 192.168.0.15:/nfs ~</span><yourmachine style="box-sizing: border-box; color: #333333; font-family: Georgia, Century, Times, serif; font-size: 15px; line-height: 21px;">/nfs/</yourmachine></li>
</ul>
</div>
andyhttp://www.blogger.com/profile/08921286377175955589noreply@blogger.com0tag:blogger.com,1999:blog-7073427415179191053.post-35106530315950638062015-03-02T02:49:00.002-08:002019-03-12T08:54:25.338-07:00Advanced Grepping<div dir="ltr" style="text-align: left;" trbidi="on">
<h3 style="text-align: left;">
Shell & Grep: Where we count certain strings in a log file by hour.</h3>
<br />
for var in `seq 10 23`; <br />
do <br />
echo 'Feb 28 '$var;<br />
grep 'Feb 28 '$var /log/cli/Hanson/2015-02-28.log | grep 'Duplicate order cancel' | wc -l;<br />
done<br />
<br />
<h3 style="text-align: left;">
How can we see: Number of Errors in several files. </h3>
<div style="text-align: left;">
Output as: Number Filename</div>
<div style="text-align: left;">
<br /></div>
grep -RIci "ERROR" . | awk -v FS=":" -v OFS="\t" '$2>0 { print $2, $1 }' | sort -hr<br /> </div>
andyhttp://www.blogger.com/profile/08921286377175955589noreply@blogger.com0tag:blogger.com,1999:blog-7073427415179191053.post-62962778948419005052015-02-25T03:03:00.001-08:002015-02-25T03:03:59.425-08:00Which process is using my port?<div dir="ltr" style="text-align: left;" trbidi="on">
Find out which process is listening on port 6501:<br /> netstat -anpt | grep 6501<br />
<br />
output: [num before python is process id]<br />tcp 0 0 127.0.1.1:6501 0.0.0.0:* LISTEN 26541/python <br />
<div>
<br /></div>
</div>
andyhttp://www.blogger.com/profile/08921286377175955589noreply@blogger.com0