Welcome to the mine useful documentation for daily work on web developer and computer programming. Thanks to PrettyDocs for theme template layout; download it at the page linked in the button below.
Download PrettyDocsPrismJS is used as the syntax highlighter here. You can build your own version via their website should you need to.
In the script you put in /etc/init.d you have to set it executable and create a symlink to /etc/rc.d/:
chmod +x /etc/init.d/my-script.sh
ln -s /etc/init.d/my-script.sh /etc/rc.d/
Please note that this wil not work as the script have to be LSB compliant (provide, at least, the following actions: start, stop restart, force-reload and status).
File: /etc/systemd/system/my-startup.service
[Unit]
Description=My Startup
[Service]
ExecStart=/usr/local/sbin/my-script.sh
[Install]
WantedBy=multiuser.target
linuxspot@linuxspot:~$ sudo nano /etc/systemd/system/my-startup.service
linuxspot@linuxspot:~$ systemctl status my-startup.service
○ my-startup.service - My Startup
Loaded: loaded (/etc/systemd/system/my-startup.service; disabled; vendor preset: enabled)
Active: inactive (dead)
Feb 06 19:35:08 linuxspot systemd[1]: Started My Startup.
linuxspot@linuxspot:~$ sudo systemctl enable my-startup.service
Created symlink /etc/systemd/system/multi-user.target.wants/my-startup.service ⇨ /etc/systemd/system/my-startup.service
dig +short myip.opendns.com @resolver1.opendns.com
Or:
dig TXT +short o-o.myaddr.l.google.com @ns1.google.com
Please note that I do not recommend following curl/wget method due to security reasons. You have been warned.
curl checkip.amazonaws.com
Or:
curl ifconfig.me
Here’s the replacement for editing /etc/networking/* in the old system. The whole system now uses YAML configuration files under /etc/netplan, and then the netplan command applies those configurations to the system.
vi /etc/netplan/*.yaml
network:
version: 2
ethernets:
eth0:
dhcp4: true
optional: true
# addresses: [192.168.1.101/24]
# gateway4: 192.168.1.1
# nameservers:
# addresses: [8.8.8.8, 1.1.1.1]
wifis:
wlan0:
dhcp4: false
dhcp6: false
addresses: [192.168.1.101/24]
gateway4: 192.168.1.1
nameservers:
addresses: [8.8.8.8, 1.1.1.1]
access-points:
"This is Access Point SSID":
password: "secret"
netplan apply
So now (whether you’re running an older system or a new one) you should now have a static IP address!
Assign Static IP Address to eth0 interface editing configuration file /etc/network/interfaces to make permanent changes as shown below:
auto eth0
iface eth0 inet static
address 192.168.1.101
netmask 255.255.255.0
gateway 192.168.1.1
Next, restart network services after entering all the details using the following command:
systemctl restart NetworkManager.service
# Or
/etc/init.d/networking restart
Open /etc/dhcpcd.conf with your favorite text editor. scroll down until you see the following commented out lines of code:
# Example static IP configuration:
#interface eth0
#static ip_address=192.168.11.13
#static routers=192.168.11.1
#static domain_name_servers=8.8.8.8
Uncomment the lines above or copy the following snippet and put it right under the code shown above:
interface wlan0
static ip_address=192.168.11.13
static routers=192.168.11.1
static domain_name_servers=8.8.8.8
You will need to set up the static ip_address and static routers tag to fit your network setup. Don’t forget to save the file.
Configuring POSTFIX on Linux and Gmail SMTP for sending mail from command line.
sudo apt update
sudo apt upgrade
sudo apt install postfix mailutils libsasl2-2 libsasl2-modules
smtp_use_tls = yes
smtp_sasl_auth_enable = yes
smtp_sasl_password_maps = hash:/etc/postfix/sasl/sasl_password
smtp_sasl_security_options = noanonymous
smtp_sasl_tls_security_options = noanonymous
Now we will have to create the file where to put the Gmail SMTP access password. We create the /etc/postfix/sasl/sasl_password file inside which we will put a single row:
smtp.google.com username:password
We create the lookup table db from postfix itself:
postmap /etc/postfix/sasl/sasl_password
chown -R root:postfix /etc/postfix/sasl
chmod 750 /etc/postfix/sasl
chmod 640 /etc/postfix/sasl/sasl_password*
sudo service postfix restart
echo "send test mail from command line" | mail "sending test" recipient@example.com
Any problems can be analyzed in /var/log/mail.log and /var/log/mail.err.
Web site full download with WGET command.
wget --recursive --no-clobber --page-requisites --html-extension --convert-links --restrict-filenames=windows --domains mysite.com --no-parent www.mysite.com