Home » Linux » Tips

How to Change the Hostname in Linux (Debian, Ubuntu, Arch, RedHat)

Linux Change Hostname

This article will show you how to change the hostname for your Linux device (Debian, Arch, Ubuntu, or RedHat). The methods below should work for the vast majority of current and obsolete Linux Distributions. What is the Hostname? The hostname of a device on the network is the human-readable label of the system. It can be used to identify or connect to a system on the network instead of connecting to it via an IP address. Displaying the Current Hostname Regardless of your distribution, you can find out … Read more

Home » Linux » Tips

FAQ: How to disable/remap a keyboard key in Linux?

disable remap a keyboard key in Linux

Q: How can I disable one or several keys on my laptop keyboard in Linux? When I press the DELETE key, it gets stuck and deletes everything 🙂

A: No problem! You can use the following command to remap or disable any key of your keyboard:

xmodmap -e 'keycode <value>=<action>'

For example, you could run the following command to disable your DELETE key:

xmodmap -e 'keycode 107='

How to get the correct keycode

You can get the keycode that corresponds to a specific keyboard button in one of two ways.

The first method is by using the simple command xev. xev opens a window and then monitors “events” such as keystrokes. It is suitable when you are running a GUI.

xev

The second method, which can be run with only the console, is showkey. This command will monitor for keystrokes for 10 seconds, or until a SIGTERM signal is received.

List of all keycodes

The full list of available keycodes and actions assigned to them on UK keyboard is below…

Read more

Home » Linux » Tips

Grub Fallback: Boot good kernel if new one crashes

grub featured

It’s hard to believe but I didn’t know about Grub fallback feature. So every time when I needed to reboot remote server into a new kernel I had to test it on local server to make sure it won’t panic on remote unit. And if kernel panic still happened I had to ask somebody who has physical access to the server to reboot the hardware choose proper kernel in Grub. It’s all boring and not healthful – it’s much better to use Grub’s native fallback feature. … Read more

Home » Linux » Tips

Track Cisco BGP peers using Nagios

Nagios (featured logo)

Few will deny that monitoring of Cisco devices is essential part of sysadmin’s job. I personally use Nagios to track states of BGP neighbors on Cisco routers so if one of peers goes down I’ll receive a phone call from Nagios. You may have redundant network topology but it still makes sense to know when peer goes offline, how often it happens and how fast failover router (if any) pick-ups the traffic from failed peer. There are a few plugins for Nagios to monitoring BGP … Read more

Home » Linux » Tips

Top Open Source IP Address Management Software

ipplan feat

In this post you will find top open source software for IP address management (IPAM). If you are sysadmin at organization that holds pool of IP addresses and allocates its parts to clients then you must use IP address management tools to track used, reserved, allocated or free IP addresses. It usually prevents an overhead and allows to have clear picture of IP addresses resources usage within an organization on the whole. For example, it may be useful to know how many free IP networks are … Read more

Home » Linux » Tips

Wget Cookies: Download Protected Content

command line

Most of Linux users are using wget from time to time, sometimes even when they don’t know about it – many GUI download managers for Linux are based on wget. Anyways wget is command line tool for downloading files over HTTP, HTTPs and FTP protocols within single session. It works like a charm with default settings for downloading simple static files, at the same time if content is protected by cookies and/or referrer then wget may seem useless but it’s actually not. For example, imagine … Read more

Home » Linux » Tips

Fastest way to create ramdisk in Ubuntu/Linux

Ubuntu (featured logo)

I hope many of you will agree that sometimes it’s really good idea to have some small amount of RAM mounted as a filesystem. It may be necessary when running some bash or perl script that handles, say, thousands of small files so it’s much more effective not to waste computer resources on reading/writing data on hard disk but keep those files directly in memory. This idea is known as Virtual RAM Drive or ramdisk and can be setup in Ubuntu or almost any other … Read more

Home » Linux » Tips

13 Linux lethal commands

[digg-me]In this post I will collect all commands which SHOULD NEVER be executed in Linux. Any of them will cause data loss or corruption, can freeze or hang up running system. NEVER RUN THESE COMMANDS IN LINUX BOX CLI! Even if somebody advises you in forum/im to do it. 1. Any of these commands will erase everything from your home directory, root or just will clear up whole disk: sudo rm -rf / rm -rf .* dd if=/dev/zero of=/dev/sda mkfs.ext3 /dev/hda whatever > /dev/hda cd … Read more

Home » Linux » Tips

Tiny bash scripts: check Internet connection availability

Sometimes it is necessary to check whether server you want to run some big bash script is connected to Internet. Usually it makes sense while running scripts periodically using cron.  Below is the tiny bash script for this purpose: #!/bin/bash WGET=”/usr/bin/wget” $WGET -q –tries=10 –timeout=5 http://www.google.com -O /tmp/index.google &> /dev/null if [ ! -s /tmp/index.google ];then echo “no” else echo “yes” fi As you see it tries to download google’s index page, if it’s not empty script returns “yes”, if there is not Internet connection … Read more

Home » Linux » Tips

Mount remote filesystem via ssh protocol using sshfs and fuse [Fedora/RedHat/Debian/Ubuntu way]

Imagine the following situation: you have to compile some Linux/Unix application or kernel module that requires kernel source present at your hard drive, say, in /usr/src/kernels/kernel-2.6.21-i386/ or elsewhere. But there is not enough disk space to copy these sources or install kernel-devel or linux-source packages (in Fedora/RedHat or Ubuntu/Debian distros respectively)… Sounds familiar? Believe me, sometimes it happens 🙂 As a solution you can mount the directory of some remote PC that contains needed kernel source. It can be done via several protocols like smb, … Read more