Skip to content

Instantly share code, notes, and snippets.

@jingxixu
Last active July 21, 2023 03:35
Show Gist options
  • Save jingxixu/13420d71c7b47e2ba2d1b84398f0c756 to your computer and use it in GitHub Desktop.
Save jingxixu/13420d71c7b47e2ba2d1b84398f0c756 to your computer and use it in GitHub Desktop.
Some useful and frequently used command reminders

GPU

nvidia-smi
nvcc --version
cat /proc/driver/nvidia/version
lspci | grep -i nvidia # verify that your GPU is CUDA-capable; basically list GPU device before CUDA is installed

GitHub

init a local git repo and push

git init
git add .
git commit -m "initial"
git remote add origin <remote repository URL>
git remote -v
git push origin master

get a .gitignore

curl https://gist.githubusercontent.com/jingxixu/100dd4a2fa4f17d42e7ec4dbd75d0dcb/raw > .gitignore

create new ssh key

ssh-keygen -t rsa -b 4096 -C "j.xu1995@gmail.com"
eval "$(ssh-agent -s)"
ssh-add ~/.ssh/id_rsa
sudo apt-get install xclip
xclip -sel clip < ~/.ssh/id_rsa.pub

ROS

create ROS workspace

mkdir -p ~/catkin_ws/src
cd ~/catkin_ws/
catkin_make

create ROS package

catkin_create_pkg beginner_tutorials std_msgs rospy roscpp

create ROS workspace using catkin_tools

mkdir -p ~/catkin_ws/src
cd ~/catkin_ws/
catkin init
catkin build    # build all packages

create ROS package using catkin_tools

catkin create pkg <package name>

other catkin_tools commands

catkin config   # show build configurations
catkin list     # show packages in the workspace
catkin clean    # clean built products
catkin build --dry-run    # show the package build order
catkin build --this     # build the package under this working directory
catkin build <package name>     # build a specific package and its dependencies

check package dependencies

  • rospack depends1 <package>
  • rospack depends <package>

Linux

install zsh

https://www.tecmint.com/install-zsh-in-ubuntu/

sudo apt install zsh
zsh --version
chsh -s $(which zsh) 

check version

  • cmake: cmake -version
  • pip package: pip list | grep <package>
  • conda package: conda list | grep <package>
  • ubuntu: lsb_release -a
  • gcc: gcc --version
  • ubuntu: uname -m && cat /etc/*release

completely remove clion installed by snap package

sudo snap remove clion
rm -rf ./.CLion2018.3 ./.CLion2018.3/config/clion.key ./.java/.userPrefs/jetbrains/clion ./snap/clion

edit pycharm launcher file for ROS

The launcher file jetbrains-pycharm.desktop is located in one of

  • /usr/share/applications
  • ~/.local/share/applications

Change Exec="/opt/pycharm-2018.3.4/bin/pycharm.sh" %f to Exec=bash -i -c "/opt/pycharm-2018.3.4/bin/pycharm.sh" %f

change symlink python3 in /usr/bin/

-s for making a link; -f forces updating; -n for folder

ln -sfn python3.7 python3

cpp

  • compilation: compile each file separately, checking syntax error and declaration existence
  • linking: find source code

compare files

meld <file1> <file2>

extract compressed .tar.gz

tar -xvzf ~/Downloads/<input file>.tar.gz -C <output folder>

check video dimensions

ffprobe -v error -show_entries stream=width,height -of default=noprint_wrappers=1 <video>

install drivers

ubuntu-drivers devices  # Detect the model of your Nvidia GPU and the recommended driver using this command.
sudo ubuntu-drivers autoinstall  # Auto install all recommended drivers.

Conda

export and create a conda env

conda env export > environment.yml
conda env create -f environment.yml
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment