How to find out what is running on a port on a remote machine
By convention, common protocols use a defined port, like 80 for HTTP or 443 for HTTPS.
You can use nmap
to find out what service is running behind a given port, and most often see some details about it. This can be helpful if servers don't offer the services you expect for some ports. If you'd like to see what ports are listing on your local machine, you might want to use netstat
instead of nmap
.
Note that nmap's service discovery may trigger several requests.
Example
When using nmap, adding the -A
switch ...
Google Chrome: How to find out your currently installed theme
So you downloaded a theme for Chrome a while ago and don't remember which one it is?
You can go to chrome://settings/appearance
(on Chrome 61+) to see the theme's name, and click a link to open it in the Chrome Web Store.
If you are on an older version, or if the above no longer works, you have to check Chrome's Preferences
file.
Linux
/home/YOUR_USER_NAME/.config/chromium/Default/Preferences
OSX
/Users/YOUR_USER_NAME/Library/Application Support/Google/Chrome/Default/Preferences
Windows
C:\Users\YOUR_US...
Icon font vertical alignment in Windows
I had an issue with icons from an icon font aligning differently on Linux, iOS and Windows (seemingly browser-independent). With vertical-align:middle
, they aligned properly on Linux, iOS and macOS, whereas with a vertical-align
of -18%
, it looked good on Windows and iOS, but not Linux.
Further investigation showed that not only icons, but also normal capital letters aligned differently. No setting of vertical-align
could fix this, neither top
, bottom
, middle
, nor additional paddings or margins. It seems like browsers take the...
Linux: Find out which processes are swapped out
Processes in Linux might be put into Swap ("virtual memory") occasionally.
Even parts of a single process might be removed from memory and put into Swap.
In order to find out which processes remain within Swap, run this:
sudo grep VmSwap /proc/*/status | egrep -v "0 kB"
Keep in mind Swap is not evil by definition. Some bytes per process beeing put to Swap will not have that much of performance influence.
If you want the Linux virtual memory manager (which is responsible for the decision if and which processes are moved to Swap) to be...
How to fix: RubyMine / IntelliJ "find file" dialog losing focus on awesome wm
Many of our developers love to use the "awesome" window manager on Linux. However, RubyMine dialogs occasionally defocus while typing.
Here is a fix for that, tested on awesome 3.4, 3.5 and 4.0 (Ubuntu 14.04 and 16.04).
Problem
Consider the following:
- Press
Ctrl
+Shift
+N
- "Find file" dialog opens
- Type to search, file list appears
- Type more, file list is being replaced
If your mouse pointer hovers the file list, the main window is focused when the list is being replaced (or simply when it shrinks and your mouse pointe...
Linux: How To Fix Failed to fetch http://dl.google.com/linux/chrome/deb/dists/stable/Release : chrome
Chrome has discontinued support for 32-Bit Linux builds and this might break your apt-get update
.
To fix this, you need to update your APT source. This command does that automagically for you:
sudo sed -i -e 's/deb http/deb [arch=amd64] http/' "/etc/apt/sources.list.d/google-chrome.list"
Note that if you are using a 32-bit Linux, you will no longer receive Chrome security updates and should switch to a different browser (maybe Chromium).
Linux: Open a file with the default application
If you are on a Linux shell and want to open a file with whatever default application is configured for that type, this often works:
xdg-open Quote.odt
xdg-open invoice.pdf
xdg-open index.html
Pro Tip
Make an alias so you have a simpler API (like Mac OS): alias open=xdg-open
or alias x=xdg-open
.
Background
You can choose your "Default applications" via UI in the Ubuntu "Settings" application (gnome-control-center
). This is just a very rough setting (e.g. open Photos with Shotwell Viewer).
If a certain file...
netstat: Sum open connections by IP (and sort it)
The following sums up all connections (ESTABLISHED, TIME_WAIT, FIN_WAIT, etc.) and sorts it:
netstat -n | awk ' $5 ~ /^[0-9]/ {print $5}' | cut -d: -f1 | sort | uniq -c | sort -n
Works on FreeBSD and Linux.
Linux Performance Analysis in 60,000 Milliseconds
You login to a Linux server with a performance issue: what do you check in the first minute?
uptime
dmesg | tail
vmstat 1
mpstat -P ALL 1
pidstat 1
iostat -xz 1
free -m
sar -n DEV 1
sar -n TCP,ETCP 1
top
Also see:
Make Nokogiri use system libxml2
The nokogiri gem provides different packages for several platforms. Each platform-specific variant ships pre-built binaries of libxml2
, e.g. x86_64-linux
includes binaries for 64bit Linux on Intel/AMD. This significantly speeds up installation of the gem, as Nokogiri no longer needs to compile libxml2
.
However, this also means that for each security issue with libxml2
, Nokogiri maintainers have to update their pre-built binaries and release a new version of the gem. Then, you need to update and ...
Sending TCP keepalives in Ruby
When you make a simple TCP connection to a remote server (like telnet
), your client won't normally notice when the connection is unexpectly severed on the remote side. E.g. if someone would disconnect a network cable from the server you're connected to, no client would notice. It would simply look like nothing is being sent.
You can detect remote connection loss by configuring your client socket to send TCP keepalive signals after some period of inactivity. If those signals are not acknowledged by the other side, your client will terminat...
Terminal escape sequences – the new XSS for Linux sysadmins
Article shows how to make a script that fakes one kind of content when printed with cat
, but uses different code when executed:
$ printf '#!/bin/bash\necho doing something evil!\nexit\n\033[2Aecho doing something very nice!\n' > backdoor.sh
$ chmod +x backdoor.sh
$ cat backdoor.sh
#!/bin/bash
echo doing something very nice!
$ ./backdoor.sh
doing something evil!
Detect recently added vdisks in a VMware ESXi linux guest
After adding a vdisk to an ESXi linux guest you will assert that you can't find a new device in the running VM. You have to force a SCSI rescan.
- find your host bus number with:
grep mtpspi /sys/class/scsi_host/host?/proc_name
- output should look like this: /sys/class/scsi_host/host2/proc_name:mptspi where the bold part is what you're searching for
- force an SCSI rescan with
echo "- - -" > /sys/class/scsi_host/<host>/scan
and insert the host found in point two for<host>
-
cat /proc/scsi/scsi
should now show the new ad...
Browse Amazon S3 buckets with Ubuntu Linux
There are some frontends available, but they all suck, are no longer maintained or are hard to install.
As a surprisingly comfortable alternative I have found a command line tool s3cmd
:
sudo apt-get install s3cmd
When you run s3cmd
the first time it will ask you for your access key ID and secret access key. This information is cached somewhere so you only need to write them once. To reconfigure later, call s3cmd --configure
.
Once you're done setting up, s3cmd
gives you shell-like commands like s3cmd ls
or `s3cmd del som...
Linux: Kill a process matching a partial name
This is useful to kill processes like ruby my-script.rb
:
pkill -f my-script.rb
With great power comes great responsibility.
Ubtuntu: "FATAL: Could not load /lib/modules/...-generic/modules.dep: No such file or directory"
If you get this error (probably because you want to load some modules):
# modprobe xt_comment
FATAL: Could not load /lib/modules/3.2.0-40-generic/modules.dep: No such file or directory
The reason could be that apt-get autoremove
already removed /lib/modules/.../modules.dep
even if you still using this kernel version:
# uname -r
3.2.0-40-generic
# ls -l /lib/modules/
total 24
drwxr-xr-x 4 root root 4096 Oct 22 17:05 3.2.0-68-generic
drwxr-xr-x 4 root root 4096 Jan 7 16:38 3.2.0-69-generic
drwxr-...
Traveling Ruby: self-contained, portable Ruby binaries
Traveling Ruby is a project which supplies self-contained, "portable" Ruby binaries: Ruby binaries that can run on any Linux distribution and any OS X machine. This allows Ruby app developers to bundle these binaries with their Ruby app, so that they can distribute a single package to end users, without needing end users to first install Ruby or gems.
Installing Adobe Reader on Ubuntu
Adobe no longer supports their PDF reader on Linux and the official page does not offer it for download. \
However, some files may not display properly on Ubuntu's default PDF reader Evince or PDF forms may not work as expected. Hence, you may still need to use it.
Here is how to install the Adobe Reader (acroread
) if you need to:
-
Download the
.deb
archive from the Adobe servers (yes, it's still there):cd /tmp && wget http://ardownload.adobe.com/pub/adobe/reader/unix/9.x/9.5.5/enu/AdbeRdr9.5.5-1_i386linux_enu.deb
-
I...
Install or update Chromedriver on Linux
Option 0: Download from the official page (preferred)
- Open https://googlechromelabs.github.io/chrome-for-testing/
- In Section "Stable" > chromedriver / linux64 > Download ZIP from URL
- Take the
chromedriver
binary from the ZIP file and put it e.g. into~/bin
.
Chromedriver must be available in your path. You can add ~/bin
to your path like this:
echo "export PATH=$PATH:$HOME/bin" >> $HOME/.bash_profile
If you're also using Geordi, disable automatic updating of chromedriver in ~/.config/geordi/global.yml
:
a...
Fixing tlmgr cannot setup TLPDB
tlmgr
is the TeX Live Manager and responsible for the TeX installation on your (Linux) machine.
If you're getting the message:
(running on Debian, switching to user mode!)
cannot setup TLPDB in /home/dominik/texmf at /usr/bin/tlmgr line 5336.
... tlmgr
has not been initialized. Run this to initialize it:
tlmgr init-usertree
Then, you may set e.g. a global paper size standard: tlmgr paper a4
.
Linux: Running a program with a different locale than your default
When your system is not running on English, you may sometimes want to run some applications and not use your system locale.
Use cases are scripts that parse output, or just using the (possibly) more common English labels or error messages. Here is how to do that.
I will use the date
command and print the current weekday, just for the sake of an example.
Changing the locale using environment variables
Most often, setting LC_ALL
for your command should be enough. The following was run on a system using a German locale.
$ date +%...
Skype 4.3 for Linux fixes group chats
Skype has been updated to 4.3 on Linux. This fixes group chat issues with non-linux clients.
If you have previously installed skype via ubuntu packages, you need to remove those fist via
sudo apt-get remove skype skype-bin
Note
Try to install the 32 bit version. In serveral cases this was the way that worked out.
Grab the installer here: