-
Notifications
You must be signed in to change notification settings - Fork 4
Linux basics
The word 'sudo' sometimes comes in front of other commands. This signifies that the command is to be run as 'superuser'. This is sometimes also referred to as 'root privileges', which is somewhat comparable to administrator privileges on windows. However, prefacing a command with 'sudo' will allow you to do virtually everything, such as deleting all system files and rendering your operating system useless. So don't just use it for everything!
The .bashrc file is a collection of instructions that are executed every time you open a new terminal. This makes it the ideal place to define environment variables (e.g. names that refer to the location of ROS packages), IP addresses and even execute code that you want to run everytime before you perform command line operations. The .bashrc file is located in the home directory, and is hidden by default (by pressing Ctrl+H you can view hidden files in the graphical file navigator).
Everytime you make changes in the .bashrc file, they are not automatically applied to the terminal you are currently working in. To apply the changes, you can either open a new terminal (and close the current one) or execute source ~/.bashrc
in your current terminal.
Secure Shell or SSH is a protocol that enables encrypted logins to a remote PC. This means that it can be used to remotely execute commands. Essentially, it provides access to a remote computers terminal. It is especially useful for systems that run headless (without a monitor), such as the computers typically present on mobile robots.
On Linux and mac, SSH is a built-in command. In windows, third party programs such as PuTTY provide similar functionality.
Modern Linux distributions often come with a rich graphical interface that enable you to perform a lot of tasks with point-and-click operations. Moving to a text-based environment may seem like a step back. However, graphical interfaces tend to simplify things, whereas the command line allows for more difficult operations. Additionally, instructions can be collected into a single file called a 'script', which means you can automate everyday tasks like copying files, logging information or pinging servers.
Knowledge of the command line is essential for ROS developers. A significant number of basic ROS tools have a command line interface, and you will find yourself using them often. ROS-specific commands are explained in the first tutorial of the workshop. Below you will find some general Linux commands that may be usefull.
ls
: list the files in the current directory
pwd
: print name of current directory
cd
: change working directory
mkdir
: create a directory/make directories
touch
: change file timestamps/create empty files
cp
: copy files and directories
mv
: move (rename) files
rm
: remove files or directories
rmdir
: remove empty directories
cat
: concatenate files and print on the standard output
nano
: command line text editor
man
: an interface to the on-line reference manuals
adding --h
or --help
to a command often opens documentation in the command line. Example:
ls --help
Ctrl+alt+T
: Open a terminal in a new window
Ctrl+Shift+T
: Open a terminal in a new tab (only after opening a terminal window)
Ctrl+C
: kill a running command
Ctrl+D
: signal bash that there is no more input
Ctrl+L
: redraw the screen
history
: display bash command history
sudo
: execute a command as the superuser
chmod
: change permissions of a file
© 2018 Ad Usum Navigantium