Introductory linux: processes and dfile management.
Last time Basic linux commands ls, cd, rm, cp, mv, man, more, less Wildcards Piping and redirecting File permissions
Today Some more linux commands Processes Disk management
Tab completion You can use tab completion to finish commands. For example: fire <TAB> firefox cd /user1/mccau <TAB> cd /user1/mccauley A very useful shortcut t that t can save a lot of typing. Use <cntrl>-d to see a list of possible tab completions.
Keyboard Shortcuts Command Line history. Use the and keys. Edit and move cursor using and Jump around using <cntrl>-a and <cntrl>-e Jump to start and end of line. Can use <cntrl>-k to delete rest of line. Lock screen <cntrl>-s Unlock with <cntrl>-q
Printing To print a file generally you can use lpr Works for text files and postscipt. For PDF files you will need to use a program acroread xpdf To specify a printer lpr Pprinter To check the printer queue lpq To delete a job use lprm
Processes A process is a binary file running on the system These can be anything from KERNEL to web browsers, to editors to your analysis code. A process that t goes bad can bring the system to a halt. Often your analysis code But editors or web browsers etc can do this too.
Ways to monitor processes ps command top List all the processes for the current shell ps u mccauley List all processes for user mccauley Shows all processes and resources Listed in order of CPU usage. Good way to identify rogue processes.
Killing gprocess If its running on your terminal can try <cntrl>c Won t always work Use the kill command Use ps or top to find out the processor id kill pid Switches -15, like control-c -9 really really kill this process.
Background and Foreground Processes Processes can run in the background or foreground. Foreground processes are attached to your terminal. Background processes are not and will continue if the terminal closes (in most cases) To launch a process in the background use & firefox & A foreground process can also be suspended <cntrl>-z use fg or bg to restart in the background or foreground.
Being nice All processes use resources. Resource usage from a prioritised list. Depends on nice level Use nice to set level nice firefox Can renice a process using renice renice 10 pid On a many user platform large jobs should in general be niced to be nice to other users.
Disk Usage Disks and file systems are a finite size. You need to know how much you are using. du df quota How much is in the directory specified? How much space is in the file system specified? How much space am I using relative to my quota?
The du command Useful switches: -k How much space in kb. -m How much space in MB. -s Summary, don t display subdirectories. -h Human readable output. Make use of a pipe du m sort n Sorts subdirectories smallest largest. sort n sorts numerically.
The df command Tells you how much space is left on a filesystem. Reports the fractional usage. Better measurement of system usage for a full file system than du. Reports the space used by the files.
The quota command Often on a filesystem you will have a quota. This is the maximum amount of data you can have on a filesystem. Your quota and how much you ve used can be checked using the quota command. quota v The quota and usage for the current user.
Archiving and Compression gzip --- Compress a file. gzip myfile.txt myfile.txt.gz gunzip --- Uncompress a file. gunzip myfile.txt.gz myfile.txt Use tar to archive files tar cf mytar.tar mydir/* mytar.tar tar xf mytar.tar mydir/* Other switches -v Verify list all files in archive process -t List all files in archive (ls for tar) -z tar followed by gzip (or gunzip) (not on all systems) -u Update, adds files to an archive.
Symbolic Links There are two types of symbolic links. Hardlinks Same filesystem only. Two files point to the same file. ln file1.txt file2.txt Softlinks File2 points to File1. ln s file2.txt file1.txt
What if I m using too much space? Try archiving/compressing some files. Search for large unusable files A good example are core files core.******* Memory dump from a crashing program Search for old data files. Obsolete data files (eg root files) can take up a lot of space. Search for old backup files Eg myfile.txt~ from xemacs. Look for old objects, libraries and executables you don t use. If you ve still got the source code do you need these?
Backed up file systems Sometimes you ll lose a file you need. Accidentally deleted. Disk crashes. Some file systems are backed up, others are not. If you lose a file on a backed up file system it can usually be recovered by the system administrator. On a file system that is not backed up the file is gone for good. Be careful to store important files on systems that are backed up. Check on your local system to see which, but in general your home directory will be safe.
On the hep system Home directories i backed up nightly No same day recovery. Two week grace period. If you don t ask for two weeks the file is gone. Email helpdesk immediately if you need a file recovered. Disk on your desktop is not backed up. Scratch space only.
Scratch space Temporary storage space. Expires after a set time period. Data will be lost. On hep 6TB scratch space To be sent as in transition. 1 week for storage.
Exercises Show me what processes you have running on the server. Determine the disk usage in your home directory Clean up pyour home directory to save space.