Linux Tips
Quick Web Server
In Terminal:
python3 -m http.server 7050
…where “7050” is an arbitrary port number.
Networking Pointers
Releasing - Renewing Your IP Address
Often when you’re having Wi-Fi issues, this is because there are issues with your IP address, the set of numbers that identifies your location online. The reasons for this can be any of dozens, but thankfully the fix is always the same, namely resetting your IP address.
To do so, you first need to know your current IP address. You can do so using the following command:
ip address
Alternatively, some Linux distros will allow you to do this within the desktop environment, check out our article on how to find your IP address in Ubuntu.
Though it’s not necessary, you may want to take note of this IP address as after we’re done we need to check that it’s been changed.
Next, we need to request a new IP address through your DHCP server. We have a full explainer on what DHCP is, but the short version is that it’s a protocol that handles IP assignments. It usually does this on a daily basis, so your network gets a new IP every 24 hours. What we’re going to do is ask if we can renew it now.
To do so you need a program called dhclient, which is installed by default on Linux systems. Run it to find out what your system is running now, using the “verbose” command (-v) to make sure you get some output:
sudo dhclient -v
This lets you know what IP was requested (DHCPREQUEST) and when it will expire, in my case 40157 seconds from now, which is about 11 hours.
Now, we need to release the IP address, which means we ask dhclient to trash it. This is done with the -r command, and I recommend you add another “verbose” command to see what’s happening:
sudo dhclient -v -r
With that done, now request a new IP address, with the same command as before:
sudo dhclient
Enjoy your new IP address.
Resetting Network Settings
Sometimes renewing the IP address isn’t enough, though. The next thing you can try is to reset your network interface entirely in the hope that whatever setting is causing the issue is returned to its default state.
To do so, we’re going to use a program called ip. This is a very powerful tool that lets you control networking on your device. We have a full guide on using the ip command, though for now we only need three commands.
The first is to show the interfaces present on your device. For that, type this:
ip link show
You’ll get a list of interfaces. For most people it’s the second one (enp0s3 in my case), so let’s try resetting that first. To do so, you need to switch the interface off:
sudo ip link set <interface_name> down
That turns it off, you can check with the “link show” command from earlier. Now you can turn the interface back on again:
sudo ip link set <interface_name> up
Grub-Customising
Updated: 2024-01-21
Dual-boot systems use GRUB to allow booting to one OS or another. Grub-customizer by Daniel Richter is quite nice but somehow doesn’t work for me.
So, to get GRUB2 to look decent, we need to first address /etc/default/grub - I’ve removed all the commented-out stuff so just the really important stuff remains:
GRUB_DEFAULT=0 GRUB_TIMEOUT_STYLE=hidden GRUB_TIMEOUT=15 GRUB_DISTRIBUTOR=`lsb_release -i -s 2> /dev/null || echo Debian` GRUB_CMDLINE_LINUX_DEFAULT=”quiet splash” GRUB_CMDLINE_LINUX=””
GRUB_GFXMODE=1920x1080 GRUB_FONT=/boot/grub/fonts/unifont.pf2
Key points to look at are the resolution - in this case 1920x1080 - and font, which lives in /boot/grub/fonts. So:
change the resolution to read: GRUB_GFXMODE=1920x1080
add the line: GRUB_FONT=/boot/grub/fonts/unifont.pf2
…ensuring, of course, that the file and path actually exist.
The next thing to look at is look in the /etc/default/grub.d folder, which will hopefully contain the following files, or something similar:
50_linuxmint.cfg
63_mint-theme-2k.cfg
In this case, the 63x file held the key to which theme is used by GRUB. If none of that sort of file exist, you might need to go to the Software Manager and load an alternate theme to the default, such as Grub2-theme-mint. Invoke:
sudo update-grub
and the missing files should appear. In that file (or one similar to it) are a two lines of interest:
GRUB_FONT=”/boot/grub/fonts/UbuntuMono32.pf2” GRUB_THEME=”/boot/grub/themes/creek/theme.txt”
The second line will tell update-grub where to find the theme. Save your changes and nvoke:
sudo update-grub
and you should be good.
WHV5M3XPNX
Updating PATH
In Ubuntu, edit /etc/environment. Its sole purpose is to store Environment Variables. Originally the $PATH variable is defined here. This is a paste from my /etc/environment file:
PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games"
So you can just open up this file as root and add whatever you want.
For Immediate results, Run (try as normal user and root):
source /etc/environment && export PATH
Kivy and PyCharm
Kivy Virtual Environment Installation using PyCharm
Assumption
Assuming virtualenv or/and virtualenvwrapper already installed:
sudo pip install virtualenv virtualenvwrapper
Launch PyCharm. Then:
Click File
Click Settings
Click project Interpreter
Click cogwheel next to the Project Interpreter field, and choose Add…
New environment is the default selection.
Type kivyinstall for the Location e.g. /home/iam/.virtualenvs/kivyinstall
Select Base interpreter (Python 3.5, or Python 2.7) from the drop down
Do not select the Inherit global site-packages check-box.
Select the Make available to all projects check-box, if needed.
Click OK
After pip and setuptools have been installed:
click + beside the column heading, Latest.
Type cython in the search text input box under Available Packages Dialog.
Select Specify version check-box to load version 0.25.2 which is compatible to Kivy version 1.10.0
Click Install Package button.
After cython 0.25.2 version installed successfully, type kivy in the search text input box under Available Packages Dialog.
Click Install Package
After kivy installed successfully, create a new project. Opened a new project. If kivyinstall did not appear in the expanded External Libraries:
click File » Settings… » Project Interpreter
select Python…(kivyinstall) e.g. Python 3.5 (kivyinstall)
Brackets in Mint (Ubuntu)
Since PyCharm and Kivy currently (18.12.27) has issues, going to have a go with Brackets, which works a treat on the Mac. The following installation pointers came from It’s FOSS.
Method 1: Install Brackets using Snap
To install Snap, enter the following in Terminal:
sudo apt-get install snapd
Starting Ubuntu 16.04, Brackets is available as a Snap app. You can also find it in the Software Center and install it from there in a few clicks for Ubuntu 16.04 and higher versions.
If you want to install via the command line, you can use the Snap commands to install Brackets. This will work for all the Linux distributions that support Snap packaging. First, make sure you have snapd daemon installed on your system. Use the command below:
snap --version
Once you have made sure that snapd is installed on your Linux system, install Brackets with:
sudo snap install brackets
In mint, an error occurred with the above command:
This revision of snap “brackets” was published using classic confinement and thus may perform arbitrary system changes outside of the security sandbox that snaps are usually confined to, which may put your system at risk
This can be rectified by adding –classic:
sudo snap install brackets --classic
Method 2: Install Brackets using PPA
… in Ubuntu and Linux Mint (Not recommended)
Note: This method is redundant now. When Brackets was not officially available, the unofficial PPA provided an easy way to install Brackets on Ubuntu.
Open a terminal and use the following commands to install Brackets via the unofficial PPA:
sudo add-apt-repository ppa:webupd8team/brackets
sudo apt-get update
sudo apt-get install brackets
Method 3: Install Brackets using DEB package
… or source code
If you do not like PPAs, you can get the .deb installation files from the link below. You will also get the source code of the latest version here:
These .deb binaries can be installed by double-clicking on it. It will be opened in Ubuntu Software Center by default. You can use a lighter alternative Gdebi as well.