sudo sh -c 'echo "deb http://packages.ros.org/ros/ubuntu $(lsb_release -sc) main" > /etc/apt/sources.list.d/ros-latest.list'
sudo apt install curl
curl -s https://raw.githubusercontent.com/ros/rosdistro/master/ros.asc | sudo apt-key add -
sudo apt update
sudo apt install ros-melodic-desktop-full && sudo apt install ros-melodic-rqt* ros-melodic-rviz*
If ros installed successful, follow below commands
echo "source /opt/ros/melodic/setup.bash" >> ~/.bashrc
source ~/.bashrc
or
echo "source /opt/ros/melodic/setup.zsh" >> ~/.zshrc
source ~/.zshrc
sudo apt install python-rosdep python-rosinstall python-rosinstall-generator python-wstool build-essential
before below commands, it is neccessary for 'rosdep update' without 'sudo'
sudo rosdep init
rosdep update
make your workspace like 'catkin_ws'
mkdir catkin_ws/src -p
cd catkin_ws/src
catkin_init_workspace
catkin_make in your workspace '~/catkin_ws/' not in '~/catkin_ws/src'
catkin_make
It is finish to install ROS in your ubuntu
below command is additional settings
In bashrc or zshrc
gedit ~/.bashrc
save and adapt bashrc
source ~/.bashrc