Logging In

advertisement
Logging In
login: <your username>
password: <combination of letters and numbers>
Typically error messages include:
invalid login - Typically a typing error
Your password has expired - Follow prompts to choose a new one.
Setting your Password
Even if you are not prompted by the system you can reset your password at
any time using the yppasswd command.
yppasswd
Changing password for <user_name>
Old password: <type in your old password>
New password: <type in your new password>
Re-enter your new password: <type in your new password again>
Logging out
exit
You can also use logout or Ctrl-D, but this may not work on all UNIX
systems.
Some Useful Commands
whoami Displays your username.
date Displays the current date and time.
calendar Calendar for current month.
cal 9 1752 Displays the calendar for September 1752.
man <UNIX command> Formats and displays the on-line manual pages. List
all options and gives examples for the use of UNIX commands. You can
use this to find out more about any of the commands listed here. Eg. try
man pwd
pwd “Print Working Directory”. Displays the directory path of your current
location.
1
ls Lists all files in current working directory.
Options include:
• ls -a lists all file including directory entries whose names begin with
a dot (.).
• ls -l lists files in “long format”, including mode, number of links,
owner name, group name, number of bytes in the file, abbreviated
month, day-of-month, hour and minute file last modified, and the pathname.
• ls -t lists files by the times they were last modified (most recent
first).
Note You can combine options together as in eg. ls -la.
1
Files
1.1
Naming your files
File names can be up to 255 characters in length and can contain upper and
lower case letters, numbers and special characters. Unix is case sensitive so
program.c and Program.c are different files.
1.2
Displaying file contents to screen
cat <filename> Displays the contents of “filename” on the screen, without
stopping.
more <filename> Displays the contents of “filename” on the screen. If
the listing is longer than one screen the listing stops and prompts you for
“more?”.
less <filename> Also displays the contents of a file on the screen. Allows
you to move backwards through the file.
Using both less and more you can use
• space to display the next page
• carriage return to display the next line
• b to move back one page
• q to quit the file display
2
1.3
Wildcards
Very useful UNIX functions!
• “*” matches any string
• “?” matches any character
Examples include ls *.c Lists all files with extension (ending in) “.c”
ls ?.c Lists all files with one-character filenames and “.c” extension.
ls *prog*.c Lists all files containing the string “prog” in the filename and
a “.c” extension.
1.4
More file manipulation commands
cp <old_filename> <new_filename> Copies the contents of old_filename
to new_filename.
mv <old_filename> <new_filename> Moves the contents of old_filename
to new_filename.
rm <filename> Deletes the file filename. This can be dangerous! you
can easily delete files by accident
A safer command is rm -i <filename> which asks you if you really want
to delete the file you specified. You can use the command alias to execute
rm -i when you type rm. Much safer! Try man alias to figure this out.
chmod This changes the file “modes”, in other words the permissions to read,
write and execute a given file. As the owner of a file you can add or remove
read, write and execute priviledges from everyone or specific groups. An
example:
chmod a+rwx program1.c I’ve just given “all” ie. everyone, read, write and
execute permission for program1.c. If I change my mind and don’t want
people able to write over my program then
chmod a-w program1.c removes write permission but still allows read and
execute.
3
Download