cd | Change the directory. You can either give a full path or simply a series of child-directories. Use: cd /path/to/folder |
ls | View what child-directories and files there are in the current working directory. On some operating systems they might be color-coded as well. Use: ls
|
pwd | Shows the absolute path to your current working directory. Use: pwd |
find | Prints a list of files matching your input. If you type a full file name it will either show that file-name or an error message stating that the file was not found. It is particularly useful when combined with the *-operator for pattern matching. Use: find <file_name>
|
du | Print the size of the directory you give as an argument. Use: du -sh <directory_name> |
mv | Move or rename files. Use: mv <old_name/location> <new_name/location> |
|
cp | Copy files from <old_location> to <new_location>. Use: cp <old_location> <new_location> |
|
rm | Delete a file. named <file_name>. Be careful with this, especially when using it in combination with the *-operator or with the -r flag! Use: rm <file_name> |
|
cat | View the content of a file by displaying it on the Terminal. It is meant for test-files only, so you might get weird results when trying to view for instance an image. Use: cat <file_name> |
|
touch | Create an empty file, named <file_name> Use: touch <file_name> |
|
mkdir | Create a directory called <dir_name> Use: mkdir <dir_name> |
|
grep | Grep is a very powerful command, but put simply searches for string-parts in a document. One of the more useful ways of using it, is directly piping the output of some command to it. Example: Find <text> in a text-file called <file> cat <file> |
grep <text> |
*-operator | The star operator is used for pattern matching. The star operator can be viewed as a joker, that can be replaced by any string, even an empty one. It is useful for auto-completion or accessing multiple files that have similar names. Example: cat *.txt will print out any text-file using the file extension .txt to your terminal. |
man | View the manual page of any command that comes with a manual page. (Most commands do have one) On this page you will be shown the usage and all the options the command provides. Use: man <command> |
top | Shows a list of running processes and used system resources. To quit it, press q or Ctrl + C. Especially useful for finding Process-IDs. Use: top |
htop | Shows a colorful and dynamic almost graphical) interface of the top command. It has a more readable layout and allows to kill processes by selecting them. Also allows sorting the processes by different metrics. Use: htop |
kill | Sends a stop-flag to the process given by the process-ID. You can choose between different flags. The graceful way (i.e. the one to try first) is to write kill -6 <process-ID> It allows the killed program to handle the exit and to some last minute store. If this does not work, one can also use the more aggressive flag kill -9 <process-ID> |
free | Displays the amount of system memory in use and how much is still free. To display it in a human readable way (i.e. in GB or MB rather than Bytes), use the -h flag. Use: free -h |
watch | Executes the following command every 2s and updates the screen. This command is useful to monitor the behavior of some statistics. One can also decrease the time between updates by using the -n flag. Use: watch -n <time_between_updates> <command> Example: watch -n 0.2 free -h (displays the free memory every 0.2 seconds) |
nvidia-smi | If a Nvidia graphics card is installed this command shows important information about the current status of the graphics card. Use: nvidia-smi |
screen | Provides an environment, in which you can emulate a console. You can safely detach from this environment and it will keep being executed. You can than reconnect at any point and it will show you the contents of the terminal at that point in time. It is especially useful when working on the cluster, as you can have your virtual environment running in one screen and detach from this screen and disconnect from the server, without the process being killed. (If you don’t run your script through slurm) One downside of this environment is however, that you cannot easily scroll within it. Use:
|
&-operator | Execute a command in the background. This will have your terminal run the command without occupying the screen. (i.e. you can still interact with the terminal as normal) |