Skip to content

Contributing Terminal

Michael Leonffu edited this page Mar 28, 2017 · 7 revisions

Welcome to terminal!

Terminal, command line, is the interface used to connect to the server and run programs. Knowing how to use terminal is necessary to develop backend.

You should either have PuTTY or Terminal, a program with SSH server capabilities.

Commands


WARNING Mostly everything in terminal is case-sensitive!

SSH

You can connect to the server with the ssh command:

$ ssh -p [port] [hostname]@[hostIP]

If successful you will be in the home directory for the user which is ~/.

Navigation

There are certain commands you should be familiar with:

  • pwd - Return's working directory
  • cd - Change the current directory
  • ls - List directory contents

pwd

Return's working directory; shows you where you are:

$ pwd

cd

Change the current directory:

$ cd [dir]

Advice: if you want to go to the home directory, in the case you are lost, do not enter a dir To move up a directory:

$ cd ..

To move into a directory called dir:

$ cd dir
Tip

You can use cd in many combinations as:

$ cd ../../dir1/dir2

ls

You can use ls to see files and directory in your current directory:

$ ls 
Tip

To see more information such as: hidden directors .dir, permissions, and in a list with color use options:

$ ls -laG
  • l - Option: ls present in a list
  • a - Option: ls shows more/all information
  • G - Option: ls returns with a color scheme

Scripts

You can use these commands once in the correct directory:

  • python - Python interpreter, running python scripts

python

Use the python command to run a python script:

$ python [python_script]

Advice: Stuck in your python? use Control-C to interrupt the script

Permissions

You can use this command to change the read, write, and execute permissions of files and directories:

$ chmod [permission_values] [file]

Refer to this article for permission_values; 755 is likely the value you want to use though.

Other

Some other commands that will help you:

  • man - Display manual for command
  • rm - Remove a file
  • exit - Logs you out of your user

man

Display manual for command, you can find help right in terminal:

$ man [command]

rm

Removes a file:

$ rm [file]

WARNING: Use carefully, files will be completely deleted and unrecoverable; use option -R to remove directories.

exit

Logs you out of your user, you can use this to exit the user root and go back into your own user

$ exit

Cheat Sheet (Backend) LEGACY

If you're reading this then stop and go back and figure out how to do it; if you are coming back then: Welcome.

  1. Run the ssh command
  2. Go to backend workspace directory: cd /root/TheOrangeAlliance/python
  3. Check you're in the right directory: pwd
  4. Use ls to find your python script
  5. Running your script: python myPythonScript.py
    Disclaimer: I cannot guess your script name, replace myPythonScript.py with whatever your python script is called, this is a case-sensitive command
  6. Stuck in python, do you deserve it? Use Control-C to attempt to interrupt python
  7. When you're done do exit
  8. Go look at some tutorials

By Michael Leonffu March 26, 2017; Last edited by Michael Leonffu March 27, 2017