Useful Unix - northern-bites/nbites GitHub Wiki

Useful Unix

A good place to find lots of information for beginners is here.

It’s HIGHLY recommended you also check out this article that compiles all the useful things a Linux user should know .

Using the terminal/emacs will be a lot less painful if you know the shortcuts/commands.

Keyboard Shortcuts

  • Ctrl + ‘a’: go to the beginning of the line.
  • Ctrl + ‘e’: go to the end of the line.
  • Ctrl + ‘d’: delete forward one character.
  • Ctrl + ‘c’: cancel currently running program or command.
  • Ctrl + ‘k’: “kill” the current line, which deletes all characters from the cursor to the end of the line
  • Ctrl + ‘w’: delete backwards one word.
  • Up Arrow: gives you the contents of your last command (can be used repeatedly to go back any number of commands)

Scripts

Scripts are really useful. They’re all the .sh files you find in our scripts folder. To run a script just do ./scriptname.sh in the directory with the script or path/to/script/scriptname.sh for a full-path to the script in any terminal. The dot in the first version just means current directory. The way to think of scripts is just a batch of operations that will run under the terminal in a certain sequence. So instead of running them one by one by hand, the script will tell the shell to run them. If you ever have a process that you would want to automate, write a script! A good intro with examples are here. You can also look through our scripts in the script folder to see what they’re about.

Other Page Links

Beginner's Guide

Useful commands on the robots

Knowing what processes are running on the robot is very useful, and can explain weird behavior that occurs even when you know you’re installing a reliable branch.

  • ps -e shows all processes on the robot, as well as PID (unique Process Identifier) and other useful info.
    • ps -e | grep man to search for active man processes (or really whatever you want)
  • top shows all processes on the robot in a ‘terminal gui.’ It updates every second or so and also displays cpu usage, PID, memory usage, state, etc. ‘top’ on the robots can be a bit recalcitrant if you’re ssh’d from a Mac, but it can be made to work.
  • tail -f nbites/log/nblog gives you the output of boss and naoqi. Tail will print out any new characters added to the file, which is what many of our processes use instead of the standard terminal ‘stdout’.
  • tail -f nbites/log/manlog gives you the output of man on the robot. Or, at least, it should – depending on when you’ve branched off of develop ‘nblog’ may contain the output of both processes. We’re trying to move away from piping both outputs to ‘nblog’ because it has the tendency to lose or confuse output.
  • kill <pid> can be used to kill a process nicely, provided you know the PID
  • kill -9 <pid> can be used to force any process, even one that normal ‘kill’ didn’t work on, to exit.
  • there is also killall of both versions which takes a process name instead of PID, e.g. killall man
  • scp is our typical command for moving files to or from the robot. Commands look like

scp <source> <dest> where one of <source> or <dest> may be a remote host, something of the form

user@address:path/to/remote/file

for example, a typically installation of boss uses the line

scp ../../build/boss/libboss.so nao@vera:nbites/lib/
⚠️ **GitHub.com Fallback** ⚠️