ICS 325
Lab 1
Access and Navigate Your
Linux Account
1. Log onto the system:
·
On
one of PCs in our lab, Select
Start à Programs à SSH
Secure Shell à Secure Shell Client
Press the spacebar to access the logon screen
Enter Host Name: redhat.ics.metrostate.edu
Enter User Name: su04325?? (where ??
is your class number)
Click Connect
Enter Password summer04
NOTE: From your home, you will need to download and install the ssh client.
Download Site: http://redhat.ics.metrostate.edu/ssh.zip
·
If
you can see the following information, you have logged onto the system
successfully
su04325??@tyr:~>
2. Change your password:
·
As
soon as you log onto the system for the first time, you should change your
password. To do so, follow these steps:
·
At
the > prompt, type in : passwd
·
Respond
to the New password prompt with your
new password
General guidelines for
selecting a password:
8 characters or more
no English words
no birthday
at least one upper key
character is included
easy to memorize
·
Confirm
the new password by retyping the new password
3. How to logout from the system
·
At
the prompt of > type in: logout
·
Another
way to do it is to type in: exit
4. Send an email to the instructor to
tell her that your password has been changed successfully.
·
At
the prompt of >, do the following:
·
Type
in: mail sue
·
To
respond to the prompt of "Subject", type in: password su04325??
·
Then
you type in the following message:
Hi Sue,
My password has been
changed successfully.
Thanks.
Your name.
·
After
you finish your typing, you need to do the following:
·
Press
the Enter Key
·
Type
in: CTRL-D (note: CTRL-key with Letter D)
5. Working in the Linux shell
commands:
ls
// list all files in this directory.
ls –l //
list all files in long format.
ls –al //
list files - includes hidden files.
ls –al | more // same as ls
–al and displays one page at a time
pwd //
prints the current directory.
cd // change directory to home
directory
cd /bin // change directory to /bin
cd subd // change
directory to subdirectory subd
clear //
clears the screen.
last //
lists the last users logged in.
who //
lists who is logged on now.
man ls //
man is the Linux manual,
man pwd
man cat
exit //exits
the Linux system
NOTE : (press the key "q" to interrupt the command "man").
6. Working with files and directories
Commands
§
mkdir creates a new directory
§
rmdir removes a directory
§
file
shows
information about a file based on its contents
§
touch
it
is used to create or update the modification and access times of files.
§
rm it is used to delete a file.
§
cat it
is used to create, view, or concatenate files.
§
cp
copy a file.
§
mv move
a file. It is also used to change the name of a file.
§
chmod changes the permissions for
the folder or file
Create a new directory
mkdir lab1
Change the current directory to the directory lab1
cd lab1
Create a file:
§
Check
the current directory to see if a file test1
exists
> file test1
test1: can't stat `test1' (No such file or directory).
§
Create
an empty file called test1
> touch test1
> file test1
test1: empty
§
Create
a file called test2 that contains the current date and time
> file test2
test2: can't start `test2' (No such file or directory).
> date
Mon Sep 13
> date > test2 //
> redirects the output, in this case to a file
> file test2
test2: ASCII text
> cat test2
Mon Sep 13
§
Create
a file called test3 using the command cat
> file test3
test3: can't stat `test3' (No such file or directory).
> cat > test3
This is a test file.
^D
> file test3
test3: ASCII text
> cat test3
This is a test file.
§
Create
a file called test4 using the command cp.
> file test4
test4: can't stat `test4' (No such file or directory).
> cp test2 test4
> cat test4
Mon Sep 13
Modify a file:
> file test1
test1: empty
> cat test2 > test1
> cat test1
Mon Sep 13
> cat test3 > test1 // > replaces
an existing file
> cat test1
This is a test file.
> cat test2 >> test1 //
>> appends to an existing file
> cat test1
This is a test file.
Mon Sep 13
Change the name of a file:
> file test5
test5: can't stat `test5' (No such file or directory).
> cat test4
Mon Sep 13
> mv
test4 test5
>file test5
test5: ASCII text
>file test4
test4: can't stat `test4' (No such file or directory).
> cat test5
Mon Sep 13
Delete a file:
>file test5
test5: ASCII text
> rm
test5
>file test5
test5: can't stat `test5' (No such file or directory).
§
File
properties:
§
When
you view a file using a long format, you will see seven-column information
listed about a file shown in the following example.
ls -l
-rw-r--r-- 1 s04325??
student 27 Jun 1
§
-rw-r--r--
§
It
consists of 10 characters.
§
The
first character indicates the type of the file:
-
:
a regular file;
d : a directory;
b : a block-oriented
special file, such as a disk or CD-ROM;
c : a
character-oriented special file, such as a terminal or printer.
§
The next nine characters indicate
the access mode (permission).
§
The
access rights are classified as
r : read;
w : write;
x : execute.
§
The
users who probably have the access rights to the file are classified into to
three categories, hence the nine characters for permissions:
u : owner
of the file.
g : the
users who are in the same group of the owner.
o : all
other users.
§
If
a hyphen appears instead of a letter, then the corresponding access right is
denied.
§
To
change the access modes, type chmod with proper
arguments.
§
+
is used to grant the access mode (permission).
§
- is used to remove the access mode
(permission).
§
Example:
> chmod g+rw
test1
> ls –l
test1 //-rw-rw-r--
1 s04325?? student 0 Jan 7
> chmod g-w test1
> ls –l
test1 //-rw-r--r--
1 s04325?? student 0 Jan 7
§
A letter "a" can be used
to represent all users.
> chmod a+rw
test1
> ls -l
test1 //-rw-rw-rw-
1 s04325?? student 0 Jan 7
§
The
numerical notation is commonly used for changing a file's access mode.
§
For
each user category, the three-character is translated into a binary number with
the three bits. Then the binary numbers which are matched to all possible
combinations of the access modes are listed as follows:
|
Access
mode |
Binary
notation |
Decimal
number |
|
--- |
000 |
0 |
|
--x |
001 |
1 |
|
-w- |
010 |
2 |
|
r-- |
011 |
3 |
|
-wx |
100 |
4 |
|
r-x |
101 |
5 |
|
rw- |
110 |
6 |
|
rwx |
111 |
7 |
Examples:
> ls -l
test1 //-rw-rw-rw-
1 s04325?? student 0 Jan 7
> chmod 755 test1
> ls -l
test1 //-rw-r-xr-x
1 s04325?? student 0 Jan 7
> chmod 600 test1
> ls -l
test1 //-rw-------
1 s04325?? student 0 Jan 7
Directories use the same permission structure