Hello, dear friend, you can consult us at any time if you have any questions, add WeChat: daixieit

Linux and Bash Terminal Basics Part 2 - MTRX3760

This page provides detail on useful Linux terminal commands to get you started

PIPING

program > filename saves program output to a file, overwriting existing files

e.g. tree > mytree.txt

program >> filename appends program output to the end of the named file, no overwriting program < filename provides the data in a file as input to the program

program1 | program2 runs program1 and sends its output to program2

e.g. tree | more

e.g. find | grep main.cpp

Note: every program you run on the command line has 3 streams, STDIN, STDOUT and STDERR. > sends STDOUT to file, < sends a file to STDIN.

MISCELLANEOUS COMMANDS

top realtime process display, press P to sort by CPU usage, q to close

htop enhanced version of top

ctrl-s pause output to terminal

ctrl-q resume output to terminal

TMUX

tmux runs a terminal multiplexer that allows multiple terminals to share one window

tmux ls, tmux attach, tmux detach : list, attach to, or detach from a running tmux

You can leave tmux running even after you’ve logged off from a system (e.g. turtlebot)

Good reference: https://gist.github.com/MohamedAlaa/2961058

Inside tmux the prefix: Ctrl-B, comes before all commands

Prefix-“ : split horizontally

Prefix-%: split vertically

Prefix-x: kill pane

Prefix-: (colon): access tmux command line;

at tmux command line: kill-session to close and end all processes

Prefix-q to display panel numbers

Prefix-Arrow keys to go between the panels, or Prefix then panel number

Prefix-z to make the panel fill the window

Within a panel: “exit” closes the panel

TERMINATOR

Similar to tmux, more mouse-friendly

Ctrl+shift+e: split vertically

Ctrl+shift+o: split horizontally

Ctrl+shift+n / ctrl+tab: go to next split terminal

Ctrl+shift+w: close terminal

Ctrl+shift+x: maximise terminal

You can also right click and use the options ‘split vertically’ etc from the menu

Right click: access preferences, see keybindings for more shortcuts

VSCODE

A full featured integrated development environment (IDE): edit, build, debug in one tool

Use this link to set up the launch.json and tasks.json files needed for debugging C++ in VSCode:

https://code.visualstudio.com/docs/cpp/config-linux

A more detailed reference: https://code.visualstudio.com/docs/cpp/launch-json-reference

Tutorial on setting up VSCode for multi cpp files: https://www.youtube.com/watch?v=DVyYnOHP4nY More information: https://github.com/microsoft/vscode

DRAWING UML DIAGRAMS

Draw.io online and desktop app that has a UML diagram option, easy interface

Google slides

Inkscape is a powerful, free and open-source alternative to adobe illustrator

WORKSPACES / VIRTUAL DESKTOPS

https://www.geeksbeginner.com/multi-workspaces-on-ubuntu-20-04/

https://websiteforstudents.com/what-are-workspaces-and-how-to-use-them-on-ubuntu-18-04/

Most versions of linux including Ubuntu have a “workspace” feature that lets you have different programs / windows open on different virtual desktops

You can bind hotkeys for switching between workspaces, default is ctl-alt-<arrow keys>

This is very useful, please learn to use it!