NEXT UP previous
Next: My Home Page

Answers

  1. One possible solution would be to use the find command to generate a list of all the file names on the system starting at the root directory and then have it search these for any core files and print out their pathnames:
    	$ find | -name core -print 2>/dev/null
    
    Don't forget, that as an ordinary user, there are directories to which you have no access and which will normally cause find to generate error messages. These messages can be suppressed by redirecting them to /dev/null.

  2. The ps command will provide a list of all your processes which are associated with your terminal. Using the -x switch will cause ps to display any processes you are running that are not associated with your terminal as well. Suppressing the ps header line is done with the -h switch. After this, each line output by ps has a process ID in the first field, which is made up of the first five characters on the line. This can be extracted and displayed as follows:

    	$ p5 -xh | cut -b1-5
    


  3. Logged in as root, the command ps -xh will list all the processes on the system, not just those owned by root. This makes getting a list of just the process IDs of those processes that belong to root a little more challenging. However, it can still be done one way is:
    	$ ps -uxh | grep "~root" | cut -b1O-14 
    
    Here the -u switch has been added to ps so that it lists the user name to which each process belongs, at the start of the line. This list can then be piped to grep to extract just those lines that begin with root. Extracting and printing the process ID from those lines is the same as before except that the PID field is in a different place, which can be identified by examining the output from the ps command.

  4. It is quite straightforward to obtain the correct list of file names generated with an appropriate is command. This can then be piped into the sort program using the -n switch to give numerical sorting and another parameter to specify where in each line the number may be found:
    	$ ls /dev/hda[0-9]* | sort -n +0.8
    
    Notice that ls automatically produces its output one file name per line when it is being sent to a pipe, rather than several file names per line, which it gives when its output is being sent to the screen. To demonstrate this try the two command lines:
    	$ ls
    	$ ls cat
    
    which you might otherwise expect to produce the same output.

  5. If you look at the man page for the od command you will find it has the -s switch which does a lot of what is required (i.e. it finds all the strings). The -Ax switch will also cause the file offsets to be displayed in hexadecimal, as required. This can then be piped into cut just to extract the offset field and leave the strings behind:

    	$ od -s -Ax /bin/cat | cut -b1-6
    

NEXT UP previous
Next: My Home Page