This article explains several useful commands on ubuntu from checking memory status and usage to user access and variables.
ls -l --block-size=M
Above command will give you a long format listing (needed to actually see the file size) and round file sizes up to the nearest MiB.
ls -lh
Here h stands for human readable
This command will produce the percentage wise usage of memory
ps aux --sort=-%mem | head
If you want to show only the command name instead of the full path of the command, run the following command:
ps -eo pid,ppid,cmd,comm,%mem,%cpu --sort=-%mem | head -10
Below command provides, owernship to user ubuntu to folder /var/www
sudo chown -R ubuntu:ubuntu /var/www/
Do not run it on /etc/
> lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 18.04.6 LTS
Release: 18.04
Codename: bionic
Check all running processes with their process ID and name
ps -e
Then we can find the command we want to kill with grep
ps -e| grep java
ps 1321
kill -9 1321
The following command will extract the zip file and create a folder project-3
tar -xvf project-3.tar.gz
The below command does the exact opposite of the above command, it will create a tar file of the given folder. If you notice the difference in -x and -c. Here -c means create and -x means extract.
tar -cvf project-3.tar.gz project-3/
Add the path to JAVA_HOME variable, you can echo and verify the same.
export JAVA_HOME=/opt/openjdk11
echo $JAVA_HOME
If an application has to access server application running on a specific port, we need to open port.
sudo ufw enable
sudo ufw allow 3306