Problem
You would like to know what are the biggest nn files in your linux computer.
Solution
Run the following to give you the 20 largest files:
sudo du -ahx / | sort -rh | head -20
taken from Linux Journal Issue 275 March 2017
Problem
You would like to know what are the biggest nn files in your linux computer.
Solution
Run the following to give you the 20 largest files:
sudo du -ahx / | sort -rh | head -20
taken from Linux Journal Issue 275 March 2017
Problem
You would like to find out the serial number of your Lenovo laptop, but without switching it off and taking the battery off.
Solution
You can run the following to get your laptop’s details including the serial number:
sudo dmidecode -t system
Taken from the post here
Problem
You are trying to install the gems for your rails application in a new computer, or by using ruby 2.4 and you get the following error:
An error occurred while installing json (1.8.3), and Bundler cannot continue. Make sure that `gem install json -v '1.8.3'` succeeds before bundling.
Solution
Remove your old Gemfile.lock file and run bundle again. A newer version of json (ie 1.8.6) should be installed.
Problem
When you are trying to install a package inside a debian Docker container you get the following error message:
FATAL -> Failed to fork.
Solution
This is an indication of ‘out of memory’ so add a swap partition if it does not exist, on the host with the following:
fallocate -l 4G /swapfile chmod 600 /swapfile mkswap /swapfile swapon /swapfile echo "/swapfile swap swap sw 0 0" >> /etc/fstab
(Thanks Valent)
Problem
You have a remote server (Debian) running some Docker containers and you want to make sure that they all restart in the event of a kernel panick.
solution
sysctl kernel.panic=20
echo c > /proc/sysrq-trigger
Problem
Looking at your /var/log/syslog you see entries every few seconds like the following:
Mar 1 15:44:52 L530 systemd-udevd[11464]: failed to execute '/lib/udev/socket:@/org/freedesktop/hal/udev_event' 'socket:@/org/freedesktop/hal/udev_event': No such file or directory Mar 1 15:44:52 L530 systemd-udevd[11451]: Process 'socket:@/org/freedesktop/hal/udev_event' failed with exit code 2. Mar 1 15:44:54 L530 systemd-udevd[11479]: failed to execute '/lib/udev/socket:@/org/freedesktop/hal/udev_event' 'socket:@/org/freedesktop/hal/udev_event': No such file or directory Mar 1 15:44:54 L530 systemd-udevd[11466]: Process 'socket:@/org/freedesktop/hal/udev_event' failed with exit code 2.
Solution
Seems that hal is not used in newer Ubuntu versions, so you can remove it:
sudo apt-get purge hal
Taken from the answer here
Problem
You would like to check the storage engine in a MySQL database.
Solution
Use the following query after logging in to the server:
SELECT TABLE_NAME,
ENGINE
FROM information_schema.TABLES
WHERE TABLE_SCHEMA = 'your_db_name';
Taken from here
Problem
You want to remove a certain line from your server’s bash history, if for example you pasted a password in the wrong place.
Solution
Use the two steps:
1. history -d line_number to remove from memory
2. history -w to write in-memory history to the history file ~/.bash_history
as described here
When the shell is not bash (sh) you can remove them from ~/.ash_history and then source the file.
Problem
You would like to change the default editor for crontab from nano to vim.
Solution
Add the following to the ~/.selected_editor:
SELECTED_EDITOR="/usr/bin/vim"
or run the select-editor and choose vim-basic (4)
server# select-editor Select an editor. To change later, run 'select-editor'. 1. /bin/ed 2. /bin/nano <---- easiest 3. /usr/bin/mcedit 4. /usr/bin/vim.basic 5. /usr/bin/vim.tiny Choose 1-5 [2]: 4
Problem
You would like to use OpenStreet maps in your Garmin GPS, and be able to use navigation.
Solution
./mkgmap.jar --gmapsupp --index --route --description="Country_Name" $( ls /map_for_a_country/*.img )
NOTE: You might need to run java –jar mkgmap.jar …