MINIMUM LINUX INTRODUCTION FOR USERS ======= ===== ============ === ===== [R.Sonnenfeld - NMT Physics - August 2007] 1 sh-3.2$ #Sometimes you can forget what machine you are on! 2 sh-3.2$ hostname 3 speare4b-3-4 4 #Sometimes you can forget who you are! 5 sh-3.2$ whoami 6 rsonnenf 10 sh-3.2$ #Directories are arranged as trees with "/" as the "root". 11 sh-3.2$ cd / 12 sh-3.2$ tree -L 2 |more 13 sh-3.2$ #Actually the tree is upside down! 14 sh-3.2$ #You often forget where you are! 15 sh-3.2$ pwd #pwd -- present working directory 16 /u/rsonnenf 17 sh-3.2$ #Change to a new directory 18 sh-3.2$ cd phys241 #cd -- change directory 19 sh-3.2$ pwd 20 /u/rsonnenf/phys241 21 sh-3.2$ #Go back up one level 22 sh-3.2$ cd .. # .. mean go up one level 23 sh-3.2$ pwd 24 /u/rsonnenf 25 sh-3.2$ #Go back down 26 sh-3.2$ cd /phys241 27 bash: cd: /phys241: No such file or directory 28 sh-3.2$ # OOPS! -- /phys241 means a directory off of root. 29 sh-3.2$ # This works -- it's the full path name. 30 sh-3.2$ cd /u/rsonnenf/phys241 31 sh-3.2$ pwd 32 /u/rsonnenf/phys241 33 sh-3.2$ #list files (ls) 34 sh-3.2$ ls 35 lectures linuxintro.txt matlab mysteryfile test.m 36 sh-3.2$ mkdir newdirectory 37 sh-3.1$ ls 38 lectures linuxintro.txt matlab mysteryfile newdirectory test.m 39 sh-3.2$ ls -l #list files with the "long" option -- more info. 40 total 24 41 drwxr-sr-x 2 rsonnenf 1612 4096 Aug 22 18:35 lectures 42 -rw-r--r-- 1 rsonnenf 1612 6785 Aug 22 18:37 linuxintro.txt 43 drwxrwx--- 9 rsonnenf 1612 4096 Aug 20 19:02 matlab 44 -rw-rw---- 1 rsonnenf 1612 0 Aug 23 07:04 mysteryfile 45 drwxr-sr-x 2 rsonnenf 1612 4096 Aug 22 18:19 newdirectory 46 -rw-rw---- 1 rsonnenf 1612 3 Aug 23 07:03 test.m 47 sh-3.2$ Recognize the directories because they have a "d" in front. 48 sh-3.1$ #cp -- The copy command cp inputfile outputfile 49 sh-3.1$ #cp is used on your machine only 50 sh-3.1$ cp linuxintro.txt mysteryfile 51 cp: overwrite `mysteryfile'? y 52 #Moving files to remote machines: 53 gftp & 54 #Type in the host name and your password 55 #Choose the "SSH" or "SFTP" protocol rather than FTP 69 #Logging into remote machines -- ssh (secure shell) 70 -bash-3.1$ ssh richard@feynman.nmt.edu 72 #General command syntax -- 73 # command -options inputfile (if any) outputfile (if any) 74 # To look up a command, use "man" 75 #Finally -- we talk about editors. Choose pico or vim. 76 # If you choose "vim", run "vimtutor" to learn it. 77 # Also -- "The easy way" -- gftp -- 78 # Seeing what is in a file -- "more". 79 # MORE HELP 80 #http://www.physics.nmt.edu/~rsonnenf/computerlab/computers.html 81 82 #Can't resist showing a script -- 83 $ more dateloop.scr #!/bin/bash # This shows off how to do a command forever while waiting for something to happen until [ 1 = 0 ] do date -u +'%D %H:%M:%S.%NZ' sleep 0.01 done exit 0