Skip to content
Michael Hoyer edited this page Nov 9, 2020 · 7 revisions

Useful Linux commands

Most of the things in linux are done thorugh the Terminal. Here is a list of the most used commands:

Command Description
ls Lists files and folders
cd Change the working directory to <folder>
cp <src> <dest> Copies <src> to <dest>
mv <src> <dest> Moves <src> to <dest>
sudo Executes the command as the root user
mkdir <directory> Creates a directory in your working directory named <directory>
rm -rf <directory> Remove <directory>
gedit or nano <file> Opens a text editor to edit <file>
sudo apt <program> Installs <program> in Ubuntu
chmd +x <file> Makes <file> executable

Sourcing

The terminal needs to know the location of the ros installation and the current workspace. This is done by adding the locations to the bashrc file, which is run everytime a terminal window is stared. This process is called sourcing.

The following command can be used to edit the bashrc file (use gedit, nano or vim as editor)

nano ~/.bashrc

Make sure the following lines at the bottom of the file (current workspace is usually vortex_ws or catkin_ws)

source /opt/ros/<ros distro>/setup.bash
source ~/<current workspace>/devel/setup.bash

Remember to reopen the terminal or to rerun bashrc after changing it. Rerunning bashrc can be done by:

source ~/.bashrc

Set a script to run on startup

During robosub it can be practical to set a script to run automatically when the system starts. This can be done in the following steps

  1. Create a script that launches the desired AUV software
  2. Create a service file (like auv_startup.service below) and point it to the launch script from step 1
  3. Move the service file to <TODO: add the right path, its in system somewhere>
  4. Use sudo systemctl enable manta_start.service to start, stop, enable and disable the service. Enable and diable change startup behaviour.
# auv_startup.service

[Unit]
Describtion=auv_startup

[Service]
User=<linux_username>
Environment=DISPLAY=:0.0
ExecStart=/home/<linux_username>/<path_to_launch_script>

[Install]
WantedBy=multi-user.target
Clone this wiki locally