All pastes #994469 Raw Edit

Miscellany

public text v1 · immutable
#994469 ·published 2008-04-23 13:00 UTC
rendered paste body
Use the cut command on the output of a long directory listing in order to
display only the file permissions. Then pipe this output to sort and uniq
to filter out any double lines. Then use the wc to count the different
permission types in this directory.

        ls -la | cut -b 1-10 | tail -n +2
      

Put the output of date in a file. Append the output of ls to this file. 

        date >date.txt
        ls >>date.txt


List the devices in /dev which are currently used by your UID. Pipe
through less to view them properly.

        ls -la | grep $(whoami) | less


How many processes are you currently running?

        ps aux | wc -l


How many invisible files are in your home directory?

        ls -lad .* | tail -n +3


Find out which file contains the following entry:

root:x:0:0:root:/root:/bin/bash

        grep -r '^root:x:0:0:root:/root:/bin/bash$' /etc


And this one:

system:         root

        grep -r '^system:  *root$' /etc


See what happens upon issuing this command:

> time; date >> time; cat < time

        1) create file `time'
        2) append date to file `time'
        3) cat content of file `time'


What command would you use to check which script in /etc/init.d starts a given
process?

        grep -ri '<enter-process-name-here>' /etc/init.d