I was helping someone out the other day and was VNC’d into their server watching them work. I asked them to make a directory about 5 levels deep into the file system. They proceeded to make each directory one by one using mkdir. When they were done, I actually removed them all so I could spend a second to show them how to do so much quicker… Let’s say the directory you need created is /tmp/usr/tmp. Rather than using 3 mkdir commands and cd’ing in between it would actually behoove one to go about using the -p option with the mkdir command. To make this directory structure you could actually…
-
-
Writing Shell Scripts
There’s usually a few different steps in the learning process for writing shell scripts. The first is to figure out how to just do simple things, like write hello world to the screen. The second is to start using a series of commands. The third seems to be using variables. The fourth is to start using libraries to reuse your scripts. The next is to take variables to the next level, variabalizing everything. Where are you at with this?
-
ps
Limit process listing to those belonging to a given user by piping the output through grep. For example, processes belonging to a user with a username charles can be displayed with the following: ps -ef | grep charles The -l option generates a long listing, and when used together with the -e and -f options creates a table with 15 columns, which can also be piped for the user name: ps -efl | grep charles
-
Creating a crontab
Creating your first crontab job is a three-part process: Prepare the absolute path to the program or script that you want to run Create a text file containing a line to schedule the job as described above for crontab fields Upload the text file to your system cron When preparing program to run or creating scripts to run remember that crontab jobs are background tasks. There is no terminal attached to a crontab job so there should be no print statements that normally write to the screen. (It is possible to redirect such print statements.) The same consideration hold true for requesting user input. Let’s assume that we want to…
-
Directory Listing with Permissions
To list the files in a directory with the permissions for files, use the following command (assuming you’re in the working directory you would like to list files for: ls -al
-
vnode
The vnode table represents all file activity in UNIX. There is a unique vnode allocated in the vnode table for each active file, each current directory, each mounted-on file, text file, and the root. To see the number of vnodes available in Mac OS X, look to sysctl for the kern.maxvnodes variable using something similar to the following command: sysctl -A | grep vnode