0% found this document useful (0 votes)
49 views

VNC Server & Unix

1. The document provides instructions on basic Unix commands for creating, copying, renaming, removing, editing, and moving files. 2. It describes how to use cat to create a file, cp to copy a file, mv to rename or move a file, rm to remove a file, and vi to edit a file. 3. It also explains how to use mv and cp to move or copy files into directories.

Uploaded by

Ken Kent Chen
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
49 views

VNC Server & Unix

1. The document provides instructions on basic Unix commands for creating, copying, renaming, removing, editing, and moving files. 2. It describes how to use cat to create a file, cp to copy a file, mv to rename or move a file, rm to remove a file, and vi to edit a file. 3. It also explains how to use mv and cp to move or copy files into directories.

Uploaded by

Ken Kent Chen
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 6

Checklist 1. Open VNC session 2. Close VNC session 3. Create directory 4. Remove directory 5. Create file 6.

Copy file 7. Rename file 8. Remove file 9. Edit file 10. Move and copy file into directory VNC http://intranet.cs.hku.hk/csintranet/contents/technical/howto/vnc.jsp Open a session with size specification 1. vncserver -geometry [x-axis]x[y-axis] Close a session 1. vncserver -kill :[display number] Unix Basic commands http://www.rshweb.biz/getstarted/unix.html Name erase Characters* Ctrl-H (backspace) Behavior Erase last character typed

kill intr

Ctrl-U Ctrl-C

Erase entire typed line Interrupt program (kill) current

quit

Ctrl-\

Quit (kill) program and produce core dump End-of-file input) (no more

eof

Ctr-D

Spacebar Enter key q key h key cat

To scroll to next page To scroll to next line To quit from more and get back to shell prompt To get a help screen of characters that more understands To print out while file without page breaks

/bin /usr/bin /dev

User commands such as date, cal, cp etc. User commands beyond those stored in /bin Device interface files, such as block (type b) and character (type c) special files System administration commands and configuration files "Grab bag" of other system directories; Subdirectories that contain commands, libraries, log files, databases, e-mail systems, and so on. (Some UNIX shops establish their users' home directories as subdirectories of /usr.) Online reference manual Administrative configuration and log files Local directories that can e mounted by remote systems Users' home directories (on some systems) Miscellaneous libraries and directories Temporary storage space Temporary storage space beyond that provided in /tmp Files with variable content, such as news and mail System-independent files, such as the online UNIX reference manual

/etc /usr

/usr/share /usr/adm /export /home /usr/lib /tmp /usr/tmp /var /usr/share

Guide to Using vi Entering and exiting vi file-name ZZ :q! Cursor Movement Arrow keys Single-character, moves single-line Edit file-name Save changes and quit Quit without saving

hjkl

single-character, single line moves: left, down, up, right Forward, screen) backward (full

Ctrl-F, Ctrl-B

/str, ?str

Forward, backward search for str

Inserting Text I a o,O Insert before cursor Append after cursor Open line after, before current line Return to Command mode

Esc Deleting Text x dd Miscellaneous u _

Delete current character Delete current line

Undo last text change Redo last text change

J http://www.itcs.umich.edu/itcsdocs/s4148/#createfile Creating a File

Join current line and next line

Many people create files using a text editor, but you can use the command cat to create files without learning a text editor. To create a practice file (named firstfile ) and enter one line of text in it, type the following at the % prompt: cat > firstfile (Press the Enter/Return key.) This is just a test. (Press the Enter/Return key.) Stop file entry by typing Control-d on a line by itself. (Hold down the Control key and type d.) On your screen you will see: % cat > firstfile This is just a test. ^D One way to examine the contents of the file you've just created is to enter this at the % prompt: cat firstfile

Copying a File To make a duplicate copy of a file, use the command cp. For example, to create an exact copy of the file called firstfile, you would type: cp firstfile secondfile The result is two files with different names, each containing the same information. The cp command works by overwriting information. If you create a different file called thirdfile and then type the following command: cp thirdfile firstfile you will find that the original contents of firstfile are gone, replaced by the contents of thirdfile .

Renaming a File Unix does not have a command specifically for renaming files. Instead, the mv command is used both to change the name of a file and to move a file into a different directory. To change the name of a file, use the following command format (where thirdfile and file3 are sample file names): mv thirdfile file3 The result of this command is that there is no longer a file called thirdfile , but a new file called file3 contains what was previously in thirdfile. Like cp, the mv command also overwrites existing files. For example, if you have two files, fourthfile and secondfile, and you type the command mv fourthfile secondfile mv will remove the original contents of secondfile and replace them with the contents of fourthfile . The effect is that fourthfile is renamed secondfile , but in the process secondfile is deleted.

Removing a File Use the rm command to remove a file. For example, rm file3 deletes file3 and its contents. You may remove more than one file at a time by giving a list of files to be deleted. For example, rm firstfile secondfile You will be prompted to confirm whether you really want to remove the files: rm: remove firstfile (y/n)? y rm: remove secondfile (y/n)? n Type y or yes to remove a file; type n or no to leave it. Editing a File http://www.december.com/unix/tutor/textedit.html http://www.cs.colostate.edu/helpdocs/vi.html

vi [file] i :x Moving and Copying Files Into a Directory The mv and cp commands can be used to put files into a directory. Assume that you want to put some files from your current directory into a newly created directory called project1. The command mv bibliography project1 will move the file bibliography into the directory project1. The command cp chapter1 project1 will put a copy of the file chapter1 into the directory project1, but leave chapter1 still in the current directory. There will now be two copies of chapter1, one in the current directory and one in project1. Remember that when moving files to new directory, we must include ~/; example: mov ~/dir1/file1 ~/dir2 means moving file1 from dir1 to new directory dir2 must list the whole path to the directory

You might also like