This week we'll cover some basic network communication tools and work with a remote system (the one that's hosting this website).
SSH
SSH is protocol for secure network communication, remote login, and remote command execution.
To log in to a server that you have an account on, use the command
ssh USERNAME@HOSTNAME
.
To run a command on the server, use the same command but also list the command:
ssh USERNAME@HOSTNAME cat .bashrc
will print the contents of your .bashrc
file.
File permissions
After logging in, run the command ls -al
to give a detailed list
of your home directory. Here's a partial output for my directory:
drwx------ 15 jlepak jlepak 4096 Apr 24 01:58 .
drwxr-xr-x 15 root root 4096 Apr 24 00:40 ..
-rw-r--r-- 1 jlepak jlepak 270 Apr 24 01:31 add-csc185.sh
drwx------ 2 jlepak jlepak 4096 Nov 22 00:39 .aptitude
-rw-r----- 1 jlepak root 27681 Apr 2 19:18 auth.log
-rw------- 1 jlepak jlepak 1648 Apr 24 01:20 .bash_history
The first field gives details of the file permissions for each entry. There are 10 columns: the first indicates if the entry is for a directory (or other possibilities); the next 9 indicate if read, write, or execute (allowing the file to be run as a command) permissions are enabled for the user (the primary owner of the file, shown in field 3), group (a group of one or more users, shown in field 4), and all others.
The chmod
program can change file permissions to enable or disable any of
those permissions.
Homework
Do this homework while logged in to the ilzd.org
server, and save
all your answers in a file called hw11.txt
in your home directory
(the nano
editor will be available to use).
Due Tuesday, May 1.
- Type the
whoami
andgroups
commands. What is their output? - Type the
who
command. Who else is logged in? - Navigate to someone else's home directory: use the command
cd /home
to navigate to the folder that contains all the user directories, and then pick one. What happens when you try to create a file in someone else's home? (You can use the commandtouch my-file.txt
to try). Navigate to the
/var/www/ilzd.org/csc185
folder./var/www/ilzd.org
holds the files served up by the web server, andcsc185
is a folder that everyone in class has permissions to write to.Create a text file (either a
.txt
file or a.html
file if you are familiar with HTML) and put a short message in it. Name it something unique so I know it's from you. Verify that you can see it in a web browswer by navigating tohttp://ilzd.org/csc185/yyy.txt
(whereyyy.txt
is whatever you named your file).