Helpful tips and tricks for Linux.
- NetworkManager
- Setup bridge
nmcli connection add type bridge autoconnect yes con-name [bridge name] ifname [bridge interface name]nmcli con add type bridge-slave ifname [ethernet name] master [bridge hame]- Example
nmcli connection add type bridge autoconnect yes con-name bridge ifname bridgenmcli con add type bridge-slave ifname enp34s0u2u1u2 master bridge
- Setup bridge
- gvim doesn't resize:
- edit
~/.bashrc export GVIM_ENABLE_WAYLAND=true
- edit
- Change MAC Address:
macchange -r [interface]. For example:macchange -r wlp3s0 - Display max supported RAM:
dmidecode --type 16 - Check RAM speed:
dmidecode --type 17 - List open ports and proceses that own them:
lsof -inetstat -lptunetstat -tulpn
- Don't use a dnsmasq lease file:
--leasefile-ro - NIS: domainname:
/etc/defaultdomain - Ensure laptop doesn't sleep/hibernate when lid is closed:
systemctl mask suspend.target - When booting headless, ensure console goes blank:
/etc/default/grub:GRUB_CMDLINE_LINUX_DEFAULT="... consoleblank=[seconds to blank]"- Example:
GRUB_CMDLINE_LINUX_DEFAULT="quiet consoleblank=20" - Make sure once edited, you run the following to ensure it "sticks" after next boot:
- Debian:
update-grub - Fedora:
grub2-mkconfig -o /boot/grub2/grub.cfg
- Debian:
- Example:
- ISO
- Mount:
mount -o loop [full path to ISO]/[ISO file name].iso [full path to mount point]. Example:mount -o loop /path/to/disk1.iso /mnt/disk - Write an ISO to a USB stick:
dd if=[ISO file] of=/dev/[usb]. For example:dd if=red_ribbon_lxde_14.03.iso of=/dev/sdb - Create from CD-ROM/DVD:
sudo dd if=/dev/cdrom of=/tmp/cdimg1.iso
- Mount:
- mkv to mp4:
ffmpeg -i [mkv file].mkv -codec copy [new name].mp4 - webm to mp4:
ffmpeg =i [webm file].webm -max_muxing_queue_size 200000 [new name].mp4- _Not sure about the
200000- it's just what I am using
- _Not sure about the
- Disable notification-daemon/notify-send
- Screen
- Move to new position:
ctrl-a [: number X]. Example:ctrl-a :number 3 - Session in a session:
ctrl-a-a - Scroll with Mouse:
~/.screenrc:termcapinfo xterm* ti@:te@
- Move to new position:
- Generate ssh host keys:
/usr/bin/ssh-keygen -A - BASH
- printf:
%s, %b, %d, %x and %f
- printf:
- Alternatives
- editor:
update-alternatives --config editor- Fedora:
export EDITOR=[path to editor]/[editor]Example:export EDITOR=/usr/bin/vim
- Fedora:
- java:
update-alternatives --config java - javac:
update-alternatives --install /usr/bin/javac javac /usr/lib/jvm/open-jdk-11/bin/javac 1
- editor:
- Remove journaling
ext4:tune2fs -O ^has_journal /dev/[drive]. Example:tune2fs -O ^has_journal /dev/sda1 - Emojis
- Install
- Latest Versions
- Manal Installation
wget https://github.com/eosrei/emojione-color-font/releases/download/v1.4/EmojiOneColor-SVGinOT-Linux-1.4.tar.gztar zxf EmojiOneColor-SVGinOT-Linux-1.4.tar.gzcd EmojiOneColor-SVGinOT-Linux-1.4./install.shapt-get install ttf-bitstream-vera
- Find default gateway:
ip route show- Look at the
defaultline. - Example:
default via 24.211.184.1 dev brwan 24.211.184.0/21 dev brwan proto kernel scope link src 24.211.184.21 192.168.168.0/24 dev br0 proto kernel scope link src 192.168.16 - Look at the
Directions can be found here.
dd if=/dev/zero of=[swap file] bs=1MiB count=$(([number of GB]*2014))sudo chmod 600 [swap file]mkswap [swap file]swapon [swap file]
dd if=/dev/zero of=swapfile bs=1MiB count=$((2*2014))sudo chmod 600 /swapfilemkswap /swapfileswapon /swapfile
When run, to have emails sent to an address, add to /etc/crondtab:
MAILTO=[user]@[domain]
For example: MAILTO=sfloess@mail
The basic structure can also be added to any individual user's crontab entries in the user's crontab file.
.bashrc:
__compute_git_info() {
local GIT_INFO="`git remote 2> /dev/null | tr -s '\n' '/' | rev | cut -c2- | rev` `git branch 2> /dev/null | grep -e '\* ' | sed 's/^..\(.*\)/\1/'`"
if [ "${GIT_INFO}" != "/" ]
then
echo " ${GIT_INFO}"
fi
}
__prompt_command() {
local GIT_INFO=`__compute_git_info`
PS1="[${GIT_INFO}] \`pwd\`> "
}
export PROMPT_COMMAND=__prompt_commandAdjusts power settings (here is a link for installing). For max performance, here are a few notable settings:
TLP_ENABLE=1
TLP_DEFAULT_MODE=AC
DISK_IDLE_SECS_ON_AC=0
CPU_SCALING_GOVERNOR_ON_AC=performance
CPU_HWP_ON_AC=performance
CPU_MIN_PERF_ON_AC=100
CPU_MAX_PERF_ON_AC=100
CPU_BOOST_ON_AC=1
SCHED_POWERSAVE_ON_AC=0
ENERGY_PERF_POLICY_ON_AC=performance
SATA_LINKPWR_ON_AC="max_performance max_performance"
Additionally, there are two settings for CPU scaling that'll be dependent upon your CPU: CPU_SCALING_MIN_FREQ_ON_AC and CPU_SCALING_MAX_FREQ_ON_AC
To list your CPU settings invoke the following: tlp-stat -p
As an example, one of my servers lists the aforementioned as: /sys/devices/system/cpu/cpu1/cpufreq/scaling_available_frequencies = 3000000 2667000 2333000 2000000 [kHz]
For this machine, I have these settings:
CPU_SCALING_MIN_FREQ_ON_AC=3000000
CPU_SCALING_MAX_FREQ_ON_AC=3000000
nexus.service
[Unit]
Description=Nexus Service
After=network.target
[Service]
Type=forking
WorkingDirectory=/opt/nexus/bin
ExecStart=/opt/nexus/bin/nexus start
ExecStop=/opt/nexus/bin/nexus stop
Restart=on-abort
TimeoutStartSec=600
TimeoutStopSec=600
RestartSec=600
[Install]
WantedBy=multi-user.target
activemq.service
[Unit]
Description=ActiveMQ Service
After=network.target
[Service]
Type=forking
PIDFile=/opt/apache-activemq/data/activemq.pid
WorkingDirectory=/opt/apache-activemq/bin
ExecStart=/opt/apache-activemq/bin/activemq start
ExecStop=/opt/apache-activemq/bin/activemq stop
Restart=on-abort
TimeoutStartSec=600
TimeoutStopSec=600
RestartSec=600
[Install]
WantedBy=multi-user.target