General command


chmod ugo+rwx directory1   ---    设置目录的所有人(u)、群组(g)以及其他人(o)以读(r )、写(w)和执行(x)的权限

**Environment Variable**

export 	---  It is a bash shell BUILTINS commands, which means it is part of the shell. It marks an environment variable to be exported to child processes.
echo $SHELL_VARIABLE    ---    output the value of the variable if it has one
unset VARIABLE_NAME    ---    unset an environment variable

whoami     cal     date

Avoid redundant command !$ — return the path of the latest command !* — return all paths of the latest command !! — automatically replace the latest command

history | grep ****    --- find certain historic commands
!****       ---    **** is the id number of the command
To further reduce the code, u can write a func in the .bashsrc


cd  &   cd -

export CDPATH='~:/Desktop/working_directory'        ---    Add the common working directory to the shell variable

s

Files

diff filename1 filename2 
zip file1.zip file1         ---     创建一个zip格式的压缩包 
unzip temp.zip
ls -lsah  ---  -l long format | -s size | -a all files | -h human-readable output
wc filename	   ---   tells you how many lines, words, and characters there are in a file
touch file.sh       ---      Create a newfile

# Open/read file
cat file.sh
less file.sh
vim file.sh
nano file.sh

# Vim:
0	 Beginning of line
$	# End of line
gg	# First line of file
G	# Last line of file
dd	# delete a line

:qa!	# quit and abandon all changes
:q!		# quit and overwrite/apply all changes
:wq		# write and quit

Disk Space Storage

df -h     ---   Show Disk Space Usage in Human Readable Format

Network related

ifconfig  --- check networking driver and usage
ping www.google.com    --- checking network connection

nslookup www.google.com   ---  query Internet name servers as well as your local name server
    Server:         128.146.48.7               --- local name server
    Address:        128.146.48.7#53

    Non-authoritative answer:
    Name:   www.google.com
    Address: 142.251.35.164                    --- IP address of google
    Name:   www.google.com
    Address: 2607:f8b0:4006:807::2004


lspci   ---  find out linux wireless card chipset info

 # Fun thing: Testing network speed
wget -O speedtest-cli https://raw.githubusercontent.com/sivel/speedtest-cli/master/speedtest.py
chmod +x speedtest-cli
# Run it with
./speedtest.py

System related

passwd 		---   lets you change your password

Resource checking

lscpu    ---   Checking CPU
   
top      --- display linux process, e.g. resource(cpu, mem...) usage

2023-05-03 Rviz2 in ArchLinux

------------------
Issues:
1. Can't start the rviz2 

------------------
Solution:
1. Update the X11 | 
    take care of the graphic driver (Inter / Nvida)| http://wiki.ros.org/docker/Tutorials/Hardware%20Acceleration
    
    xhost +local:root                       # adjust the permissions the X server host.
    docker run \
      --rm    \                      # Automatically removes the container when it exits.
      --it    \                      # Starts an interactive terminal session.
      --name  \                      # Assigns a name to the container (optional).
      --net=host  \                  # Shares the host network namespace with the container, which is necessary for RViz2 to connect to the ROS network.
      --volume=/tmp/.X11-unix:/tmp/.X11-unix \ # mounts the host machine's X11 socket directory into the Docker container, which allows the container to connect to the X11 display server
      --env="QT_X11_NO_MITSHM=1" \
      --env="DISPLAY=$DISPLAY" \      # sets the DISPLAY environment variable in the Docker container, which tells the graphical application where to display its output
      --device=/dev/dri:/dev/dri \    # set the driver to Intel driver
      docker_name
      /bin/bash             `   # Starts a Bash shell in the container.

Wifi logo is not found in ubuntu 20.04

About dual-boot with Windows and “fast-boot” enabled

If you have a dual-boot machine with a recent version of Windows and start seeing problems during initialization of the WiFi device when booting Linux, the problem could be due to the “fast startup” feature on Windows.

With this feature enabled, Windows don’t really shut down the entire system, but leaves things partially running so you can start the machine faster again. Try to disable this option, on Windows 10 it should be in “Control Panel→Hardware and Sound→Power Options→System Settings”. Select “Chooose what the power buttons do” to access the System Settings from the Power Options. Then disable the “Fast Startup” option in “Shutdown Settings”. This will cause Windows to fully shutdown and may solve the issue.

update the nvidia driver

install the tool for configuring the NVIDIA graphics driver

sudo apt-get install nvidia-settings
❌nvidia-settings won’t start: “Unable to find display on any available systems”

Because of running Wayland, we logout on the login screen you should have a gear in corner that allows you to switch to X11 currently that is the only way to control nvidia GPU that I know of.

❌nvidia-settings won’t start: “Unable to find display on any available systems”
  sudo ubuntn-drivers devices
  sudo ubuntn-drivers autoinstall
  
  sudo prime-select nvidia # 切换nvidia显卡
  sudo prime-select intel  # 切换intel显卡
  sudo prime-select query  # 查看当前使用的显卡

for ref: https://blog.csdn.net/wf19930209/article/details/81877822

use autoinstall to upgrade the driver

    sudo ubuntn-drivers autoinstall
    
    #check if novueau is working
    lsmod | grep nouveau

for ref:https://blog.csdn.net/u012386311/article/details/103402428?spm=1001.2101.3001.6650.1&utm_medium=distribute.pc_relevant.none-task-blog-2%7Edefault%7ECTRLIST%7ERate-1-103402428-blog-82626538.pc_relevant_default&depth_1-utm_source=distribute.pc_relevant.none-task-blog-2%7Edefault%7ECTRLIST%7ERate-1-103402428-blog-82626538.pc_relevant_default&utm_relevant_index=1

OpenCV setup in linux

# Install minimal prerequisites (Ubuntu 18.04 as reference)
sudo apt update && sudo apt install -y cmake g++ wget unzip  ## (-y: automatic yes to prompts)g++:complier, wget:download the source code

# Download and unpack sources
wget -O opencv.zip https://github.com/opencv/opencv/archive/4.x.zip

# Create build directory
mkdir -p build && cd build

# Configure
cmake  ../opencv-4.x

# Build
cmake --build .

Cmake

traditional method

    mkdir build && cd build
    cmake ..
    make
    make test

modern build procedure
    
    mkdir -p build && cd build
    cmake --build build -t test    ## by passing the “test” target to the underlying build system. -t (--target before CMake 3.15) lets you select a target

Add Chinese input to the linux system

Check the following link out
https://www.dell.com/support/kbdoc/en-us/000181184/how-to-add-chinese-pinyin-input-to-xps-9310-laptops-that-ship-with-ubuntu-20-04-in-english