Ubuntu: Bash history management

# To see top commands
history | awk '{print $2}' | sort | uniq -c | sort -rn | head
# To remove a commands from history
# Replace YOUR_COMMAND with the initials of the command you want to remove from bash history
sed -i '/^YOUR_COMMAND/d' ~/.bash_history

VisualStudio code & compile_commands.json

If you are working with C/C++ in VSCode, you will find that VSCode keeps on showing

"${workspaceFolder}/build/compile_commands.json" could not be found. 'includePath' from c_cpp_properties.json will be used instead.

This message is generated by vscode-cpptools. Although it is an optional file however vscode-cpptools keeps on showing error message that it is missing.

This message can easily be fixed if you are using CMake. To do so simply add following to your CMake configuration file.

# Generate compile_commands.json
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)

Setup: FTP server

# Setup FTP server
# Instructions are tested on: Ubuntu 18.04.3 LTS
apt install -y atftpd
sudo gedit /etc/default/atftpd
# – set USE_INETD=FALSE
# – Optional: To change directory to host FTP contents, change /srv/tftp in OPTIONS line
# – Optional: To have maximum log: change –verbose=7 and append –logfile /var/log/atftpd.log
sudo mkdir -p /srv/tftp
sudo chmod -R 777 /srv/tftp
sudo chown -R nobody /srv/tftp
# Vanilla contents
# USE_INETD=true
# # OPTIONS below are used only with init script
# OPTIONS="–tftpd-timeout 300 –retry-timeout 5 –mcast-port 1758 –mcast-addr 239.239.239.0-255 –mcast-ttl 1 –maxthread 100 –verbose=5 /srv/tftp"
# After changes
# USE_INETD=false
# # OPTIONS below are used only with init script
# OPTIONS="–tftpd-timeout 300 –retry-timeout 5 –mcast-port 1758 –mcast-addr 239.239.239.0-255 –mcast-ttl 1 –maxthread 100 –verbose=7 –logfile /var/log/atftpd.log ~/tftp"
# Run the service
sudo invoke-rc.d atftpd start
# Verify atftpd is running
netstat -lnp | grep ":69 "
# Use atftp FTP client to verify atftpd
apt install -y atftp
atftp localhost
# Make sure /etc/hosts is having following mapping otherwise localhost above command will not work
# 127.0.0.1 localhost
# Download an file from FTP server
get file_name_which_is_hosted_on_ftp