1 / 30

Log on and off r43sgao.managed.mst from a campus PC

Make sure that X-win32 is installed on the PC. This is useful for displaying graphics Make sure that putty is installed on the PC. It is used to connect to r43 If you want to do connect to the computer from outside campus, make sure that your VPN (virtual private network) is on

koto
Download Presentation

Log on and off r43sgao.managed.mst from a campus PC

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Make sure that X-win32 is installed on the PC. This is useful for displaying graphics Make sure that putty is installed on the PC. It is used to connect to r43 If you want to do connect to the computer from outside campus, make sure that your VPN (virtual private network) is on Click on xwin-32 Click on putty In Host Name, type your_user_name@r43sgao.managed.mst.edu Click “Keyboard” and select Control-H Click “Session” and put “r43sgao” below “Saved Sessions” Click on “Save” Double click “r43sgao” and login Note: You only need to do the last step next time you start Putty Notes: 1). r43sgao is a Linux workstation owned by the Geophysics group and is located in the IT building 2). If you need to work outside MST, you need to have mst-vpn installed on your PC (call the IT help desk for instruction) 3). You can also set up xwin-32 to directly logon to r43sgao, but it is slower. Log on and off r43sgao.managed.mst.edu from a campus PC

  2. Set up your account on r43 • After you logged on, type /home/sgao/r43setup.cmd • Do not worry about “…. Cannot create directory ..” • Then logout by typing exit • Login again • To test the setups, type sac • You should see “sac >” • Type q or exit to quit sac

  3. General Format of Linux commands • A Linux command line consists of the name of a Linux command followed by its "arguments" (options and the target filenames and/or expressions). • For instance, the general syntax for a Linux command is     ($ is the prompt and please do not type the $. Most of you have r43sgao{abc}100: as the prompt where abc is your username) $ command -options targets Note: There must be a space between the 3 parts, and no space after the “-” Also, all Linux commands uses the lower case • Here command can be thought of as a verb, options as an adverb and targets as the direct objects of the verb. In the case that the user wishes to specify several options, these need not always be listed separately (the options can sometimes be listed altogether after a single dash). For example: $ ls–a $ ls –al

  4. The Unix/Linux file system Every ‘item’ in a Unix file system belongs to one of the four types of “files” • Ordinary files (e.g., ASCII files, binary files) • Directories (folders) • Devices (in the /dev directory) • Links (including hard and soft links)

  5. A typical Linux file structure

  6. Essential directories / The "root" directory (the very top level). /bin Essential low-level system utilities /usr/bin Higher-level system utilities and application programs /sbinSuperuser system utilities (for performing system administration tasks) /lib Program libraries (collections of system calls that can be included in programs by a compiler) for low-level system utilities /usr/lib Program libraries for higher-level user programs /tmp Temporary file storage space (can be used by any user) /etc Linux system configuration and information files /dev Hardware devices

  7. Two ways to specify a file • Absolute path: e.g., /nethome/users/sgao/demo/02_gmt/plot.gmt will be reached no matter will you are in the file system • Relative path: e.g., if you are in /nethome/users/sgao, the file above can be reached as demo/02_gmt/plot.gmt; or if you are in /nethome/users/sgao/demo/04_sac, the file can be reached as ../02_gmt/plot.gmt (note, in Unix, a single dot (.) means the current directory, and a double dot (..) means the upper level. For instance, the command cp /nethome/users/sgao/demo/02_gmt/plot.gmt . (note the dot at the end of the line above) copies the file plot.gmt in the directory /nethome/users/sgao/demo/02_gmt to wherever you typed the command above

  8. Getting around in your file system When you log into r43sgao, your current working directory is your user home directory. It is named as /nethome/users/USERNAME where USERNAME is your username (e.g upv22 for me) You can refer to your home directory at any time as "~“ and the home directory of other users as "~<login>“ where <login> is the login name of the user. For instance, “cd ~sgao/demo” will take you (from any place on the system) to the demo directory under sgao. Typing cd without any directory name takes you to your home directory (cd is the same as cd ~)

  9. To make things more confusing … • On r43sgao, there are 2 disks. One is /data which is also called /home. It has 10 TB of space. The second one is /data1 which is also called /nethome. It has about 5 TB of space. Our home directories are all located on /data1. • For historical reasons, some users have account on /data and some do not. For this class, always use your home directory for your work.

  10. Properties of a file/directory The properties can be found by using “ls –l”. typeis a single character which is either 'd' (directory), '-' (ordinary file), 'l' (symbolic link), 'b' (block-oriented device) or 'c' (chacracter-oriented device). permissionsis a set of characters describing acess rights. There are 9 permission characters, describing 3 access types given to 3 user categories. The three access types are read ('r'), write ('w') and execute ('x'), and the three users categories are the user who owns the file, users in the group that the file belongs to and other users (the general public). An 'r', 'w' or 'x' character means the corresponding permission is present; a '-' means it is absent. linksrefers to the number of filesystem links pointing to the file/directory owner is usually the user who created the file or directory. group denotes a collection of users who are allowed to access the file according to the group access rights specified in the permissions field. size is the length of a file, or the number of bytes used by the operating system to store the list of files in a directory. dateis the date when the file or directory was last modified (written to). nameis the name of the file or directory.

  11. The many forms of cp • Make a copy of a file: cp source-file destination-file • Copy a file to a directory: cp source-file destination-dir • Copy more than one files to a directory: cp source-files destination-dir • Copy a file to the upper-level dir: cp source-file .. • Copy a file from the upper-level to this dir: cp ../source-file . • Copy a file from two levels up to this dir: cp ../../source-file . • Copy a file using absolute path: cp /nethome/users/sgao/demo/02_gmt/plot.gmt . • Copy a file from sgao’s home dir to your current dir: cp ~sgao/demo/02_gmt/plot.gmt . • Copy entire directory (including all the contents): cp –r source-dir destination-dir

  12. Rename and move using mv mv is used to rename files/directories and/or move them from one directory into another. • Rename file1 as file2: mv file1 file2 • Rename directory 1 as directory 2: mv dir1 dir2 • Move a file to a directory: mv file dir • Move a file to the upper level: mv file .. • Move a file from the upper level to the current dir: mv ../file . • Move file1 from the upper level to the current dir and rename it as file2: mv ../file1 file2 • Move a file or dir using absolute path to the current dir: mv/nethome/users/sgao/demo/02_gmt/plot.gmt . • Move directory1 to directory2: mv dir1 dir2

  13. Deleting files and directories • Remove a file: rm file • Remove a file without confirmation: /bin/rm file • Remove all the files in a directory: rm * • Remove all the files in a directory without confirmation: /bin/rm * • Remove a directory and all its contents without confirmation: /bin/rm –fr dir • Remove a file in a directory: rm dir/file • Remove a file in the upper level: rm ../file • Remove all files with a name starting with b,c,d,and e: rm [a-e]*

  14. Many ways to view a file • Note: before you trying to edit/view a file, find the type of the file using: file file_name • Only text or ascii files should be edited/viewed • more file: view the contents of file screen by screen. Hit the space bar to scroll to the next page • less file: view the file using less. Similar to more • head –n file: view the first n lines of file • tail –n file: view the last n lines of the file • vi file: edit the file using vi (this is the most powerful way to edit a file)

  15. Hard and soft (symbolic) links • Hard link: ln filename linkname creates another directory entry for filename called linkname (i.e. linkname is a hard link). Both directory entries appear identical (and both now have a link count of 2). If either filename or linkname is modified, the change will be reflected in the other file (since they are in fact just two different directory entries pointing to the same file). •   Soft link: ln -s filename linkname creates a shortcut called linkname (i.e. linkname is a soft link. Its file name has a ‘@’ at the end). You should use soft link

  16. Specifying multiple filenames using wildcards • '?' matches any single character in that position in the filename. • '*' matches zero or more characters in the filename. A '*' on its own will match all files. '*.*' matches all files with containing a '.'. • Characters enclosed in square brackets ('[ ]’) will match any filename that has one of those characters in that position. Examples: • ??? matches all three-character filenames. • ?ell? matches any five-character filenames with 'ell' in the middle. • he* matches any filename beginning with 'he'. • [m-z]*[a-l] matches any filename that begins with a letter from 'm' to 'z' and ends in a letter from 'a' to 'l'.

  17. File and Directory Permissionsthree kinds of permissions: r (read), w (write), x (execute) The user can change the permissions using chmod. Examples: chmoda+x file (all users can execute the file as a command) chmod a-x,u+x dir (no one but you and the superuser can cd to dir)

  18. Couldn’t find your file? Find a file: find directory -name targetfile find . –name targetfile Find the location of a command: which command-name which ls

  19. Finding string in a file using grep grep options pattern files Examples: grep hello *.txt searches all text files in the current directory for lines containing "hello". grep -vi hello *.txt searches all text files in the current directory for lines that do not contain any form of the word hello (e.g. Hello, HELLO, or hELlO).

  20. File compression and restoration • tar (tape archiver) tar backs up entire directories and files onto a tape device or (more commonly) into a single disk file known as an archive. An archive is a file that contains other files plus information about them, such as  their filename, owner, timestamps, and access permissions. tar does not perform any compression by default. To create a disk file tar archive, use tar -cvf archivenamefilenames directories where archivename will usually have a .tar extension. Here the c option means create, v means verbose (output filenames as they are archived), and f means file. To list the contents of a tar archive, use tar -tvf archivename To restore files from a tar archive, use tar -xvf archivename To compress a file: compress file (the output file name will end with a .Z) To uncompress a compressed file: uncomperss compressed-file If the file ends with .gz, use: gunzip compressed-file

  21. A powerful editor Vi is short for “view” Vim is short for “vi improved” Vi and vim are the same on core Your hands need not to move away from the keyboard to reach the mouse or the arrow keys The key to handle vi is that there are two modes: When you first get into vi (by typing vi file_name), you are in the command mode. What you CANNOT do in command mode: entering text What you can do in command mode: Moving cursors around: to move the cursor down: j to move the cursor up: k to move to the left: h to move to the right: l 2. To delete things: to delete a character: move the cursor on the character and type x to delete a word: move the cursor on the beginning of the word and type dw to delete a line: move the cursor to the line and type dd to move a line to a different place: move the cursor to the line to be deleted, type dd, and then move the cursor to where you want the new line to be, and type p Note: there are many more things you can do. See page 126 of the Unix book Basics of vi or vim

  22. To get into the insert mode, type one of the following letters in command mode: a – insert after the cursor; i --- insert before the cursor Hit the “Esc” key to return to command mode Note: the insert mode is for inserting (typing) only. For anything else, you need to use the command mode. To save the file (of course, you need to be in command mode), type the sign : and they type wq (means write and quit). In order to learn vi well, you need a lot of practice. The www has many good resources. Search vim practice on Google. Also please refer to page 126 of the Unix book More on vim

  23. Some good practices to organize your files • The key principle: a ‘tree-root’ structure of folders with meaningful names. • Example: Under my home directory, I have the Pubs (for publications) directory, I have directories such as Papers (for papers), Courses etc. • And under Proj, I have dir like North (for my research) • Under North, I have different directories, each contains files/directories. • As the number of files accumulates, you will definitely get lost in the file system if you do not have a reasonable tree-root structure

  24. echo hello world mkdir test date date -u hostname arch uptime who am i who id last finger w pwd ps top (you need to press q to quit) echo $shell man ls (you may need to press q to quit) man who (you may need to press q to quit) ls -a last clear cal 2011 julday 8 24 2012 bc -l (type quit or press Ctrl-d to quit) echo 5+4 | bc -l time sleep 5 history Very basic ractice: Log on to r43sgao using putty Enter these commands at the Linux prompt, and try to interpret the output. Ask questions and don't be afraid to experiment (as a normal user you cannot do much harm):

  25. Practice 1 • Try the following command sequence: • cd • mkdir test2 • cd test2 • echo hello world >testfile1.txt • pwd • ls -al • cd . • pwd     (where did that get you?) • cd .. • pwd • ls -al • cd .. • pwd • ls -al • cd .. • pwd     (what happens now) • cd /etc • ls -al | more • cat passwd • cd ~ • pwd

  26. Practice 2 • Continue to explore the filesystem tree using cd, ls, pwd and cat. Look in /bin, /usr/bin, /sbin, /tmp and /boot. What do you see? • Explore /dev. Can you identify what devices are available?  • Change to the home directory of another user directly, using cd ~username. • Change back into your home directory. • Make subdirectories called work and play. • Delete the subdirectory called work. • Copy the file /etc/passwd into your home directory. • Move it into the subdirectory play. • Still in your home directory, copy the entire directory play to a directory called work, preserving the symbolic link. • Delete the work directory and its contents with one command. Accept no complaints or queries. • Change into a directory that does not belong to you and try to delete the files

  27. Practice 3 • find ~sgao/demo –name plot5.gmt • cd ~ • mkdir test3 • cd test3 • cd .. • chmod a-x test3 • cd test3 (what do you see and how to solve the problem) • Find the location of the following commands: ls, pwd, psxy, sac, pstext, latex • cd • mkdir test4 • cd test4 • echo ‘hello my world’ >tmp1.txt • echo ‘this is my test’ >tmp2.txt • grep my *txt • grep world *txt • cd • tar –cvf test.tar * • cd test3 • pwd • mv ../test.tar . • tar –xvf test.tar • ls (what do you see and why?)

  28. Creating a file call vip.txt using vi Typing five lines of text with each line containing 5 or more words Save the file Vi the file again. Delete the 3rd word in the 2nd line Delete the 3rd line Move the 2nd line to a new place between lines 3 and 4 Add a new line at the end of the file Save the file Practice 4: vi practice

  29. http://www.lagmonster.org/docs/vi.html#quit

More Related