UNIVERSIDADE DA BEIRA INTERIOR Programação II / Programação e Algoritmos BE + EI + TSI Como aceder à conta geral da UBI e usar o “nano” Usando Windows 1) Fazer login na máquina local (ou computador pessoal) 2) Utilizar o Putty para aceder a unix.ubi.pt Na primeira vez será questionado se pretende gravar a chave – diga que sim (apenas deverá dizer não se suspeitar que se está a ligar a um computador errado): 3) Introduza a username (número de aluno) e password: Usando Linux 1) Fazer login na máquina local (ou computador pessoal) 2) Ligar-se através de ssh ao computador remoto (apenas pergunta a primeira vez se têm a certeza): Página 2 de 6 Usar o editor (nano) 1) Chamar o editor e escrever os programas: 2) Gravar o ficheiro: CTRL + X Página 3 de 6 3) Y (Yes) para gravar; N (No) para não gravar; CTRL + C para voltar ao editor 4) <Enter> para manter o mesmo nome Página 4 de 6 5) Compilar: gcc nome.c –o nome (gcc -o nome nome.c) 6) Executar: ./nome The Nano Text Editor Introduction Nano is a text editor suited to working in UNIX. It is not as powerful as PC window-based editors, as it does not rely on the mouse, but still has many useful features. Most nano commands are invoked by holding down the Ctrl key (that is, the control key), and pressing one of the other keys. In this text, the control key is referred to using ^. For example, ^X means ``hold down the CTRL key and press the x key''. Most of the important commands are listed at the bottom of your screen. ^G nano help Starting nano To edit a file called filename, type nano filename. In nano, you can insert another file: ^R read an existing file into nano (inserted at the current cursor position) ^T opens a browser that allows you to select a file name from a list of files and directories Página 5 de 6 Navigation The usual mouse-based point-and-click method is not supported by nano. Use the arrow keys to move around the page in nano. Other navigation commands: ^A move to beginning of line ^E move to end of line ^Y move down a page ^V move up a page ^_ move to a specific line (^_^V moves to the top of the file, ^_^Y to the bottom) ^C find out what line the cursor is currently on ^W search for some text. When searching, you will be prompted for the text to search for. It searches from the current cursor position, wrapping back up to the top if necessary. Editing Insert new text at the current cursor position just by typing the text in. Delete commands: ^D delete character currently under the cursor BackSpace delete character currently in front of the cursor ^K delete entire line ^\ search for (and replace) a strong of characters Cut and paste ^K does not delete lines permanently; the most recent set of deletions are stored in a buffer. These lines may be re-inserted at the current cursor location using ^U. This may be used to simulate cut and paste: • Repeatedly use ^K until all of the text you want to move has been deleted. • Move to the line that you want to insert the text at, and use ^U. Note that pressing ^U more than once will cause multiple copies to be inserted. This is particularly useful if you want to copy text: • Repeatedly use ^K until all of the text you want to copy has been deleted. • Press ^U immediately to put a copy back in its original location. • Move to the line that you want to copy the text to, and use ^U. Saving and Exiting ^O save contents without exiting (you will be prompted for a file to save to) ^X exit nano (you will be prompted to save your file if you haven't) when saving a file, opens a browser that allows you to select a file name from a list of ^T files and directories Página 6 de 6