<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:content="http://purl.org/rss/1.0/modules/content/"><channel><title>Linux on Simplestory</title><link>https://simplestory.github.io/en/tags/linux/</link><description>Recent content in Linux on Simplestory</description><generator>Hugo</generator><language>en-us</language><copyright>Simplestory</copyright><lastBuildDate>Fri, 02 Mar 2018 00:00:00 +0000</lastBuildDate><atom:link href="https://simplestory.github.io/en/tags/linux/index.xml" rel="self" type="application/rss+xml"/><item><title>Using g++ and gdb</title><link>https://simplestory.github.io/en/posts/20180302_5ed219da904f7b6718ebebb4c8b47d3c/</link><pubDate>Fri, 02 Mar 2018 00:00:00 +0000</pubDate><guid>https://simplestory.github.io/en/posts/20180302_5ed219da904f7b6718ebebb4c8b47d3c/</guid><description>&lt;blockquote&gt;
&lt;p&gt;G++ is the C++ compiler under Unix/Linux, and gdb is a powerful debugging tool under Unix/Linux. Most of the time, the C/C++ code we write does not run on Windows but on a Linux system. Here I record some usage of g++ and gdb in case they are needed.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;h3 id="using-g"&gt;Using g++&lt;/h3&gt;
&lt;p&gt;When g++ performs compilation work, it needs 4 steps in total:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Preprocessing, generating a .i file, mainly expanding header files and macro definitions: &lt;code&gt;g++ -E test.cpp -o test.i&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;Compilation, converting the preprocessed file into assembly language and generating a .s file: &lt;code&gt;g++ -S test.i -o test.s&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;Assembly, turning the assembly into object code (machine code) and generating a .o file, mainly converting the .s file into a binary file: &lt;code&gt;g++ -c test.s -o test.o&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;Linking, linking the object code to generate an executable program: &lt;code&gt;g++ test.o -o test&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;The steps above can also be done with a single command:&lt;/p&gt;</description></item><item><title>Configuring Django on Ubuntu</title><link>https://simplestory.github.io/en/posts/20180219_c851e812699d1207837d404c0af593ce/</link><pubDate>Mon, 19 Feb 2018 00:00:00 +0000</pubDate><guid>https://simplestory.github.io/en/posts/20180219_c851e812699d1207837d404c0af593ce/</guid><description>&lt;blockquote&gt;
&lt;p&gt;At the time of the 2018 Spring Festival, heaven knows what I went through, posting a blog article on the fourth day of the new year. Django was actually configured before the New Year; I had just learned some knowledge about developing web applications with python at that time, so I configured it along the way.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;&lt;strong&gt;Environment used for the configuration&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;System: Ubuntu16.04 (LTS)&lt;/li&gt;
&lt;li&gt;python version: python3.6 (using Anaconda to create a virtual environment)&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id="preparation"&gt;Preparation&lt;/h2&gt;
&lt;h4 id="uninstalling-an-old-version-of-django"&gt;Uninstalling an old version of Django&lt;/h4&gt;
&lt;p&gt;If you are upgrading from an older version of Django, you need to deal with the old version a little.&lt;/p&gt;</description></item><item><title>Configuring Tensorflow on Linux</title><link>https://simplestory.github.io/en/posts/20180204_68b9e972b5a534bc31d12d9be53b57ec/</link><pubDate>Sun, 04 Feb 2018 00:00:00 +0000</pubDate><guid>https://simplestory.github.io/en/posts/20180204_68b9e972b5a534bc31d12d9be53b57ec/</guid><description>&lt;blockquote&gt;
&lt;p&gt;Borrowing a line from the &lt;a href="http://www.tensorfly.cn/"&gt;TensorFlow Chinese community&lt;/a&gt;: TensorFlow, an open-source magic tool for artificial intelligence.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;&lt;strong&gt;Environment used for the configuration&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;System: Ubuntu16.04 (LTS)&lt;/li&gt;
&lt;li&gt;python version: python3.6 (using Anaconda to create a virtual environment)&lt;/li&gt;
&lt;li&gt;Nvidia card: Geforce 920M (if there is no Nvidia card, only the CPU version can be installed)&lt;/li&gt;
&lt;/ul&gt;
&lt;h1 id="installing-tensorflow"&gt;Installing Tensorflow&lt;/h1&gt;
&lt;p&gt;tensorflow has two versions, CPU and GPU; I created two python virtual environments and installed these two versions separately. Below I record this painful installation process&lt;/p&gt;</description></item><item><title>Linux Penetration Testing Commands</title><link>https://simplestory.github.io/en/posts/20180120_3e2c28e497c306d34f88081093e32c89/</link><pubDate>Sat, 20 Jan 2018 00:00:00 +0000</pubDate><guid>https://simplestory.github.io/en/posts/20180120_3e2c28e497c306d34f88081093e32c89/</guid><description>&lt;blockquote&gt;
&lt;p&gt;Below is a penetration testing memo for Linux machines; I came across it on the internet by chance and copied it over here.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;h2 id="penetration-testing-a-linux-machine"&gt;Penetration testing a Linux machine&lt;/h2&gt;
&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th style="text-align:left"&gt;Command&lt;/th&gt;
&lt;th style="text-align:left"&gt;Description&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td style="text-align:left"&gt;netstat -tulpn&lt;/td&gt;
&lt;td style="text-align:left"&gt;Show network ports in Linux together with the corresponding ID (PID)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style="text-align:left"&gt;watch ss -stplu&lt;/td&gt;
&lt;td style="text-align:left"&gt;Observe TCP and UDP ports in real time through sockets&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style="text-align:left"&gt;lsof -i&lt;/td&gt;
&lt;td style="text-align:left"&gt;Show established connections&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style="text-align:left"&gt;macchanger -m MACADDR INTR&lt;/td&gt;
&lt;td style="text-align:left"&gt;Change the MAC address on KALI Linux&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style="text-align:left"&gt;ifconfig eth0 192.168.2.1/24&lt;/td&gt;
&lt;td style="text-align:left"&gt;Set the IP address in Linux&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style="text-align:left"&gt;ifconfig eth0:192.168.2.3/24&lt;/td&gt;
&lt;td style="text-align:left"&gt;Add an IP address to an existing network interface in Linux&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style="text-align:left"&gt;ifconfig eth0 hw ether MAC ADDR&lt;/td&gt;
&lt;td style="text-align:left"&gt;Change the address in Linux using ifconfig&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style="text-align:left"&gt;ifconfig eth0 mtu 1500&lt;/td&gt;
&lt;td style="text-align:left"&gt;Change the MTU size with ifconfig; change 1500 to the MTU you want&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style="text-align:left"&gt;dig -x 192.168.1.1&lt;/td&gt;
&lt;td style="text-align:left"&gt;Perform a reverse lookup on an IP address&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style="text-align:left"&gt;host 192.168.1.1&lt;/td&gt;
&lt;td style="text-align:left"&gt;Perform a reverse lookup on an IP address; useful when dig is not installed&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style="text-align:left"&gt;dig @192.168.2.2 domain.com -t AXFR&lt;/td&gt;
&lt;td style="text-align:left"&gt;Perform a DNS zone transfer with dig&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style="text-align:left"&gt;host -l domain.com nameserver&lt;/td&gt;
&lt;td style="text-align:left"&gt;Perform a DNS zone transfer with host&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style="text-align:left"&gt;nbtstat -A x.x.x.x&lt;/td&gt;
&lt;td style="text-align:left"&gt;Obtain the domain name corresponding to an IP address&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style="text-align:left"&gt;ip addr add 192.168.2.22/24 dev eth0&lt;/td&gt;
&lt;td style="text-align:left"&gt;Add a hidden IP address that does not show up when running ifconfig&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style="text-align:left"&gt;tcpkill -9 host goole.com&lt;/td&gt;
&lt;td style="text-align:left"&gt;Block access to goole.com from the host&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style="text-align:left"&gt;echo &amp;quot;1&amp;quot;&amp;gt;/proc/sys/net/ipv4/ip_forward&lt;/td&gt;
&lt;td style="text-align:left"&gt;Enable IP forwarding, turning the Linux box into a router — which makes it convenient to control the traffic routed through this box&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style="text-align:left"&gt;echo &amp;quot;8.8.8.8&amp;quot;&amp;gt;/etc/resolv.conf&lt;/td&gt;
&lt;td style="text-align:left"&gt;Use Goole's DNS&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;h2 id="system-information-commands"&gt;System information commands&lt;/h2&gt;
&lt;p&gt;Very helpful for local enumeration&lt;/p&gt;</description></item><item><title>MySQL Data File Paths on Linux</title><link>https://simplestory.github.io/en/posts/20171201_7eec743fae4833726b0d923cf6db1da6/</link><pubDate>Fri, 01 Dec 2017 00:00:00 +0000</pubDate><guid>https://simplestory.github.io/en/posts/20171201_7eec743fae4833726b0d923cf6db1da6/</guid><description>&lt;p&gt;&lt;strong&gt;Server version: 5.7.20-0ubuntu0.16.04.1 (Ubuntu)&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;After logging into MySQL, you can use the following command to query where the related files are stored:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-sql" data-lang="sql"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="k"&gt;show&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;variables&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;like&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s1"&gt;&amp;#39;%dir%&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;The output is shown below:&lt;/p&gt;
&lt;p&gt;&lt;img loading="lazy" src="https://simplestory-blog-img.oss-cn-guangzhou.aliyuncs.com/in_posts/20171201/mysql.png" title="mysql"&gt;&lt;/p&gt;
&lt;p&gt;Usually these are:&lt;/p&gt;
&lt;p&gt;The default location of the database files is: &lt;code&gt;/usr/share/mysql/&lt;/code&gt;
Configuration file: &lt;code&gt;/etc/mysql/my.cnf&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;Database directory: &lt;code&gt;/var/lib/mysql&lt;/code&gt;
Configuration directory: &lt;code&gt;/etc/share/mysql&lt;/code&gt; (mysql.server command and configuration files)
MySQL related commands: &lt;code&gt;/usr/bin&lt;/code&gt;
Startup scripts: &lt;code&gt;/etc/init.d/&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;One way to start mysql safely: /usr/bin/mysqld_safe-user=root&amp;amp;&lt;/strong&gt;&lt;/p&gt;</description></item><item><title>Some Linux Commands</title><link>https://simplestory.github.io/en/posts/20171107_619e2d5ba49593e40e16667bafdcf2c1/</link><pubDate>Tue, 07 Nov 2017 00:00:00 +0000</pubDate><guid>https://simplestory.github.io/en/posts/20171107_619e2d5ba49593e40e16667bafdcf2c1/</guid><description>Some little-known Linux commands</description></item><item><title>Installing OpenCV on Linux</title><link>https://simplestory.github.io/en/posts/20171020_df3860e05b3ca04bdc2f774c5c1914fd/</link><pubDate>Fri, 20 Oct 2017 00:00:00 +0000</pubDate><guid>https://simplestory.github.io/en/posts/20171020_df3860e05b3ca04bdc2f774c5c1914fd/</guid><description>&lt;blockquote&gt;
&lt;p&gt;Recently, because a project needed computer vision recognition, I started tinkering with OpenCV. Although the installation process was long and winding, the experience of using it together with Python is actually quite good. Here I record the OpenCV installation and compilation process.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;&lt;strong&gt;System environment: Ubuntu16.04&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Software installed: OpenCV3.3.0+Python2.7.12&lt;/strong&gt;&lt;/p&gt;
&lt;h2 id="updating-the-system-packages"&gt;Updating the system packages:&lt;/h2&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-shell" data-lang="shell"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;$ sudo apt update
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;$ sudo apt upgrade
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h2 id="installing-some-developer-tools"&gt;Installing some developer tools:&lt;/h2&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-shell" data-lang="shell"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;$ sudo apt-get install build-essential cmake pkg-config
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;The pkg-config package is very likely already installed by default, but just in case, add it in as well. The cmake program is used later to compile OpenCV.&lt;/p&gt;</description></item></channel></rss>