linux on davidchua https://dchua.com/tags/linux/ Recent content in linux on davidchua Hugo -- gohugo.io en-us Fri, 08 Sep 2023 02:43:00 +0000 Diagnosing too many open files https://dchua.com/posts/2023-09-08-diagnosing-too-many-open-files/ Fri, 08 Sep 2023 02:43:00 +0000 https://dchua.com/posts/2023-09-08-diagnosing-too-many-open-files/ When facing a “Too Many Open Files” error, it is normally a result of a process taking up too many file descriptors. To diagnose this, find out the PID of the process which gave out the error. You can do this with a: $ ps auwx | grep <name_of_process> Verify open file limit per process 📝 Note: Each process that runs have a number of open files limit. By default, most of the time the limit is 1024 Forwarding Vault audit logs to a remote Syslog server (like Graylog) https://dchua.com/posts/2017-03-06-forwarding-vault-audit-logs-to-a-remote-syslog-server/ Mon, 06 Mar 2017 00:00:00 +0000 https://dchua.com/posts/2017-03-06-forwarding-vault-audit-logs-to-a-remote-syslog-server/ Using Vault’s Audit Backend to send logs to a remote Syslog server. Objective Send audit_logs from Hashicorp’s Vault to an Graylog instance Prerequisite Setup a Syslog TCP/UDP Input on Graylog (if you’re using graylog) Has a remote syslog server running Steps Important Notice: Vault has a Syslog Audit Backend as part of its suite but it currently does not allow remote forwarding. In order to do that we will have to make use of rsyslog’s rules forwarding. Deleting files and getting your diskspace back without rebooting https://dchua.com/posts/2017-02-03-deleting-files-and-getting-your-diskspace-back-without-rebooting/ Fri, 03 Feb 2017 00:00:00 +0000 https://dchua.com/posts/2017-02-03-deleting-files-and-getting-your-diskspace-back-without-rebooting/ When you run out of diskspaces and need to delete files quickly to recover them, most of the time, your deleted files will not free up the diskspace until the process that is using it is restarted or deleted. To force the filesystem to free up the lock to the file so that the files can be cleared up, you’d need to find the process that is using the file and truncate it. Monitor a Directory for File Changes with inotifywait https://dchua.com/posts/2016-12-27-monitor-a-directory-for-file-changes-with-inotifywait/ Tue, 27 Dec 2016 00:00:00 +0000 https://dchua.com/posts/2016-12-27-monitor-a-directory-for-file-changes-with-inotifywait/ Sometimes there may be a need to monitor and be alerted when any new files have been added in a particular directory. One of the quickest way to do that is to use inotifywait. You can find it in the inotify-tools package. If you don’t have it yet, you can install it with apt-get install inotify-tools if you’re on Debian/Ubuntu. Create a nice looking bash script. Maybe something called watcher.sh, copy the following script and fire away! Find out which processes is using your swap https://dchua.com/posts/2015-05-27-find-out-which-processes-is-using-your-swap/ Wed, 27 May 2015 00:00:00 +0000 https://dchua.com/posts/2015-05-27-find-out-which-processes-is-using-your-swap/ To find out which process is using your swap memory, use smem $ sudo apt-get install smem # To get a full list of PID and the amount of memory and swap they use $ smem -s swap # To get a summary of memory usage by user $ smem -u References: Find out what is using your swap SMEM memory reporting tool Fix freezing mouse-click issue on Spotify Linux https://dchua.com/posts/2015-05-05-fix-freezing-mouse-click-issue-on-spotify-linux/ Tue, 05 May 2015 00:00:00 +0000 https://dchua.com/posts/2015-05-05-fix-freezing-mouse-click-issue-on-spotify-linux/ If you’re running Linuxmint/Ubuntu and you’re experiencing strange issues with your mouse click being disabled across the entire desktop after running spotify, you might experiencing this issue To fix this, go to your file: # ~/.config/spotify/Users/<username>/prefs # add the following ui.track_notifications_enabled=false Figure out which DNS server you are using https://dchua.com/posts/2014-09-17-figure-out-which-dns-server-you-are-using/ Wed, 17 Sep 2014 00:00:00 +0000 https://dchua.com/posts/2014-09-17-figure-out-which-dns-server-you-are-using/ If you need to find out what DNS you are currently using (for troubleshooting purposes, this snippet might help): $ tcpdump udp and src port 53 $ tcpdump udp and dst port 53 $ tcpdump -n -s 1500 -i eth0 udp port 53 These 3 commands will sniff your packets for port 53 interactions and will let you know what is the ip address of the DNS server that you’re interacting with. Link your custom app to your Gnome Applications https://dchua.com/posts/2014-09-12-link-your-custom-app-to-your-gnome-applications/ Fri, 12 Sep 2014 00:00:00 +0000 https://dchua.com/posts/2014-09-12-link-your-custom-app-to-your-gnome-applications/ If you’re running GNOME and you have a custom script/app that you want to be able to run quickly from your applications bar, you can easily add an entry with the following: In your ~/.local/share/applications or /usr/share/applications folder (choose one depending on whether you want to share with all your users or yourself), add the following entry: # whateverfile.desktop [Desktop Entry] Type=Application Encoding=UTF-8 Name=Sample Application Name Comment=A sample application Exec=application Icon=application. Things to do with a new Ubuntu Installation https://dchua.com/posts/2014-07-21-things-to-do-with-a-new-ubuntu-installation/ Mon, 21 Jul 2014 00:00:00 +0000 https://dchua.com/posts/2014-07-21-things-to-do-with-a-new-ubuntu-installation/ This post will be constantly updating for new information Step 1: Setup Swap space sudo /bin/dd if=/dev/zero of=/var/swap.1 bs=1M count=2048 # count is in MB sudo /sbin/mkswap /var/swap.1 sudo /sbin/swapon /var/swap.1 Setup 2:Setup IPv4 Precedence To ensure that your apt-gets are not slowed down due to your system grabbing repository files over IPv6 # in /etc/gai.conf # uncomment this line prescedence ::ffff:0:0/96 100 X11 forwarding over remote SSH tmux https://dchua.com/posts/2014-07-15-x11-forwarding-over-remote-ssh-tmux/ Tue, 15 Jul 2014 00:00:00 +0000 https://dchua.com/posts/2014-07-15-x11-forwarding-over-remote-ssh-tmux/ I’m starting to do all my development remotely on a development server that I’m hosting at home over a VPN. This means that all my devices are basically thin-clients. Pre-requisite Make sure that you’ve already allowed X11 forwarding over your remote user account. If not, do this (in your remote server logged in as your remote user account) # in ~/.ssh/config (create if its not there) # add the following ForwardX11 yes One of the problems I had encountered was attempting to do X11 forwarding over TMUX. Wifi Configuration - Ncurses style https://dchua.com/posts/2013-12-30-wifi-configuration-ncurses-style/ Mon, 30 Dec 2013 00:00:00 +0000 https://dchua.com/posts/2013-12-30-wifi-configuration-ncurses-style/ So I’ve been having this irritating problem of configuring wifi on my small mini-computers in command-line. Getting a little bit frustrated with the tedious work of configuring the wpa-supplement and /etc/network/interfaces just to get my system configured with my home network, I found this nifty little tool called wicd. WICD is a network manager that comes in many flavors mostly in GUI ontop of a X Window. Running a headless Raspberry Pi, I don’t want to boot up and X11 forward a display just to configure it. Mongodb caveats; you need swap space https://dchua.com/posts/2013-12-10-mongodb-caveats-you-need-swap-space/ Tue, 10 Dec 2013 00:00:00 +0000 https://dchua.com/posts/2013-12-10-mongodb-caveats-you-need-swap-space/ So I was helping out a friend figure out why his server keeps crashing and timing out. Having moved his mongodb query code out into its own controller and setup an onload AJAX call, I subsequently started to look deep into the mongodb logs. I noticed this appearing: Tue Dec 10 15:20:14.043 [conn3] getmore bleah.data query: { $where: " Doing a google, I came across this article. Apparently, mongodb dies when it runs out of memory. Discover Wireless Devices with Avahi https://dchua.com/posts/2013-11-16-discover-wireless-devices-with-avahi/ Sat, 16 Nov 2013 00:00:00 +0000 https://dchua.com/posts/2013-11-16-discover-wireless-devices-with-avahi/ Quick protip: If you’re having trouble finding the ip addresses of your devices that is connected to your local area network. Use Avahi $ avahi-browse -alr This returns you a list of all the devices connected to your network with the corresponding ip address. Changing default colorscheme in gvim/mvim https://dchua.com/posts/2011-02-09-changing-default-colorscheme-in-gvimmvim/ Wed, 09 Feb 2011 00:00:00 +0000 https://dchua.com/posts/2011-02-09-changing-default-colorscheme-in-gvimmvim/ A common mistake I’ve often fall into is forgetting how to set a default colorscheme for GUI vim editors. If you’re using gvim, MacVim, to set your default colorscheme, you’ll need to edit (or create if it doesn’t exist) ~/.gvimrc instead of your normal ~/.vimrc. For example in my ~/.gvimrc: colorscheme darkblue