Here are a few commands that I found helpful when I learned to use the command line to connect to the server.
To connect to the server, type the following line into your command line tool. I’m on a Mac and use the terminal:
username is the name of a user that has ssh permission, example: root. ip is the ip of the domain you want to connect to, example: 3126.96.36.199
you will then be asked for a password for the user, which you need to provide.
To manoeuvre to the right directory, you can use some of the following commands:
- ls (list files and folders in the current directory)
- cd (change directory)
cd .. (change to parent directory)
cd folder/folder1/folder2/ (go to a directory directly by typing the exact location)
- use the ~ symbol to get back to the home directory. Example: cd ~
Doing things with files
You can manipulate files and folders by using the following commands.
The cp command makes a copy of a file for you. For example, cp file foo makes an exact copy of the file whose name you entered and names the copy foo, but the first file will still exist with its original name. After you use mv, the original file no longer exists, but after you use cp, that file stays and a new copy is made.
The mv command moves a file to a different location or renames a file. Examples are as follows: mv file foo renames the original file to foo. mv foo ~/Desktop moves the file foo to your desktop directory but does not rename it. You must specify a new filename to rename a file.
Use this command to remove or delete a file in your directory. It does not work on directories that contain files.
The mkdir command allows you to create directories. For example, mkdir music creates a music directory.
The chmod command changes the permissions on the files listed.
Permissions are based on a fairly simple model. You can set permissions for user, group, and world, and you can set whether each can read, write, and/or execute the file. For example, if a file had permission to allow everybody to read but only the user could write, the permissions would read rwxr–r–. To add or remove a permission, you append a + or a – in front of the specific permission. For example, to add the capability for the group to edit in the previous example, you could type chmod g+x file.
chmod 764 pics.html
owner group other
777 = rwxrwxrwx
755 = rwxr-xr-x
744 = rwxr–r–
644 = rw-r–r–
The chown command allows the user to change the user and group ownerships of a file. For example, chown john file changes the ownership of the file to John.