Anda di halaman 1dari 6

Useful UNIX Commands

pwd Print the present working (current) directory


ls List names of all files in the current directory
ls pattern List only files matching pattern (e.g. *.txt)
ll or Long listing of all files in the current
ls –l directory.
(those are all lowercase
L's, not 1's!) See page 5 for more details.
cd filepath Change directories to the given filepath
cd or cd ~ Return to the home directory
cd .. Go up one directory
mv path1 path2 path1 is the name of a file or directory.
If path2 is a directory, moves the file or
directory there.
Otherwise, renames the file/directory to the
new name.
cp path1 path2 Same as mv, but does a copy instead of a
move/rename.
rm file Deletes the given file.
rm –r dirname Recursively deletes all files and directories in
the given directory.
mkdir dirname Creates a new subdirectory in the current
directory, called dirname.
rmdir dirname Deletes the directory name. NOTE: The
directory must be empty or this will fail!
man command Prints a manual page for the given command
(e.g. ls, rm, etc.). Press q to quit the manual.
pine Starts a text-only e-mail application.
pico filename Starts a text-only text editor.
man command Get detailed info on a specific command.
↑ Recall the last command entered.
(tab key) Finish a filename you're typing (if possible)
Task Chart
Task Windows UNIX
Rename file/directory Right-click a file and choose mv file1 file2
“Rename”
Delete file Select a file and press Delete rm file1
Move file/directory Right-click a file and choose mv file1 path1
“Copy To…”
Create new directory Select File -> New -> Folder mkdir dirname
Delete entire directory Select a directory and press rm –r dirname
Delete
Show all files in a directory Double-click the directory ls or ll
Log off Start -> Shut Down -> Log Click small "power" icon on
Off toolbar

Useful Internet Links


http://www.google.com/ - The Google search engine; use it for searching the Internet.
http://www.yahoo.com/ - Another great place to start.
http://mail.cs.yorku.ca/ - You can check your mail online with this. Use your CS account
login and password.
http://www.cs.yorku.ca/course/1020/ - course home page.
http://www.registrar.yorku.ca/ - Registrar home page, where you can log in to check your
financial info, grades, course enrolment, or see schedules.
http://www.editplus.com/ - Homepage for EditPlus, a great freeware text editor. Can also
be used as an FTP program!
http://www.mozilla.com/ - Homepage for Mozilla Firefox and Thunderbird, free browser
and e-mail programs.
http://filezilla.sourceforge.net/ - Homepage for FileZilla, a free FTP program.
http://www.chiark.greenend.org.uk/~sgtatham/putty/ - Homepage for PuTTY, a great
Telnet/SSH program. Just type cs.yorku.ca as the host.
http://www.cs.yorku.ca/tdb/_doc.php/userg/howto/ - Information on using CDROMs or
USB keys with Linux computers at York.
http://www.personal.kent.edu/~rmuhamma/OpSystems/unixCommands.htm - quick
reference guide for more UNIX commands. Remember to use
man command for more detailed information for specific commands.
Common File Types

Ext. Program Description


.txt Notepad Plain text file.
.doc Microsoft Word Formatted document (text styles, tables, columns,
embedded images and objects, etc.)
.java Crimson, nedit, javac Java program in plain text format.
(compiling)
.class java (runtime) Compiled Java class for running.
.exe None Executable program; double-click it to run.
.gif, .jpg, Photoshop, Image Various types of image files. BMP files tend to be very
.png, .bmp Viewer large and should not be sent via e-mail.
.wav, .mp3, Windows Media Sound files. WAVs are raw sound files and can be quite
.wma, .mid Player, Winamp large.
.avi, Microsoft Media Video files.
.mp(e)g, Player
.wmv
.htm, .html Internet Explorer, HTML Web Pages, which allow for embedded images
Mozilla Firefox and animation.
.pdf Adobe Acrobat Adobe Acrobat format: a commonly used format
Reader available for reading on almost all platforms. Creating
them requires special programs, however.
.zip, .rar, CompressedFolder Compressed files; each file consists of one or more files
.tar, .bz2, (WinXP), WinZip, or folders compressed to save space and allow sending as
.7z WinRar, 7-Zip; gzip, a single file.
tar (UNIX)

Other Things of Interest


Viewing File Extensions in Windows

By default, Windows will not display file extensions in folder windows. To see the
extensions:

• Go to the Tools -> Folder Options menu.


• Click the “View” tab.
• Make sure the checkbox for “Hide extensions for known file types” is unchecked.
Telnet and FTP
You have an "account" at York. This account allows you up to 150 MB of disk
space. You can store all your files here. You can also access your files and your account
from home!
FTP (File Transfer Protocol) is a way to send files from your home computer to
your CS account or vice versa. In FTP programs, a file on your home computer is called a
local file, and your CS account will contain remote files. Using an FTP client like
FileZilla, you can transfer files between the two places easily. Note that transferring a file
to your home computer is called downloading, and transferring it from home to your CS
account is called uploading.
However, while you can transfer files this way, you can't do any commands (such
as copying files between directories or creating new files). That's what Telnet is for.
Telnet allows you to remotely log in to your CS account from home, as if you're running
a terminal on a Linux machine at York. The downside is that you can only use text-based
programs, such as pine (text-only e-mail) and pico (text-only text editor). PuTTY is the
best Telnet client to use (see link above).

Your Prism Account


Your CS account is accessible from any computer in the first-floor labs in the
Computer Science building. You can also access your account space from the Windows
computers in the teaching lab (Prism 1004). Log in and go to “My Computer”, and the Z:\
drive will hold your CS account space.
Remember that if you save any file in “My Documents”, you will have to log on
to that exact computer if you want to find it again. So you should only save onto the Z:\
drive.

Printing Single-Sided
By default, documents will be printed double-sided. To change it to single-sided,
you need access to the "lpr" command. "lpr" is the UNIX command which sends
documents to the printer. Many programs (e.g. Adobe Acrobat, Mozilla Firefox) let you
change what the command looks like. Change the command from
lpr
to
lpr –Zsimplex

...or at least make sure that "-Zsimplex" appears somewhere after "lpr".
Note that many programs (such as NEdit) do not let you directly change the "lpr"
command. If you're looking at text or images, your best bet is probably just to open it
using Firefox, which can handle any kind of text, image, or PDF file.
Linux Programs
Program Windows version Program Type Description
Terminal MS-DOS Prompt Terminal window Enter commands to work with files
and programs.
File Manager Windows Explorer File manager View, open, copy, or move files
using a graphical interface.
Mozilla Firefox Internet Explorer Browser Browse the Internet, check course
web pages, message boards, etc.
Mozilla Thunderbird Outlook Express E-mail Check your e-mail and newsgroups.
Nedit Notepad/EditPlus Text editor Create and edit plain-text files. Has
syntax highlighting (coloring words
with different meanings in
programming languages).
OpenOffice Microsoft Office (Word, Office suite Create rich-text documents with
Excel, PowerPoint) imbedded images, create Powerpoint
slide shows, or use a spreadsheet.
Gimp Paint, Photoshop Image editor Create and edit images (JPG, BMP,
etc.)
Xmms Winamp, Windows Music player Play music files.
Media Player

File Listings (ls –l command)

1: "d" indicates a directory, "-" indicates a regular file.


2: "read", "write", and "execute" permissions for the file's owner. If any of them aren't allowed,
there will be a "-" instead of a "r", "w", or "x".
3: "read", "write", and "execute" permissions for the file's "group".
4: "read", "write", and "execute" permissions for everyone else.
5: You can ignore this column.
6: The username of the file's owner.
7: The file's "group".
8: The file's size in bytes. One kilobyte (KB) is about 1,000 bytes. One megabyte (MB) is about
1,000 KB.
9: The date and time it was most recently changed.
10: The actual file name.

Note that some filenames are hidden. To view them, type ls –a (for the short version)
or ls –la (for the long one). (Those are all lowercase L's, not 1's.)
You can also recursively list the contents of all subdirectories in your current directory by typing
ls –R.
Your First Java Program
public class Hello
{ public static void main(String[] args)
{ System.out.println(“Hello world!”);
}
}

Instructions:
1. Open a terminal window by clicking the black box on the toolbar
2. Type pwd to see what directory you're in
3. Type mkdir java to create a new directory for your Java
programs
4. Type cd java to enter your new directory
5. Type pwd to see your new path
6. Open a text editor by typing nedit &
7. Type the text above into the text editor
8. Save as “Hello.java” in the "java" subdirectory
9. Type ls to make sure you see Hello.java in your directory
10. Type javac Hello.java to compile your program
11. Type ls to make sure Hello.class is there
12. Type java Hello to run your program

Remember: If the class is called "Hello", the file must be saved as


"Hello.java". (Note: NOT "hello.java"!) Case matters!

Anda mungkin juga menyukai